From c297d1c8d5d454afb6f7fe4ebdc19181ecdfc79a Mon Sep 17 00:00:00 2001 From: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:54:12 -0500 Subject: [PATCH] feat(dialog): S2 takeover dialog migration (#3347) * feat(dialog): adds new takeover dialog styles - new tokens and takeover dialog styles were implemented in index.css - rebuild tokens/metadata * docs(dialog): updates dialog template and stories - adds layout: "fullscreen" to render dialogs in their canvases, instead of off the canvas - uses getRandomId and renderContent functions to render header and footer contents - implements "slotted" components for the new takeover dialog feature - removes hasDivider since s2 dialogs don't support a divider - updates Figma links for fullscreen and fullscreenTakeover stories - updates some class names to better follow naming conventions * chore(dialog): clean up dialog tests - adds hasHeroImage arg - adds background and margin customStyles for fullscreen dialog in Chromatic only (so we can see the rounded corners better) fix(modal): update modal with takeover dialog styles - builds metadata - adds tokens for modal that complement new takeover dialog styles/tokens chore(dialog,modal): create changeset --- .changeset/modern-chairs-sit.md | 23 ++++++ components/dialog/dist/metadata.json | 27 +++++-- components/dialog/index.css | 44 ++++++++--- components/dialog/stories/dialog.stories.js | 81 ++++++++++++++++++--- components/dialog/stories/dialog.test.js | 39 ++++------ components/dialog/stories/template.js | 28 +++---- components/modal/dist/metadata.json | 5 +- components/modal/index.css | 19 +++-- tokens/custom/large-vars.css | 5 +- tokens/custom/medium-vars.css | 3 + tokens/dist/css/index.css | 6 ++ tokens/dist/css/large-vars.css | 3 + tokens/dist/css/medium-vars.css | 3 + tokens/dist/index.css | 6 ++ 14 files changed, 211 insertions(+), 81 deletions(-) create mode 100644 .changeset/modern-chairs-sit.md diff --git a/.changeset/modern-chairs-sit.md b/.changeset/modern-chairs-sit.md new file mode 100644 index 0000000000..6123465369 --- /dev/null +++ b/.changeset/modern-chairs-sit.md @@ -0,0 +1,23 @@ +--- +"@spectrum-css/dialog": major +"@spectrum-css/modal": minor +--- + +S2 Takeover dialog + +This is the migration for the fullscreen/fullscreenTakeover dialog stories (these stories correspond to the "takeover dialog" in Figma). The Divider component support was removed in S2 standard dialog migration ([#2860](https://github.com/adobe/spectrum-css/pull/2860)). New and updated tokens are in place to update fullscreen/fullscreenTakeover dialog sizing, grid spacing, spacing in the header, and font sizes. Fullscreen/fullscreenTakeover dialogs do not support additional footer content or checkboxes (in comparison to the standard dialog). + +Takeover dialogs also support replacing text in the header and body areas with other components. This required an additional `.spectrum-Dialog-headerContentWrapper` element that should center whatever component/content within. + +Class names updated to match naming convention (remove hyphens and capitalize second word): +`.spectrum-Dialog-header-content` > `.spectrum-Dialog-headerContent` +`.spectrum-Dialog-footer-content` > `.spectrum-Dialog-footerContent` + +_New Mods_ +`--mod-takeover-dialog-grid-spacing` +`--mod-takeover-dialog-spacing-header-content-gap` +`--mod-takeover-dialog-title-font-size` + +Modal updates + +- Modal component now uses the updated margin token (`window-to-edge`) found in the takeover dialog design specs. This work also introduced `--spectrum-modal-takeover-window-to-edge` diff --git a/components/dialog/dist/metadata.json b/components/dialog/dist/metadata.json index 33753fbe8e..738156392d 100644 --- a/components/dialog/dist/metadata.json +++ b/components/dialog/dist/metadata.json @@ -12,6 +12,7 @@ ".spectrum-Dialog--fullscreen .spectrum-Dialog-footer", ".spectrum-Dialog--fullscreen .spectrum-Dialog-grid", ".spectrum-Dialog--fullscreen .spectrum-Dialog-header", + ".spectrum-Dialog--fullscreen .spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog--fullscreen .spectrum-Dialog-heading", ".spectrum-Dialog--fullscreen.spectrum-Dialog .spectrum-Dialog-grid", ".spectrum-Dialog--fullscreenTakeover", @@ -21,6 +22,7 @@ ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-footer", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-grid", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-header", + ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-heading", ".spectrum-Dialog--fullscreenTakeover.spectrum-Dialog .spectrum-Dialog-grid", ".spectrum-Dialog--sizeL", @@ -30,12 +32,12 @@ ".spectrum-Dialog-closeButton", ".spectrum-Dialog-content", ".spectrum-Dialog-footer", - ".spectrum-Dialog-footer .spectrum-Dialog-footer-content", + ".spectrum-Dialog-footer .spectrum-Dialog-footerContent", ".spectrum-Dialog-footer:has(.spectrum-Dialog-buttonGroup)", - ".spectrum-Dialog-footer:has(.spectrum-Dialog-footer-content)", + ".spectrum-Dialog-footer:has(.spectrum-Dialog-footerContent)", ".spectrum-Dialog-grid", ".spectrum-Dialog-header", - ".spectrum-Dialog-header > .spectrum-Dialog-header-content", + ".spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog-heading", ".spectrum-Dialog-hero" ], @@ -61,7 +63,10 @@ "--mod-standard-dialog-spacing-footer-to-button-group", "--mod-standard-dialog-spacing-grid-padding", "--mod-standard-dialog-spacing-title-to-description", - "--mod-standard-dialog-spacing-title-to-header-content" + "--mod-standard-dialog-spacing-title-to-header-content", + "--mod-takeover-dialog-grid-spacing", + "--mod-takeover-dialog-spacing-header-content-gap", + "--mod-takeover-dialog-title-font-size" ], "component": [], "global": [ @@ -112,9 +117,21 @@ "--spectrum-standard-dialog-spacing-title-to-description", "--spectrum-standard-dialog-spacing-title-to-header-content", "--spectrum-standard-dialog-title-font-size", + "--spectrum-takeover-dialog-block-size", + "--spectrum-takeover-dialog-grid-spacing", + "--spectrum-takeover-dialog-height", + "--spectrum-takeover-dialog-inline-size", + "--spectrum-takeover-dialog-spacing-grid-padding", + "--spectrum-takeover-dialog-spacing-header-content-gap", + "--spectrum-takeover-dialog-spacing-header-gap", + "--spectrum-takeover-dialog-spacing-title-to-body", + "--spectrum-takeover-dialog-spacing-title-to-content", + "--spectrum-takeover-dialog-title-font-size", + "--spectrum-takeover-dialog-width", "--spectrum-title-line-height", "--spectrum-title-sans-serif-font-style", - "--spectrum-title-sans-serif-font-weight" + "--spectrum-title-sans-serif-font-weight", + "--spectrum-title-size-xxl" ], "passthroughs": [ "--mod-buttongroup-flex-wrap", diff --git a/components/dialog/index.css b/components/dialog/index.css index cd89fe5956..b4ea3002d3 100644 --- a/components/dialog/index.css +++ b/components/dialog/index.css @@ -53,6 +53,14 @@ /* Passthrough for nested component(s) */ --mod-buttongroup-justify-content: flex-end; --mod-buttongroup-flex-wrap: nowrap; + + /* Fullscreen/fullscreenTakeover */ + --spectrum-takeover-dialog-title-font-size: var(--spectrum-title-size-xxl); + --spectrum-takeover-dialog-grid-spacing: var(--spectrum-takeover-dialog-spacing-grid-padding); + --spectrum-takeover-dialog-spacing-header-content-gap: var(--spectrum-takeover-dialog-spacing-header-gap); + --spectrum-takeover-dialog-spacing-title-to-content: var(--spectrum-takeover-dialog-spacing-title-to-body); + --spectrum-takeover-dialog-inline-size: var(--spectrum-takeover-dialog-width); + --spectrum-takeover-dialog-block-size: var(--spectrum-takeover-dialog-height); } .spectrum-Dialog { @@ -151,7 +159,7 @@ outline: none; /* Hide focus outline around header */ /* additional header content should grow/shrink with the text, but only until it takes up half of the header */ - > .spectrum-Dialog-header-content { + > .spectrum-Dialog-headerContentWrapper { max-inline-size: fit-content; flex: 1 1 100%; font-size: var(--mod-standard-dialog-header-content-font-size, var(--spectrum-standard-dialog-header-content-font-size)); @@ -188,12 +196,12 @@ outline: none; /* Hide focus outline */ - .spectrum-Dialog-footer-content { + .spectrum-Dialog-footerContent { /* this attempts to give as much space as possible for the button group, particularly to avoid stacking on mobile. Some sizes still may have to stack. */ flex: 1 1 100%; } - &:has(.spectrum-Dialog-footer-content), + &:has(.spectrum-Dialog-footerContent), &:has(.spectrum-Dialog-buttonGroup) { justify-content: space-between; } @@ -248,13 +256,13 @@ } .spectrum-Dialog--fullscreen { - inline-size: 100%; - block-size: 100%; + inline-size: var(--spectrum-takeover-dialog-inline-size); + block-size: var(--spectrum-takeover-dialog-block-size); } .spectrum-Dialog--fullscreenTakeover { - inline-size: 100%; - block-size: 100%; + inline-size: var(--spectrum-takeover-dialog-inline-size); + block-size: var(--spectrum-takeover-dialog-block-size); border-radius: 0; } @@ -266,16 +274,16 @@ .spectrum-Dialog-grid { display: grid; grid-template-columns: - var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)) 1fr auto auto - var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)); grid-template-rows: - var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)) auto 1fr - var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)); grid-template-areas: ". . . . ." ". heading header buttonGroup ." @@ -285,6 +293,20 @@ .spectrum-Dialog-header { grid-area: heading; + gap: var(--mod-takeover-dialog-spacing-header-content-gap, var(--spectrum-takeover-dialog-spacing-header-content-gap)); + margin-inline-end: var(--mod-takeover-dialog-spacing-header-content-gap, var(--spectrum-takeover-dialog-spacing-header-content-gap)); + margin-block-end: var(--spectrum-takeover-dialog-spacing-title-to-content); + + /* components in fullscreen/fullscreenTakeover dialogs are centered in the headerContentWrapper */ + > .spectrum-Dialog-headerContentWrapper { + max-inline-size: unset; + display: inline-flex; + justify-content: center; + } + } + + .spectrum-Dialog-heading { + font-size: var(--mod-takeover-dialog-title-font-size, var(--spectrum-takeover-dialog-title-font-size)); } .spectrum-Dialog-closeButton { diff --git a/components/dialog/stories/dialog.stories.js b/components/dialog/stories/dialog.stories.js index e487943296..a203ed0658 100644 --- a/components/dialog/stories/dialog.stories.js +++ b/components/dialog/stories/dialog.stories.js @@ -1,6 +1,8 @@ import { withUnderlayWrapper } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import { size } from "@spectrum-css/preview/types"; +import { Template as Table } from "@spectrum-css/table/stories/template.js"; +import { Template as Steplist } from "@spectrum-css/steplist/stories/template.js"; import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; @@ -10,10 +12,11 @@ import { Template } from "./template.js"; /** * A dialog displays important information that users need to acknowledge. They appear over the interface and block further interactions. Standard dialogs are the most frequent type of dialogs. They appear in the center of the screen over the interface and should be used for moderately complex tasks. Takeover dialogs are large types of dialogs. They use the totality of the screen and should be used for modal experiences with complex workflows. * + * The alert variants that were previously a part of Dialog were moved to their own component, [alert dialog](/docs/components-alert-dialog--docs). + * * ## Usage with modal component * When a dialog component is used in tandem with a [modal](/docs/components-modal--docs), implementations should set `--mod-modal-background-color` to `transparent`. This will prevent any background color used in the modal from peeking through from behind the dialog at the rounded corners, allowing the dialog's background color to take precedence. * - * The alert variants that were previously a part of Dialog were moved to their own component, [alert dialog](/docs/components-alert-dialog--docs). */ export default { title: "Dialog", @@ -96,15 +99,6 @@ export default { control: "boolean", if: { arg: "layout", eq: "default" }, }, - hasDivider: { - name: "Divider", - type: { name: "boolean" }, - table: { - type: { summary: "boolean" }, - category: "Component", - }, - control: "boolean", - }, showModal: { name: "Wrap the dialog in a modal", type: { name: "boolean" }, @@ -167,6 +161,7 @@ export default { }, packageJson, metadata, + layout: "fullscreen", }, decorators: [ withUnderlayWrapper, @@ -267,16 +262,71 @@ WithScroll.parameters = { }; /** - * The full screen variant shows a large dialog background, only revealing a small portion of the page around the outside of the dialog, behind an overlay. The size of the dialog varies with the size of the screen, in both width and height. + * The fullscreen variant shows a large dialog background, only revealing a small portion of the page around the outside of the dialog, behind an overlay. The size of the dialog varies with the size of the screen, in both width and height. + * + * Fullscreen dialogs do not support a close button, and are not dismissible. + * + * Implementations may swap out the extra header content and body content for other components, like the [steplist](/docs/components-steplist--docs) and [table](/docs/components-table--docs) seen in this example. Components in the extra header content area will be centered. */ export const Fullscreen = DialogFullscreen.bind({}); Fullscreen.args = { ...Default.args, + header:[ + (passthroughs, context) => Steplist({ + ...passthroughs, + items: [ + { + label: "Enter records", + isComplete: true, + }, + { + label: "Confirmation", + isComplete: true, + }, + { + label: "Summary", + isSelected: true, + }, + ], + }, context), + ], + content: [ + (passthroughs, context) => Table({ + ...passthroughs, + showThumbnails: true, + rowItems: [ + { + cellContent: ["Table Row Alpha", "Test", "2"], + }, + { + cellContent: ["Table Row Bravo", "Test", "28"], + }, + { + cellContent: [ + "Table Row Charlie. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Test", + "23", + ], + }, + { + cellContent: ["Table Row Delta", "Test", "7"], + }, + { + cellContent: ["Summary Row", "", "60"], + isSummaryRow: true, + }, + ], + }, context), + ], layout: "fullscreen", hasFooter: false, }; Fullscreen.parameters = { chromatic: { disableSnapshot: true }, + design: { + type: "figma", + url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=61935-5399", + } }; // TODO: Because storybook doesn't support for multiple conditionals, we've removed the hasFooter @@ -286,15 +336,22 @@ Fullscreen.parameters = { // https://github.com/storybookjs/storybook/discussions/18542 Fullscreen.argTypes = { hasFooter: { table: { disable: true, } }, + header: { table: { disable: true, } }, }; /** - * The full screen takeover variant is similar to the full screen variant except that the background covers the entire screen. The page behind the dialog is not visible. This variant should be reserved for workflows where displaying a second dialog on top of the first one is to be expected. + * The fullscreen takeover variant is similar to the fullscreen variant except that the background covers the entire screen. The page behind the dialog is not visible. This variant should be reserved for workflows where displaying a second dialog on top of the first one is to be expected. + * + * Fullscreen takeover dialogs do not support a close button, and are not dismissible. */ export const FullscreenTakeover = DialogFullscreenTakeover.bind({}); FullscreenTakeover.storyName = "Fullscreen takeover"; FullscreenTakeover.parameters = { chromatic: { disableSnapshot: true }, + design: { + type: "figma", + url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=61935-5399", + } }; FullscreenTakeover.args = { ...Default.args, diff --git a/components/dialog/stories/dialog.test.js b/components/dialog/stories/dialog.test.js index f9b5acb6b2..a6b6b17711 100644 --- a/components/dialog/stories/dialog.test.js +++ b/components/dialog/stories/dialog.test.js @@ -42,41 +42,34 @@ export const DialogGroup = Variants({ }, { testHeading: "With hero/cover image", + hasHeroImage: true, heroImageUrl: "example-card-portrait.png", }, { testHeading: "With hero/cover image, dismissible", + hasHeroImage: true, heroImageUrl: "example-card-portrait.png", isDismissible: true, hasFooter: false, }, - { - testHeading: "No divider", - hasDivider: false, - }, - { - testHeading: "No divider, dismissible", - hasDivider: false, - isDismissible: true, - hasFooter: false, - }, - { - testHeading: "With hero/cover image, no divider", - hasDivider: false, - heroImageUrl: "example-card-portrait.png", - }, - { - testHeading: "With hero/cover image, no divider, dismissible", - hasDivider: false, - isDismissible: true, - hasFooter: false, - heroImageUrl: "example-card-portrait.png", - }, ], }); export const DialogFullscreen = Variants({ - Template, + Template: (args, context) => { + const { parameters: { showTestingGrid = false } = {} } = context; + + return Template({ + ...args, + /* + * Custom styles were added to make sure the VRTs catch the rounded corners + */ + customStyles: { + margin: showTestingGrid ? "16px" : undefined, + "background-color": showTestingGrid ? "var(--spectrum-gray-100)" : undefined, + }, + }, context); + }, withSizes: false, wrapperStyles: { "background-color": "var(--spectrum-gray-50)" diff --git a/components/dialog/stories/template.js b/components/dialog/stories/template.js index a9ab8ea61d..1f20f54109 100644 --- a/components/dialog/stories/template.js +++ b/components/dialog/stories/template.js @@ -2,8 +2,7 @@ import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/templ import { Template as Checkbox } from "@spectrum-css/checkbox/stories/template.js"; import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js"; import { Template as Modal } from "@spectrum-css/modal/stories/template.js"; -import { getRandomId } from "@spectrum-css/preview/decorators"; -import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; +import { getRandomId, renderContent } from "@spectrum-css/preview/decorators"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -19,7 +18,7 @@ export const Template = ({ showModal = false, hasFooter = false, heading, - header, + header = [], hasCheckbox = false, content = [], footer = [], @@ -66,18 +65,15 @@ export const Template = ({