diff --git a/.changeset/poor-scissors-chew.md b/.changeset/poor-scissors-chew.md new file mode 100644 index 0000000000..c8fd1216d9 --- /dev/null +++ b/.changeset/poor-scissors-chew.md @@ -0,0 +1,5 @@ +--- +"@salt-ds/lab": patch +--- + +Overlay and Dialog headers fix alignment for titles spanning into multiple lines, wrap preheader and headers in H2. diff --git a/packages/lab/src/dialog/DialogHeader.css b/packages/lab/src/dialog/DialogHeader.css index 17aeb97d31..a9003cc1d5 100644 --- a/packages/lab/src/dialog/DialogHeader.css +++ b/packages/lab/src/dialog/DialogHeader.css @@ -3,12 +3,14 @@ padding-bottom: var(--salt-spacing-300); padding-left: var(--salt-spacing-300); padding-right: var(--salt-spacing-300); - align-items: center; display: flex; flex-direction: row; gap: var(--salt-spacing-100); box-sizing: border-box; } +.saltDialogHeader-header { + margin: 0; +} .saltDialogHeader-container { flex-grow: 1; @@ -29,6 +31,7 @@ /* Styles applied to the status indicator icon overriding its default size */ .saltDialogHeader .saltStatusIndicator.saltIcon { --icon-size: var(--salt-text-h2-lineHeight); + padding-top: calc((var(--salt-size-base) - var(--salt-text-h2-lineHeight)) / 2); } /* Styles applied to DialogHeader when accent={true} */ diff --git a/packages/lab/src/dialog/DialogHeader.tsx b/packages/lab/src/dialog/DialogHeader.tsx index 6ea6463bef..6b2eb226b7 100644 --- a/packages/lab/src/dialog/DialogHeader.tsx +++ b/packages/lab/src/dialog/DialogHeader.tsx @@ -1,4 +1,5 @@ import { + H2, StatusIndicator, Text, type ValidationStatus, @@ -82,12 +83,10 @@ export const DialogHeader = forwardRef( > {status && }
-
- {preheader && ( - {preheader} - )} +

+ {preheader && {preheader}} {header} -

+ {description && ( {description} diff --git a/packages/lab/src/overlay/OverlayHeader.css b/packages/lab/src/overlay/OverlayHeader.css index 2a74f8fd5b..da5e7af727 100644 --- a/packages/lab/src/overlay/OverlayHeader.css +++ b/packages/lab/src/overlay/OverlayHeader.css @@ -1,7 +1,6 @@ .saltOverlayHeader { padding: var(--salt-spacing-100); width: 100%; - align-items: center; display: flex; flex-direction: row; justify-content: stretch; diff --git a/packages/lab/src/overlay/OverlayHeader.tsx b/packages/lab/src/overlay/OverlayHeader.tsx index 0375929a12..76bb694390 100644 --- a/packages/lab/src/overlay/OverlayHeader.tsx +++ b/packages/lab/src/overlay/OverlayHeader.tsx @@ -1,4 +1,4 @@ -import { Text, makePrefixer } from "@salt-ds/core"; +import { H2, Text, makePrefixer } from "@salt-ds/core"; import { useComponentCssInjection } from "@salt-ds/styles"; import { useWindow } from "@salt-ds/window"; import { clsx } from "clsx"; @@ -45,12 +45,10 @@ export const OverlayHeader = forwardRef( return (
-
- {preheader && ( - {preheader} - )} +

+ {preheader && {preheader}} {header} -

+ {description && ( {description} diff --git a/packages/lab/stories/dialog/dialog.qa.stories.tsx b/packages/lab/stories/dialog/dialog.qa.stories.tsx index a3a355afe7..e9b7cc3ecd 100644 --- a/packages/lab/stories/dialog/dialog.qa.stories.tsx +++ b/packages/lab/stories/dialog/dialog.qa.stories.tsx @@ -1,4 +1,5 @@ -import { Dialog, H2 } from "@salt-ds/core"; +import { Button, Dialog } from "@salt-ds/core"; +import { CloseIcon } from "@salt-ds/icons"; import { DialogHeader } from "@salt-ds/lab"; import type { Meta, StoryFn } from "@storybook/react"; import { QAContainer, type QAContainerProps } from "docs/components"; @@ -11,7 +12,7 @@ export default { export const DialogHeaders: StoryFn = () => ( Terms and conditions} + header="Terms and conditions" style={{ width: 600, }} @@ -20,40 +21,47 @@ export const DialogHeaders: StoryFn = () => ( style={{ width: 600, }} - header={

Terms and conditions

} + header="Terms and conditions" preheader="Ensure you read and agree to these Terms" /> Terms and conditions} + header="Terms and conditions" preheader="Ensure you read and agree to these Terms" description="Effective date: August 29, 2024" /> Terms and conditions} + header="Terms and conditions" style={{ width: 600, }} /> + + + } status="info" style={{ width: 600, }} - header={

Terms and conditions

} - preheader="Ensure you read and agree to these Terms" + header="Terms and conditions" /> + + + } status="info" style={{ width: 600, }} - header={

Terms and conditions

} - preheader="Ensure you read and agree to these Terms" - description="Effective date: August 29, 2024" + header="Complete terms and conditions for using the services provided by our company" />
); diff --git a/packages/lab/stories/dialog/dialog.stories.tsx b/packages/lab/stories/dialog/dialog.stories.tsx index f1aaa1e77b..0ecb88f20a 100644 --- a/packages/lab/stories/dialog/dialog.stories.tsx +++ b/packages/lab/stories/dialog/dialog.stories.tsx @@ -5,7 +5,6 @@ import { DialogContent, type DialogContentProps, type DialogProps, - H2, SplitLayout, StackLayout, } from "@salt-ds/core"; @@ -24,7 +23,7 @@ export default { component: Dialog, args: { preheader: "Settlements", - header:

Terms and conditions

, + header: "Terms and conditions", description: "Effective date: August 29, 2024", content: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", @@ -145,6 +144,12 @@ export const Default = DialogTemplate.bind({}); Default.args = { id: "Default", }; +export const LongTitle = DialogTemplate.bind({}); +LongTitle.args = { + id: "LongTitle", + header: + "Complete terms and conditions for using the services provided by our company", +}; const AlertDialogTemplate: StoryFn< DialogProps & { header: ReactNode; content: ReactNode } @@ -201,23 +206,23 @@ const AlertDialogTemplate: StoryFn< export const InfoStatus = AlertDialogTemplate.bind({}); InfoStatus.args = { status: "info", - header:

Info

, + header: "Info", }; export const SuccessStatus = AlertDialogTemplate.bind({}); SuccessStatus.args = { status: "success", - header:

Success

, + header: "Success", }; export const WarningStatus = AlertDialogTemplate.bind({}); WarningStatus.args = { status: "warning", - header:

Warning

, + header: "Warning", }; export const ErrorStatus = AlertDialogTemplate.bind({}); ErrorStatus.args = { status: "error", - header:

Error

, + header: "Error", }; diff --git a/packages/lab/stories/overlay/overlay.qa.stories.tsx b/packages/lab/stories/overlay/overlay.qa.stories.tsx index 1c7b5a5a0c..a0035e0a75 100644 --- a/packages/lab/stories/overlay/overlay.qa.stories.tsx +++ b/packages/lab/stories/overlay/overlay.qa.stories.tsx @@ -1,6 +1,5 @@ import { Button, - H4, Overlay, OverlayPanel, OverlayPanelContent, @@ -29,8 +28,8 @@ export const Default: StoryFn = (props) => { return ( = (props) => { - + Header block} + header="Guidelines for optimal use of our application" actions={} /> diff --git a/packages/lab/stories/overlay/overlay.stories.tsx b/packages/lab/stories/overlay/overlay.stories.tsx index cf64078111..228a1f2712 100644 --- a/packages/lab/stories/overlay/overlay.stories.tsx +++ b/packages/lab/stories/overlay/overlay.stories.tsx @@ -1,6 +1,5 @@ import { Button, - H4, Overlay, OverlayPanel, OverlayPanelContent, @@ -9,20 +8,18 @@ import { StackLayout, Text, Tooltip, - useId, } from "@salt-ds/core"; import { CloseIcon } from "@salt-ds/icons"; import { OverlayHeader } from "@salt-ds/lab"; -import type { Meta } from "@storybook/react"; +import type { Meta, StoryFn } from "@storybook/react"; import { useState } from "react"; export default { title: "Lab/Overlay Header", } as Meta; -export const Header = ({ onOpenChange }: OverlayProps) => { +const HeaderTemplate: StoryFn = ({ onOpenChange, ...props }: OverlayProps) => { const [open, setOpen] = useState(false); - const id = useId(); const onChange = (newOpen: boolean) => { setOpen(newOpen); @@ -35,12 +32,11 @@ export const Header = ({ onOpenChange }: OverlayProps) => { - Header block} /> + @@ -62,9 +58,26 @@ export const Header = ({ onOpenChange }: OverlayProps) => { ); }; +export const Header = HeaderTemplate.bind({}); +Header.args = {}; + +export const LongHeader = HeaderTemplate.bind({}); +LongHeader.args = { + header: + "Comprehensive guidelines and detailed instructions for the optimal use and application of our services to ensure maximum efficiency and user satisfaction", + actions: ( + + ), +}; + export const HeaderWithCloseButton = ({ onOpenChange }: OverlayProps) => { const [open, setOpen] = useState(false); - const id = useId(); const onChange = (newOpen: boolean) => { setOpen(newOpen); @@ -90,7 +103,6 @@ export const HeaderWithCloseButton = ({ onOpenChange }: OverlayProps) => { { Header block} + header="Header block" actions={} /> diff --git a/site/src/examples/dialog/WithHeader.tsx b/site/src/examples/dialog/WithHeader.tsx index 14e2902a46..413511f99d 100644 --- a/site/src/examples/dialog/WithHeader.tsx +++ b/site/src/examples/dialog/WithHeader.tsx @@ -3,7 +3,6 @@ import { Dialog, DialogActions, DialogContent, - H2, H3, StackLayout, useId, @@ -44,7 +43,7 @@ export const WithHeader = (): ReactElement => { Terms and conditions} + header="Terms and conditions" description="Effective date: August 29, 2024" actions={closeButton} /> diff --git a/site/src/examples/overlay/WithHeader.tsx b/site/src/examples/overlay/WithHeader.tsx index 4a3b409995..7d0afa0bcb 100644 --- a/site/src/examples/overlay/WithHeader.tsx +++ b/site/src/examples/overlay/WithHeader.tsx @@ -4,7 +4,6 @@ import { OverlayPanel, OverlayPanelContent, OverlayTrigger, - useId, } from "@salt-ds/core"; import { CloseIcon } from "@salt-ds/icons"; import { OverlayHeader } from "@salt-ds/lab"; @@ -12,7 +11,6 @@ import { type ReactElement, useState } from "react"; export const WithHeader = (): ReactElement => { const [open, setOpen] = useState(false); - const id = useId(); const onOpenChange = (newOpen: boolean) => setOpen(newOpen); @@ -32,11 +30,8 @@ export const WithHeader = (): ReactElement => { - - Title} - actions={headerActions} - /> + +
Content of Overlay