Skip to content

Commit

Permalink
feat(AttentionBox): add prop for enter animation
Browse files Browse the repository at this point in the history
  • Loading branch information
rivka-ungar committed Oct 28, 2024
1 parent b19996b commit 1a4303d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
18 changes: 18 additions & 0 deletions packages/core/src/components/AttentionBox/AttentionBox.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
@keyframes enterAnimation {
0% {
transform: translateY(-10px);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
transform: translateX(0);
opacity: 1;
}
}

.attentionBox {
position: relative;
padding: 12px var(--spacing-medium);
Expand All @@ -6,6 +20,10 @@
max-width: 100%;
height: fit-content;

&.animateOnEnter {
animation: enterAnimation 200ms cubic-bezier(0.00, 0.00, 0.40, 1.00) forwards;
}

// Overriding on primary icon color should be with bigger specificity than the original color
& .closeIconWrapper .closeIcon {
color: var(--primary-text-color);
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/components/AttentionBox/AttentionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface AttentionBoxProps extends VibeComponentProps {
onClose?: (event: React.MouseEvent) => void;
compact?: boolean;
closeButtonAriaLabel?: string;
animateOnEnter?: boolean;
}

const AttentionBox: React.FC<AttentionBoxProps> & {
Expand All @@ -59,7 +60,8 @@ const AttentionBox: React.FC<AttentionBoxProps> & {
compact = false,
id,
"data-testid": dataTestId,
closeButtonAriaLabel = "Close"
closeButtonAriaLabel = "Close",
animateOnEnter = false
}) => {
const overrideClassName = backwardCompatibilityForProperties([className, componentClassName]);

Expand All @@ -71,7 +73,9 @@ const AttentionBox: React.FC<AttentionBoxProps> & {

return (
<aside
className={cx(styles.attentionBox, getStyle(styles, camelCase(`type-${type}`)), overrideClassName)}
className={cx(styles.attentionBox, getStyle(styles, camelCase(`type-${type}`)), overrideClassName, {
[styles.animateOnEnter]: animateOnEnter
})}
role="alert"
data-testid={dataTestId || getTestId(ComponentDefaultTestId.ATTENTION_BOX, id)}
>
Expand Down

0 comments on commit 1a4303d

Please sign in to comment.