diff --git a/packages/calcite-components/src/components/dialog/dialog.e2e.ts b/packages/calcite-components/src/components/dialog/dialog.e2e.ts index ff488db736e..a9642f22380 100644 --- a/packages/calcite-components/src/components/dialog/dialog.e2e.ts +++ b/packages/calcite-components/src/components/dialog/dialog.e2e.ts @@ -1180,7 +1180,26 @@ describe("calcite-dialog", () => { }); }); - describe("theme", () => { + describe("slotted", () => { + it("should not close when slotted panels are closed", async () => { + const page = await newE2EPage({ + html: html` + + `, + }); + await page.waitForChanges(); + + const closeButton = await page.find(`calcite-panel >>> #${PanelIDS.close}`); + + await closeButton.click(); + await page.waitForChanges(); + + const dialog = await page.find("calcite-dialog"); + expect(await dialog.getProperty("open")).toBe(true); + }); + }); + + describe("theme sizing", () => { themed( async () => { const page = await newE2EPage(); @@ -1193,10 +1212,6 @@ describe("calcite-dialog", () => { return { page, tag: "calcite-dialog" }; }, { - "--calcite-dialog-scrim-background-color": { - shadowSelector: `.${CSS.scrim}`, - targetProp: "--calcite-scrim-background-color", - }, "--calcite-dialog-size-x": { shadowSelector: `.${CSS.dialog}`, targetProp: "inlineSize", @@ -1221,14 +1236,6 @@ describe("calcite-dialog", () => { shadowSelector: `.${CSS.dialog}`, targetProp: "maxBlockSize", }, - "--calcite-dialog-content-space": { - shadowSelector: `.${CSS.panel}`, - targetProp: "--calcite-internal-dialog-content-padding", - }, - "--calcite-dialog-footer-space": { - shadowSelector: `.${CSS.panel}`, - targetProp: "--calcite-panel-footer-space", - }, "--calcite-dialog-offset-x": { shadowSelector: `.${CSS.dialog}`, targetProp: "insetInlineStart", @@ -1237,6 +1244,50 @@ describe("calcite-dialog", () => { shadowSelector: `.${CSS.dialog}`, targetProp: "insetBlockStart", }, + }, + ); + }); + + describe("theme appearance", () => { + themed( + async () => { + const page = await newE2EPage(); + await page.setContent( + html` + + + +
To continue, you must agree to the terms
+ + I agree to the terms + +

+ Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam + fringilla viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros. + Aenean sodales sollicitudin dui in fermentum. +

+ + Add members now +
`, + ); + // set large page to ensure test dialog isn't becoming fullscreen + await page.setViewport({ width: 1440, height: 1440 }); + await skipAnimations(page); + return { page, tag: "calcite-dialog" }; + }, + { + "--calcite-dialog-scrim-background-color": { + shadowSelector: `.${CSS.scrim}`, + targetProp: "--calcite-scrim-background-color", + }, + "--calcite-dialog-content-space": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-content-space", + }, + "--calcite-dialog-footer-space": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-footer-space", + }, "--calcite-dialog-background-color": { shadowSelector: `.${CSS.panel}`, targetProp: "--calcite-panel-background-color", @@ -1245,25 +1296,58 @@ describe("calcite-dialog", () => { shadowSelector: `.${CSS.panel}`, targetProp: "--calcite-panel-icon-color", }, + "--calcite-dialog-heading-text-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-heading-text-color", + }, + "--calcite-dialog-description-text-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-description-text-color", + }, + "--calcite-dialog-header-action-background-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-header-action-background-color", + }, + "--calcite-dialog-header-action-text-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-header-action-text-color", + }, + "--calcite-dialog-header-background-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-header-background-color", + }, + "--calcite-dialog-footer-background-color": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-footer-background-color", + }, + "--calcite-dialog-border-color": [ + { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-border-color", + }, + { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-border-color", + }, + { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-border-color", + }, + { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-border-color", + }, + ], + "--calcite-dialog-accent-color": { + shadowSelector: `.${CSS.dialog}`, + targetProp: "borderColor", + }, + "--calcite-dialog-space": { + shadowSelector: `.${CSS.panel}`, + targetProp: "--calcite-panel-space", + }, }, ); - - it("should not close when slotted panels are closed", async () => { - const page = await newE2EPage({ - html: html` - - `, - }); - await page.waitForChanges(); - - const closeButton = await page.find(`calcite-panel >>> #${PanelIDS.close}`); - - await closeButton.click(); - await page.waitForChanges(); - - const dialog = await page.find("calcite-dialog"); - expect(await dialog.getProperty("open")).toBe(true); - }); }); describe.each([{ modal: true }, { modal: false }])("focusTrap behavior", ({ modal }) => { diff --git a/packages/calcite-components/src/components/dialog/dialog.scss b/packages/calcite-components/src/components/dialog/dialog.scss index f94969afde3..48c0b32272a 100644 --- a/packages/calcite-components/src/components/dialog/dialog.scss +++ b/packages/calcite-components/src/components/dialog/dialog.scss @@ -17,8 +17,35 @@ * @prop --calcite-dialog-offset-y: Specifies the vertical offset of the component. * @prop --calcite-dialog-background-color: Specifies the background color of the component. * @prop --calcite-dialog-icon-color: Specifies the color of the component's icon. + * @prop --calcite-dialog-accent-color: Specifies the component's accent color when `kind` is specified. + * @prop --calcite-dialog-corner-radius: Specifies the component's corner radius. + * @prop --calcite-dialog-heading-text-color: Specifies the text color of the component's `heading`. + * @prop --calcite-dialog-description-text-color: Specifies the text color of the component's `description`. + * @prop --calcite-dialog-border-color: Specifies the component's border color. + * @prop --calcite-dialog-header-background-color: Specifies the background color of the component's header. + * @prop --calcite-dialog-header-action-background-color: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`. + * @prop --calcite-dialog-header-action-background-color-hover: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when hovered. + * @prop --calcite-dialog-header-action-background-color-press: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when pressed. + * @prop --calcite-dialog-header-action-text-color: Specifies the text color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`. + * @prop --calcite-dialog-header-action-text-color-press: Specifies the text color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when pressed or hovered. + * @prop --calcite-dialog-footer-background-color: Specifies the background color of the component's footer. + * @prop --calcite-dialog-space: Specifies the padding of the component's `"unnamed (default)"` slot. + * @prop --calcite-dialog-header-content-space: Specifies the padding of the `"header-content"` slot. + * @prop --calcite-dialog-footer-space: Specifies the padding of the component's footer. + * @prop --calcite-dialog-action-menu-border-color: Specifies the border color of the component's internally rendered `calcite-popover`, which is rendered within a `calcite-action` menu when slotted `calcite-action`s are present in the `header-actions-end` slot. Applies to any slotted `calcite-popover`s. */ +// AUTO-GENERATED — do not modify. Changes will be overwritten. +// +// Internal CSS custom properties for component use only. Overwriting is not recommended. +// +// --calcite-internal-dialog-animation-offset +// --calcite-internal-dialog-content-padding +// --calcite-internal-dialog-hidden-position +// --calcite-internal-dialog-min-size-x +// --calcite-internal-dialog-min-size-y +// --calcite-internal-dialog-shown-position + :host { // the dialog should always use a dark scrim, regardless of light / dark mode - matches value in global.scss --calcite-dialog-scrim-background-color: #{rgba($calcite-color-neutral-blk-240, $calcite-opacity-85)}; @@ -121,6 +148,19 @@ calcite-panel { --calcite-panel-border-color: var(--calcite-dialog-border-color); --calcite-panel-background-color: var(--calcite-dialog-background-color, var(--calcite-color-foreground-1)); --calcite-panel-icon-color: var(--calcite-dialog-icon-color); + --calcite-panel-heading-text-color: var(--calcite-dialog-heading-text-color); + --calcite-panel-description-text-color: var(--calcite-dialog-description-text-color); + --calcite-panel-header-background-color: var(--calcite-dialog-header-background-color); + --calcite-panel-header-action-background-color: var(--calcite-dialog-header-action-background-color); + --calcite-panel-header-action-background-color-hover: var(--calcite-dialog-header-action-background-color-hover); + --calcite-panel-header-action-background-color-press: var(--calcite-dialog-header-action-background-color-press); + --calcite-panel-header-action-text-color: var(--calcite-dialog-header-action-text-color); + --calcite-panel-header-action-text-color-press: var(--calcite-dialog-header-action-text-color-press); + --calcite-panel-footer-background-color: var(--calcite-dialog-footer-background-color); + --calcite-panel-space: var(--calcite-dialog-space, var(--calcite-internal-dialog-content-padding)); + --calcite-panel-header-content-space: var(--calcite-dialog-header-content-space, var(--calcite-dialog-content-space)); + --calcite-panel-footer-space: var(--calcite-dialog-footer-space); + --calcite-popover-border-color: var(--calcite-dialog-action-menu-border-color, var(--calcite-color-border-1)); } :host([kind="brand"]) calcite-panel { @@ -291,19 +331,19 @@ calcite-panel { } :host([kind="danger"]) .dialog { - @apply border-color-danger; + border-color: var(--calcite-dialog-accent-color, var(--calcite-color-status-danger)); } :host([kind="info"]) .dialog { - @apply border-color-info; + border-color: var(--calcite-dialog-accent-color, var(--calcite-color-status-info)); } :host([kind="success"]) .dialog { - @apply border-color-success; + border-color: var(--calcite-dialog-accent-color, var(--calcite-color-status-success)); } :host([kind="warning"]) .dialog { - @apply border-color-warning; + border-color: var(--calcite-dialog-accent-color, var(--calcite-color-status-warning)); } :host([kind="brand"][open]), diff --git a/packages/calcite-components/src/custom-theme.stories.ts b/packages/calcite-components/src/custom-theme.stories.ts index 2a7aaed0495..97cbc291167 100644 --- a/packages/calcite-components/src/custom-theme.stories.ts +++ b/packages/calcite-components/src/custom-theme.stories.ts @@ -88,6 +88,7 @@ import { shellPanel, shellPanelTokens } from "./custom-theme/shell-panel"; import { meter, meterTokens } from "./custom-theme/meter"; import { table, tableTokens } from "./custom-theme/table"; import { carousel, carouselTokens } from "./custom-theme/carousel"; +import { dialog, dialogTokens } from "./custom-theme/dialog"; const globalTokens = { calciteColorBrand: "#007ac2", @@ -223,6 +224,9 @@ const kitchenSink = (args: Record, useTestValues = false) =>
${carousel}
+
+
${dialog}
+
`; const componentTokens = { @@ -290,6 +294,7 @@ const componentTokens = { ...stepperTokens, ...tableTokens, ...carouselTokens, + ...dialogTokens, }; export default { diff --git a/packages/calcite-components/src/custom-theme/dialog.ts b/packages/calcite-components/src/custom-theme/dialog.ts new file mode 100644 index 00000000000..32df69ccb44 --- /dev/null +++ b/packages/calcite-components/src/custom-theme/dialog.ts @@ -0,0 +1,61 @@ +import { html } from "../../support/formatting"; + +export const dialogTokens = { + calciteDialogScrimBackgroundColor: "", + calciteDialogSizeX: "", + calciteDialogMinSizeX: "", + calciteDialogMaxSizeX: "", + calciteDialogSizeY: "", + calciteDialogMinSizeY: "", + calciteDialogMaxSizeY: "", + calciteDialogOffsetX: "", + calciteDialogOffsetY: "", + calciteDialogBackgroundColor: "", + calciteDialogIconColor: "", + calciteDialogAccentColor: "", + calciteDialogCornerRadius: "", + calciteDialogHeadingTextColor: "", + calciteDialogDescriptionTextColor: "", + calciteDialogBorderColor: "", + calciteDialogHeaderBackgroundColor: "", + calciteDialogHeaderActionBackgroundColor: "", + calciteDialogHeaderActionBackgroundColorHover: "", + calciteDialogHeaderActionBackgroundColorPress: "", + calciteDialogHeaderActionTextColor: "", + calciteDialogHeaderActionTextColorPress: "", + calciteDialogFooterBackgroundColor: "", + calciteDialogSpace: "", + calciteDialogHeaderContentSpace: "", + calciteDialogFooterSpace: "", + calciteDialogActionMenuBorderColor: "", +}; + +export const dialog = html` + + + + + +
To continue, you must agree to the terms
+ + I agree to the terms + +

+ Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam fringilla + viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros. Aenean sodales + sollicitudin dui in fermentum. +

+ + Add members now +
+
+`; diff --git a/packages/calcite-components/src/demos/dialog.html b/packages/calcite-components/src/demos/dialog.html index 4130f964503..7f3f9b1732f 100644 --- a/packages/calcite-components/src/demos/dialog.html +++ b/packages/calcite-components/src/demos/dialog.html @@ -42,6 +42,34 @@ margin: 25px 0; border-top: 1px solid var(--calcite-color-border-2); } + .themed-dialog { + --calcite-dialog-scrim-background-color: rgba(50, 20, 50, 0.4); + --calcite-dialog-background-color: orange; + --calcite-dialog-corner-radius: 12px; + --calcite-dialog-heading-text-color: darkgreen; + --calcite-dialog-description-text-color: lightgreen; + --calcite-dialog-border-color: blue; + --calcite-dialog-background-color: yellow; + --calcite-dialog-header-background-color: orange; + --calcite-dialog-footer-background-color: red; + --calcite-dialog-border-color: lime; + --calcite-dialog-space: 2rem; + --calcite-dialog-header-content-space: 0; + --calcite-dialog-footer-space: 0; + --calcite-dialog-content-space: 12px; + --calcite-dialog-footer-padding: 3rem; + --calcite-dialog-header-border-block-end: rgb(13, 242, 204); + --calcite-dialog-header-action-background-color: blue; + --calcite-dialog-header-action-background-color-hover: blue; + --calcite-dialog-header-action-background-color-press: blue; + --calcite-dialog-accent-color: pink; + } + + .themed-dialog calcite-action[slot="header-actions-end"] { + --calcite-action-background-color: red; + --calcite-action-background-color-hover: red; + --calcite-action-background-color-press: red; + } @@ -1690,7 +1718,64 @@

Dialog

+
+ +
+
+
+ + + + +
To continue, you must agree to the terms
+ + + I agree to the terms + +

+ Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam + fringilla viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros. + Aenean sodales sollicitudin dui in fermentum. Fusce egestas erat nec eros sodales ornare. Ut malesuada est + tortor, vitae semper turpis rutrum at. Donec suscipit, nulla in euismod luctus, nulla sapien interdum + tortor, a iaculis elit mi sed lectus. Morbi in congue metus, non imperdiet ex. Nunc et neque tempor, + porttitor est sed, vestibulum risus. Integer non erat libero. +

+

+ Cras sagittis vel neque sed efficitur. Vestibulum mattis diam eget urna condimentum tempus. Donec + malesuada velit sit amet metus faucibus pharetra. Sed sit amet massa facilisis, porttitor nunc vitae, + sollicitudin mauris. Nullam nec rhoncus augue. Praesent rhoncus varius sapien, sit amet porttitor nisl + varius eu. Pellentesque at eros eget metus dignissim lacinia. Sed sed justo eget sapien ultrices commodo. + Donec eget pretium urna. Vestibulum ut tortor ut quam viverra dictum. Morbi ut turpis velit. Phasellus + maximus lacus nunc, ac consequat est varius in. Nullam facilisis, purus ut aliquet condimentum, est tortor + accumsan justo, at sagittis urna dolor eget lacus. Interdum et malesuada fames ac ante ipsum primis in + faucibus. +

+

+ Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam + fringilla viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros. + Aenean sodales sollicitudin dui in fermentum. Fusce egestas erat nec eros sodales ornare. Ut malesuada est + tortor, vitae semper turpis rutrum at. Donec suscipit, nulla in euismod luctus, nulla sapien interdum + tortor, a iaculis elit mi sed lectus. Morbi in congue metus, non imperdiet ex. Nunc et neque tempor, + porttitor est sed, vestibulum risus. Integer non erat libero. +

+ Start with no members + Add members now +
+ + Themed +
+