Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AttentionBox): add prop for enter animation #2566

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
@keyframes entryAnimation {
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;

&.entryAnimation {
animation: entryAnimation 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;
entryAnimation?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description to this prop :)

}

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",
entryAnimation = 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.entryAnimation]: entryAnimation
})}
role="alert"
data-testid={dataTestId || getTestId(ComponentDefaultTestId.ATTENTION_BOX, id)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import * as AttentionBoxStories from "./AttentionBox.stories";

## Overview

Attention box lets users know important information within content areas, as close as possible to the content it’s about.
Attention box lets users know important information within content areas, as close as possible to the content it’s about. An optional smooth entrance animation can be used to enhance visibility.

<Canvas of={AttentionBoxStories.Overview} />

Expand Down Expand Up @@ -133,10 +133,16 @@ Provides additional information about an action or section.

### Attention box inside a dialog/combobox

Provides cotextual and related information.
Provides contextual and related information.

<Canvas of={AttentionBoxStories.AttentionBoxInsideADialogCombobox} />

### Animation

The Attention box component consist of enter animation prop to increase user attention. Is highly recommended to use a 200ms delay before the attention box entry motion once the page is fully loaded.

<Canvas of={AttentionBoxStories.AttentionBoxAnimation} />

## Related components

<RelatedComponents componentsNames={[ALERT_BANNER, TOAST, TOOLTIP]} />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import { useCallback } from "react";
import AttentionBox from "../AttentionBox";
import { createStoryMetaSettingsDecorator } from "../../../storybook";
Expand All @@ -13,6 +13,7 @@ import Flex from "../../Flex/Flex";
import Favorite from "../../Icon/Icons/components/Favorite";
import AttentionBoxLink from "../AttentionBoxLink/AttentionBoxLink";
import "./AttentionBox.stories.scss";
import Button from "../../Button/Button";

const metaSettings = createStoryMetaSettingsDecorator({
component: AttentionBox,
Expand Down Expand Up @@ -181,3 +182,38 @@ export const AttentionBoxInsideADialogCombobox = {

name: "Attention box inside a dialog/combobox"
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add live edit?

export const AttentionBoxAnimation = {
render: () => {
const [isOpen, setOpen] = useState(false);
const onClick = useCallback(() => {
setOpen(true);
}, []);
return (
<>
<Flex
gap={Flex.gaps.MEDIUM}
style={{
height: "44px"
}}
>
<Button onClick={onClick} kind={Button.kinds.SECONDARY}>
Entry animation
</Button>
{isOpen && (
<AttentionBox
compact
withIconWithoutHeader
entryAnimation
icon={Info}
text="First, move the content you want to copy into folder. Only main boards and dashboards can be copied."
onClose={() => setOpen(false)}
/>
)}
</Flex>
</>
);
},

name: "Attention box inside a dialog/combobox"
};