diff --git a/packages/core/stories/dialog/dialog.qa.stories.tsx b/packages/core/stories/dialog/dialog.qa.stories.tsx index 2de141de572..ee12e594d0b 100644 --- a/packages/core/stories/dialog/dialog.qa.stories.tsx +++ b/packages/core/stories/dialog/dialog.qa.stories.tsx @@ -252,6 +252,38 @@ export const DialogHeaders: StoryFn = () => ( width: 600, }} /> + + + + diff --git a/packages/core/stories/dialog/dialog.stories.tsx b/packages/core/stories/dialog/dialog.stories.tsx index 51210567490..45a4a3b42be 100644 --- a/packages/core/stories/dialog/dialog.stories.tsx +++ b/packages/core/stories/dialog/dialog.stories.tsx @@ -295,11 +295,16 @@ Preheader.args = { }; const AlertDialogTemplate: StoryFn< - DialogProps & { header: string; content: ReactNode } + DialogProps & { + header: string; + content: ReactNode; + description?: ReactNode; + } > = ({ open: openProp = false, status, header, + description, size = "small", content, ...args @@ -356,7 +361,7 @@ const AlertDialogTemplate: StoryFn< // focus the ok instead of the cancel button initialFocus={initialFocusButtonIndex} > - + {content} {direction === "column" ? ( @@ -400,6 +405,34 @@ ErrorStatus.args = { header: "Error", }; +export const InfoStatusWithDescription = AlertDialogTemplate.bind({}); +InfoStatusWithDescription.args = { + status: "info", + header: "File update", + description: "A new version is available with important changes.", +}; + +export const SuccessStatusWithDescription = AlertDialogTemplate.bind({}); +SuccessStatusWithDescription.args = { + status: "success", + header: "Transaction complete", + description: "Your payment has been processed successfully.", +}; + +export const WarningStatusWithDescription = AlertDialogTemplate.bind({}); +WarningStatusWithDescription.args = { + status: "warning", + header: "Session expiring", + description: "Your session will expire in 5 minutes.", +}; + +export const ErrorStatusWithDescription = AlertDialogTemplate.bind({}); +ErrorStatusWithDescription.args = { + status: "error", + header: "Connection failed", + description: "Unable to connect to the server. Please try again.", +}; + export const MandatoryAction: StoryFn = ({ open: openProp = false, }) => { diff --git a/site/docs/components/dialog/examples.mdx b/site/docs/components/dialog/examples.mdx index 8720bee4ff8..7dd0b921f98 100644 --- a/site/docs/components/dialog/examples.mdx +++ b/site/docs/components/dialog/examples.mdx @@ -60,6 +60,12 @@ Don’t use the info dialog when the information concerns a successful action. I +## Status with description + +All status dialogs support the `description` prop on `DialogHeader` to provide additional context below the header. This is useful when you need to give users more information about the status without adding it to the dialog content. + + + ## Error Use the error status to communicate a critical issue that prevents the user from continuing or completing it. diff --git a/site/src/examples/dialog/InfoWithDescription.tsx b/site/src/examples/dialog/InfoWithDescription.tsx new file mode 100644 index 00000000000..9df1467242f --- /dev/null +++ b/site/src/examples/dialog/InfoWithDescription.tsx @@ -0,0 +1,87 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogHeader, + FlexLayout, + StackLayout, + type StackLayoutProps, + useId, + useResponsiveProp, +} from "@salt-ds/core"; +import { type ElementType, type ReactElement, useState } from "react"; + +export const InfoWithDescription = (): ReactElement => { + const [open, setOpen] = useState(false); + const id = useId(); + + const handleRequestOpen = () => { + setOpen(true); + }; + + const onOpenChange = (value: boolean) => { + setOpen(value); + }; + + const handleClose = () => { + setOpen(false); + }; + + const direction: StackLayoutProps["direction"] = + useResponsiveProp( + { + xs: "column", + sm: "row", + }, + "row", + ); + + const close = ( + + ); + + const seeUpdates = ( + + ); + + return ( + <> + + + + + A new version of this file is available with 26 updates. + + + {direction === "column" ? ( + + {seeUpdates} + {close} + + ) : ( + + {close} + {seeUpdates} + + )} + + + + ); +}; diff --git a/site/src/examples/dialog/index.ts b/site/src/examples/dialog/index.ts index d7b1ab10c8e..6155fa36c49 100644 --- a/site/src/examples/dialog/index.ts +++ b/site/src/examples/dialog/index.ts @@ -3,6 +3,7 @@ export * from "./Default"; export * from "./DisableScrim"; export * from "./Error"; export * from "./Info"; +export * from "./InfoWithDescription"; export * from "./MandatoryAction"; export * from "./Preheader"; export * from "./Sizes";