From a742e81b9adee11c6b808d98af92e46c394d8e56 Mon Sep 17 00:00:00 2001 From: lisa Date: Tue, 18 Nov 2025 14:59:29 +0100 Subject: [PATCH 1/3] feat: small alert --- .changeset/dirty-parks-kick.md | 5 + .../Alert/__stories__/Size.stories.tsx | 57 +++++++++ .../Alert/__stories__/index.stories.tsx | 1 + .../__snapshots__/index.test.tsx.snap | 119 ++++++++++++------ .../components/Alert/__tests__/index.test.tsx | 6 + packages/ui/src/components/Alert/index.tsx | 24 +++- .../ui/src/components/Alert/styles.css.ts | 22 +++- 7 files changed, 189 insertions(+), 45 deletions(-) create mode 100644 .changeset/dirty-parks-kick.md create mode 100644 packages/ui/src/components/Alert/__stories__/Size.stories.tsx diff --git a/.changeset/dirty-parks-kick.md b/.changeset/dirty-parks-kick.md new file mode 100644 index 0000000000..fbe48528ca --- /dev/null +++ b/.changeset/dirty-parks-kick.md @@ -0,0 +1,5 @@ +--- +"@ultraviolet/ui": patch +--- + +`Alert`: add "size" prop diff --git a/packages/ui/src/components/Alert/__stories__/Size.stories.tsx b/packages/ui/src/components/Alert/__stories__/Size.stories.tsx new file mode 100644 index 0000000000..0a3d1affe3 --- /dev/null +++ b/packages/ui/src/components/Alert/__stories__/Size.stories.tsx @@ -0,0 +1,57 @@ +import type { Decorator } from '@storybook/react-vite' +import type { ComponentProps } from 'react' +import { Stack } from '../../Stack' +import { Alert } from '..' + +export const Size = (props: ComponentProps) => ( + <> + alert('Button clicked')} + title="title" + > + This is an Alert. + + + alert('Button clicked')} + size="small" + title="title" + > + This is a small alert + + alert('Button clicked')} + size="small" + title="title" + > + Small alert with long children. Lorem ipsum dolor sit amet, consectetur + adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco + laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in + reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla + pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa + qui officia deserunt mollit anim id est laborum., + + +) + +Size.decorators = [ + StoryComponent => ( + + + + ), +] as Decorator[] + +Size.parameters = { + docs: { + description: { + story: + 'Using `sentiment` prop you can change the sentiment of the component. Each sentiment has a default icon set.', + }, + }, +} diff --git a/packages/ui/src/components/Alert/__stories__/index.stories.tsx b/packages/ui/src/components/Alert/__stories__/index.stories.tsx index 373aa35200..b253b417f0 100644 --- a/packages/ui/src/components/Alert/__stories__/index.stories.tsx +++ b/packages/ui/src/components/Alert/__stories__/index.stories.tsx @@ -11,5 +11,6 @@ export { Title } from './Title.stories' export { Button } from './Button.stories' export { Link } from './Link.stories' export { Sentiments } from './Sentiments.stories' +export { Size } from './Size.stories' export { Closable } from './Closable.stories' export { LongChildren } from './LongChildren.stories' diff --git a/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap index ae3eb425b8..c594ae9d33 100644 --- a/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap @@ -1,15 +1,62 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`alert > renders correctly small 1`] = ` + +
+
+
+
+ + + +
+ + title + +

+ Sample Alert +

+
+
+
+
+
+
+`; + exports[`alert > renders correctly with all sentiments > renders correctly sentiment 'danger' 1`] = `
renders correctly with all sentiments > renders correctly senti />

renders correctly with all sentiments > renders correctly senti data-testid="testing" >

renders correctly with all sentiments > renders correctly senti />

renders correctly with all sentiments > renders correctly senti data-testid="testing" >

renders correctly with all sentiments > renders correctly senti />

renders correctly with all sentiments > renders correctly senti data-testid="testing" >

renders correctly with all sentiments > renders correctly senti />

renders correctly with all sentiments > renders correctly senti data-testid="testing" >

renders correctly with all sentiments > renders correctly senti />

renders correctly with buttonText and onClickButton 1`] = ` data-testid="testing" >

renders correctly with buttonText and onClickButton 1`] = ` />

renders correctly with buttonText and onClickButton 1`] = `

should display an alert when submitError is present />

render with alert 1`] = ` This summary provides a cost estimation based on your configuration, the amount of time you expect to use the resource for, and the scale of your expected usage. For the purposes of this calculation, we consider that 1 month equals to 730 hours.

render with alert 1`] = ` />
Date: Tue, 18 Nov 2025 16:55:33 +0100 Subject: [PATCH 3/3] fix: icon size --- .../Alert/__tests__/__snapshots__/index.test.tsx.snap | 6 +++--- packages/ui/src/components/Alert/index.tsx | 4 +++- packages/ui/src/components/Alert/styles.css.ts | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap index c594ae9d33..1335d8d030 100644 --- a/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Alert/__tests__/__snapshots__/index.test.tsx.snap @@ -16,12 +16,12 @@ exports[`alert > renders correctly small 1`] = ` style="--_4k0ekn3: 1 1 auto;" > diff --git a/packages/ui/src/components/Alert/index.tsx b/packages/ui/src/components/Alert/index.tsx index f55ee2846e..2f4388f623 100644 --- a/packages/ui/src/components/Alert/index.tsx +++ b/packages/ui/src/components/Alert/index.tsx @@ -16,6 +16,7 @@ import { alert, buttonAlert, buttonCloseAlert, + smallIcon, textAlert, wrapAlert, } from './styles.css' @@ -98,9 +99,10 @@ export const Alert = ({ >