From cf92ec9a25e3340d91f1523affa9da08b38239b0 Mon Sep 17 00:00:00 2001 From: Fernanda Castillo Date: Wed, 4 Dec 2024 14:33:59 +0000 Subject: [PATCH 1/6] Updates to headers alignment --- .changeset/poor-scissors-chew.md | 5 ++++ packages/core/src/dialog/DialogHeader.css | 1 + packages/lab/src/dialog/DialogHeader.css | 4 ++- packages/lab/src/dialog/DialogHeader.tsx | 3 +- packages/lab/src/overlay/OverlayHeader.css | 1 - .../lab/stories/dialog/dialog.qa.stories.tsx | 28 +++++++++++------- .../lab/stories/dialog/dialog.stories.tsx | 6 ++++ .../stories/overlay/overlay.qa.stories.tsx | 12 +++++--- .../lab/stories/overlay/overlay.stories.tsx | 29 +++++++++++++++++-- 9 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 .changeset/poor-scissors-chew.md diff --git a/.changeset/poor-scissors-chew.md b/.changeset/poor-scissors-chew.md new file mode 100644 index 00000000000..eda562ba27b --- /dev/null +++ b/.changeset/poor-scissors-chew.md @@ -0,0 +1,5 @@ +--- +"@salt-ds/lab": patch +--- + +fix alignment for titles spanning into multiple lines, wrap labs dialog header in H2 to avoid breaking change diff --git a/packages/core/src/dialog/DialogHeader.css b/packages/core/src/dialog/DialogHeader.css index 0fa72081a0e..fa35e6ba786 100644 --- a/packages/core/src/dialog/DialogHeader.css +++ b/packages/core/src/dialog/DialogHeader.css @@ -17,6 +17,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.css b/packages/lab/src/dialog/DialogHeader.css index 17aeb97d312..3d32cd686ad 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; diff --git a/packages/lab/src/dialog/DialogHeader.tsx b/packages/lab/src/dialog/DialogHeader.tsx index 6ea6463beff..22395b47826 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, @@ -86,7 +87,7 @@ export const DialogHeader = forwardRef( {preheader && ( {preheader} )} - {header} +

{header}

{description && ( diff --git a/packages/lab/src/overlay/OverlayHeader.css b/packages/lab/src/overlay/OverlayHeader.css index 2a74f8fd5b0..da5e7af7276 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/stories/dialog/dialog.qa.stories.tsx b/packages/lab/stories/dialog/dialog.qa.stories.tsx index a3a355afe7e..e9b7cc3ecdc 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 f1aaa1e77be..ea20eeac614 100644 --- a/packages/lab/stories/dialog/dialog.stories.tsx +++ b/packages/lab/stories/dialog/dialog.stories.tsx @@ -145,6 +145,12 @@ export const Default = DialogTemplate.bind({}); Default.args = { id: "Default", }; +export const LongTitle = DialogTemplate.bind({}); +Default.args = { + id: "LongTitle", + header: + "Complete terms and conditions for using the services provided by our company", +}; const AlertDialogTemplate: StoryFn< DialogProps & { header: ReactNode; content: ReactNode } diff --git a/packages/lab/stories/overlay/overlay.qa.stories.tsx b/packages/lab/stories/overlay/overlay.qa.stories.tsx index 1c7b5a5a0c4..3288dd2fcc9 100644 --- a/packages/lab/stories/overlay/overlay.qa.stories.tsx +++ b/packages/lab/stories/overlay/overlay.qa.stories.tsx @@ -29,8 +29,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 cf640781114..4a9d6cb56ea 100644 --- a/packages/lab/stories/overlay/overlay.stories.tsx +++ b/packages/lab/stories/overlay/overlay.stories.tsx @@ -13,14 +13,14 @@ import { } 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(); @@ -40,7 +40,7 @@ export const Header = ({ onOpenChange }: OverlayProps) => { width: 500, }} > - Header block} /> + Header block} {...props} /> @@ -62,6 +62,29 @@ 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(); From 29642c7e9551a3066dd854936fcd4e52226e2424 Mon Sep 17 00:00:00 2001 From: Fernanda Castillo Date: Tue, 17 Dec 2024 10:13:27 +0000 Subject: [PATCH 2/6] Updates to stories --- .../lab/stories/dialog/dialog.stories.tsx | 2 +- .../stories/overlay/overlay.qa.stories.tsx | 8 +++++-- .../lab/stories/overlay/overlay.stories.tsx | 21 ++++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/lab/stories/dialog/dialog.stories.tsx b/packages/lab/stories/dialog/dialog.stories.tsx index ea20eeac614..2f6f50ec25f 100644 --- a/packages/lab/stories/dialog/dialog.stories.tsx +++ b/packages/lab/stories/dialog/dialog.stories.tsx @@ -146,7 +146,7 @@ Default.args = { id: "Default", }; export const LongTitle = DialogTemplate.bind({}); -Default.args = { +LongTitle.args = { id: "LongTitle", header: "Complete terms and conditions for using the services provided by our company", diff --git a/packages/lab/stories/overlay/overlay.qa.stories.tsx b/packages/lab/stories/overlay/overlay.qa.stories.tsx index 3288dd2fcc9..f4f00c1d5cc 100644 --- a/packages/lab/stories/overlay/overlay.qa.stories.tsx +++ b/packages/lab/stories/overlay/overlay.qa.stories.tsx @@ -1,6 +1,6 @@ import { Button, - H4, + H2, Overlay, OverlayPanel, OverlayPanelContent, @@ -47,7 +47,11 @@ export const Default: StoryFn = (props) => { Guidelines for optimal use of our application} + 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 4a9d6cb56ea..965bda0ec6b 100644 --- a/packages/lab/stories/overlay/overlay.stories.tsx +++ b/packages/lab/stories/overlay/overlay.stories.tsx @@ -1,6 +1,6 @@ import { Button, - H4, + H2, Overlay, OverlayPanel, OverlayPanelContent, @@ -40,7 +40,14 @@ const HeaderTemplate: StoryFn = ({ onOpenChange, ...props }: OverlayProps) => { width: 500, }} > - Header block} {...props} /> + + Header block + + } + {...props} + /> @@ -68,11 +75,11 @@ 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: ( - - Header block - - } - {...props} - /> + @@ -74,13 +63,8 @@ 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 -

- ), + header: + "Comprehensive guidelines and detailed instructions for the optimal use and application of our services to ensure maximum efficiency and user satisfaction", actions: ( { - Header block - - } + header="Header block" actions={} /> diff --git a/site/src/examples/dialog/WithHeader.tsx b/site/src/examples/dialog/WithHeader.tsx index 14e2902a464..413511f99d9 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 ab50d3ba1c8..7d0afa0bcb4 100644 --- a/site/src/examples/overlay/WithHeader.tsx +++ b/site/src/examples/overlay/WithHeader.tsx @@ -1,11 +1,9 @@ import { Button, - H2, Overlay, OverlayPanel, OverlayPanelContent, OverlayTrigger, - useId, } from "@salt-ds/core"; import { CloseIcon } from "@salt-ds/icons"; import { OverlayHeader } from "@salt-ds/lab"; @@ -13,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); @@ -33,15 +30,8 @@ export const WithHeader = (): ReactElement => { - - - Title - - } - actions={headerActions} - /> + +
Content of Overlay
From f87436d3d34257726555dc09f3e80a1fcc4313b8 Mon Sep 17 00:00:00 2001 From: Fernanda Castillo Date: Fri, 20 Dec 2024 13:51:32 +0000 Subject: [PATCH 6/6] move updated css to labs changes --- packages/core/src/dialog/DialogHeader.css | 1 - packages/lab/src/dialog/DialogHeader.css | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/dialog/DialogHeader.css b/packages/core/src/dialog/DialogHeader.css index fa35e6ba786..0fa72081a0e 100644 --- a/packages/core/src/dialog/DialogHeader.css +++ b/packages/core/src/dialog/DialogHeader.css @@ -17,7 +17,6 @@ /* 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.css b/packages/lab/src/dialog/DialogHeader.css index 3d32cd686ad..a9003cc1d52 100644 --- a/packages/lab/src/dialog/DialogHeader.css +++ b/packages/lab/src/dialog/DialogHeader.css @@ -31,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} */