Skip to content

Commit

Permalink
add simple animated AI poc
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwinter07 committed Feb 6, 2025
1 parent 538d1b9 commit 95a9664
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,31 @@ export const SecondaryAction: Story = {
},
},
}

export const AiTile: Story = {
args: {
aiProps: {
isAi: true,
},
},
}

export const AiLoadingTile: Story = {
render: ({ aiProps, primaryAction: _, ...otherProps }) => {
const [isAiLoading, setIsAiLoading] = React.useState(false)

return (
<MultiActionTile
primaryAction={{ onClick: () => setIsAiLoading(!isAiLoading), label: 'Perform AI action' }}
aiProps={{ isLoading: isAiLoading, isAi: aiProps?.isAi }}
{...otherProps}
/>
)
},
args: {
aiProps: {
isAi: true,
isLoading: true,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,55 @@ $tilePaddingTop: $spacing-xl;
margin-top: $spacing-sm;
height: $spacing-xl;
}

.isAi {
--gradient-shadow: linear-gradient(
45deg,
#fb0094,
#0000ff,
#00ff00,
#ffff00,
#ff0000,
#fb0094,
#0000ff,
#00ff00,
#ffff00,
#ff0000
);
}

.isAi.isLoading {
position: relative;
border-color: transparent;

&:before,
&:after {
content: '';
position: absolute;
top: -2px;
left: -2px;
background: var(--gradient-shadow);
background-size: 400%;
width: calc(100% + 4px);
height: calc(100% + 4px);
z-index: -1;
border-radius: calc(var(--border-solid-border-radius) + 1px);
animation: pulse 20s linear infinite;
}

&:after {
filter: blur(20px);
}

@keyframes pulse {
0% {
background-position: 0 0;
}
50% {
background-position: 300% 0;
}
100% {
background-position: 0 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type GenericTileProps = {
title: React.ReactNode
titleTag?: AllowedHeadingTags
metadata?: string
aiProps?: {
isAi?: boolean
isLoading?: boolean
}
information?: TileInformation | React.ReactNode
/** Provides accessible label for the title's info button @default "View more information: [title]" */
infoButtonLabel?: string
Expand All @@ -48,6 +52,7 @@ export const GenericTile = ({
variant = 'default',
footer,
classNameOverride,
aiProps,
...restProps
}: GenericTileProps): JSX.Element => {
const [isFlipped, setIsFlipped] = useState<boolean | undefined>()
Expand Down Expand Up @@ -158,7 +163,14 @@ export const GenericTile = ({

return (
<div className={classnames(styles.root, classNameOverride)} {...restProps}>
<div className={classnames(styles.tile, isFlipped && styles.isFlipped)}>
<div
className={classnames(
styles.tile,
isFlipped && styles.isFlipped,
aiProps?.isAi && styles.isAi,
aiProps?.isLoading && styles.isLoading,
)}
>
<>
{renderFront()}
{renderBack()}
Expand Down
52 changes: 52 additions & 0 deletions packages/components/src/Well/Well.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,55 @@
--border-color: transparent;
--border-style: none;
}

.isAi {
--gradient-shadow: linear-gradient(
45deg,
#fb0094,
#0000ff,
#00ff00,
#ffff00,
#ff0000,
#fb0094,
#0000ff,
#00ff00,
#ffff00,
#ff0000
);
}

.isAi.isLoading {
position: relative;
border-color: transparent;
border-width: 1px;
&:before,
&:after {
content: '';
position: absolute;
top: -2px;
left: -2px;
background: var(--gradient-shadow);
background-size: 400%;
width: calc(100% + 4px);
height: calc(100% + 4px);
z-index: -1;
border-radius: calc(var(--border-solid-border-radius) + 1px);
animation: pulse 20s linear infinite;
}

&:after {
filter: blur(20px);
}

@keyframes pulse {
0% {
background-position: 0 0;
}
50% {
background-position: 300% 0;
}
100% {
background-position: 0 0;
}
}
}
7 changes: 7 additions & 0 deletions packages/components/src/Well/Well.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export type WellProps = {
/** @default `solid` */
borderStyle?: WellBorderStyleType
noMargin?: boolean
aiProps?: {
isAi?: boolean
isLoading?: boolean
}
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>

/**
Expand All @@ -25,6 +29,7 @@ export const Well = ({
color = 'white',
borderStyle = 'solid',
noMargin = false,
aiProps,
classNameOverride,
...restProps
}: WellProps): JSX.Element => (
Expand All @@ -35,6 +40,8 @@ export const Well = ({
styles[color],
variant && styles[variant],
noMargin && styles.noMargin,
aiProps?.isAi && styles.isAi,
aiProps?.isLoading && styles.isLoading,
classNameOverride,
)}
{...restProps}
Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/Well/_docs/Well.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,20 @@ export const NoMargin: Story = {
</div>
),
}

export const AiSummary: Story = {
args: {
aiProps: {
isAi: true,
},
},
}

export const AiSummaryLoading: Story = {
args: {
aiProps: {
isAi: true,
isLoading: true,
},
},
}

0 comments on commit 95a9664

Please sign in to comment.