From 45d65d987a338b24f11fb20c9eb864d767465620 Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Wed, 2 Oct 2024 14:46:55 -0700 Subject: [PATCH 01/30] feat(tile): add design tokens --- packages/calcite-components/.stylelintrc.cjs | 1 + .../calcite-components/src/components.d.ts | 4 + .../src/components/tile/tile.e2e.ts | 78 ++++++++++++- .../src/components/tile/tile.scss | 110 ++++++++++++------ 4 files changed, 155 insertions(+), 38 deletions(-) diff --git a/packages/calcite-components/.stylelintrc.cjs b/packages/calcite-components/.stylelintrc.cjs index 2e02214db54..f36f9230a75 100644 --- a/packages/calcite-components/.stylelintrc.cjs +++ b/packages/calcite-components/.stylelintrc.cjs @@ -6,6 +6,7 @@ const customFunctions = [ "medium-modular-scale", "modular-scale", "scale-duration", + "scaleDuration", "small-modular-scale" ]; // ⚠️ END OF AUTO-GENERATED CODE diff --git a/packages/calcite-components/src/components.d.ts b/packages/calcite-components/src/components.d.ts index 45c00f705de..7da8199359d 100644 --- a/packages/calcite-components/src/components.d.ts +++ b/packages/calcite-components/src/components.d.ts @@ -982,6 +982,7 @@ export namespace Components { "form": string; /** * The `id` attribute of the component. When omitted, a globally unique identifier is used. + * @deprecated No longer necessary. */ "guid": string; /** @@ -4199,6 +4200,7 @@ export namespace Components { "form": string; /** * The `id` of the component. When omitted, a globally unique identifier is used. + * @deprecated No longer necessary. */ "guid": string; /** @@ -8967,6 +8969,7 @@ declare namespace LocalJSX { "form"?: string; /** * The `id` attribute of the component. When omitted, a globally unique identifier is used. + * @deprecated No longer necessary. */ "guid"?: string; /** @@ -12368,6 +12371,7 @@ declare namespace LocalJSX { "form"?: string; /** * The `id` of the component. When omitted, a globally unique identifier is used. + * @deprecated No longer necessary. */ "guid"?: string; /** diff --git a/packages/calcite-components/src/components/tile/tile.e2e.ts b/packages/calcite-components/src/components/tile/tile.e2e.ts index 1f7580e132e..920d304cac5 100644 --- a/packages/calcite-components/src/components/tile/tile.e2e.ts +++ b/packages/calcite-components/src/components/tile/tile.e2e.ts @@ -1,8 +1,18 @@ import { newE2EPage } from "@stencil/core/testing"; -import { accessible, defaults, disabled, focusable, hidden, reflects, renders, slots } from "../../tests/commonTests"; +import { + accessible, + defaults, + disabled, + focusable, + hidden, + reflects, + renders, + slots, + themed, +} from "../../tests/commonTests"; import { html } from "../../../support/formatting"; import { isElementFocused } from "../../tests/utils"; -import { SLOTS } from "./resources"; +import { CSS, SLOTS } from "./resources"; describe("calcite-tile", () => { describe("accessibility", () => { @@ -211,4 +221,68 @@ describe("calcite-tile", () => { expect(description).toBeNull(); }); }); + + describe("theme", () => { + describe("default", () => { + themed( + html` + + + `, + { + "--calcite-tile-background-color": { + shadowSelector: `.${CSS.container}`, + targetProp: "backgroundColor", + }, + "--calcite-tile-border-color": { + shadowSelector: `.${CSS.container}`, + targetProp: "outlineColor", + }, + "--calcite-tile-description-text-color": { + shadowSelector: `.${CSS.description}`, + targetProp: "color", + }, + "--calcite-tile-heading-text-color": { + shadowSelector: `.${CSS.heading}`, + targetProp: "color", + }, + "--calcite-tile-icon-color": { + shadowSelector: "calcite-icon", + targetProp: "--calcite-icon-color", + }, + }, + ); + }); + describe("single selection", () => { + themed( + html` + + + `, + { + "--calcite-tile-selection-icon-color": { + shadowSelector: `calcite-icon.${CSS.selectionIcon}`, + targetProp: "--calcite-icon-color", + }, + "--calcite-tile-selection-icon-color-hover": { + shadowSelector: `calcite-icon.${CSS.selectionIcon}`, + targetProp: "--calcite-icon-color", + state: "hover", + }, + }, + ); + }); + }); }); diff --git a/packages/calcite-components/src/components/tile/tile.scss b/packages/calcite-components/src/components/tile/tile.scss index c9b1f43fedc..51d045ac8f7 100644 --- a/packages/calcite-components/src/components/tile/tile.scss +++ b/packages/calcite-components/src/components/tile/tile.scss @@ -7,42 +7,65 @@ * @prop --calcite-tile-border-color: Specifies the border color of the component. * @prop --calcite-tile-description-text-color: Specifies the description text color of the component. * @prop --calcite-tile-heading-text-color: Specifies the heading text color of the component. + * @prop --calcite-tile-icon-color: Specifies the icon color in the component. + * @prop --calcite-tile-selection-icon-color: Specifies the color of the selection icon in the component. + * @prop --calcite-tile-selection-icon-color-hover: Specifies the color of the selection icon in the component on hover. + * @prop --calcite-tile-shadow: Specifies the box-shadow of the component. */ +/** Internal variables + * --calcite-internal-tile-border-color + * --calcite-internal-tile-description-text-color + * --calcite-internal-tile-heading-text-color + * --calcite-internal-tile-icon-color + * --calcite-internal-tile-outline-color + * --calcite-internal-tile-selection-icon-color + * --calcite-internal-tile-shadow + */ + :host { - --calcite-tile-background-color: var(--calcite-color-foreground-1); - --calcite-tile-border-color: var(--calcite-color-border-2); - --calcite-tile-description-text-color: var(--calcite-color-text-3); - --calcite-tile-heading-text-color: var(--calcite-color-text-2); - --calcite-icon-color: var(--calcite-color-text-3); + --calcite-internal-tile-border-color: var(--calcite-tile-border-color, var(--calcite-color-border-2)); + --calcite-internal-tile-description-text-color: var( + --calcite-tile-description-text-color, + var(--calcite-color-text-3) + ); + --calcite-internal-tile-heading-text-color: var(--calcite-tile-heading-text-color, var(--calcite-color-text-2)); + --calcite-internal-tile-icon-color: var(--calcite-color-text-3); box-sizing: border-box; display: inline-block; } .container { - background-color: var(--calcite-tile-background-color); + --calcite-internal-tile-outline-color: var(--calcite-tile-border-color, var(--calcite-internal-tile-border-color)); + --calcite-internal-tile-select-icon-color: var(--calcite-tile-selection-icon-color, var(--calcite-color-text-3)); + + background-color: var(--calcite-tile-background-color, var(--calcite-color-foreground-1)); block-size: var(--calcite-container-size-content-fluid); box-sizing: border-box; inline-size: var(--calcite-container-size-content-fluid); - outline: var(--calcite-border-width-sm, 1px) solid var(--calcite-tile-border-color); + outline: var(--calcite-border-width-sm, 1px) solid var(--calcite-internal-tile-outline-color); user-select: none; + box-shadow: var(--calcite-tile-shadow, var(--calcite-internal-tile-shadow, none)); + &.interactive { cursor: pointer; + &:hover, &:focus, &.selected { - outline-color: var(--calcite-color-brand); + --calcite-internal-tile-outline-color: var(--calcite-tile-border-color, var(--calcite-color-brand)); + --calcite-internal-tile-select-icon-color: var( + --calcite-tile-selection-icon-color-hover, + var(--calcite-color-brand) + ); position: relative; - .selection-icon { - --calcite-icon-color: var(--calcite-color-brand); - } } &.selected { z-index: var(--calcite-z-index); } &:focus { - box-shadow: inset 0 0 0 1px var(--calcite-color-brand); + --calcite-internal-tile-shadow: inset 0 0 0 1px var(--calcite-color-brand); z-index: var(--calcite-z-index-sticky); } } @@ -70,7 +93,7 @@ } .heading { - color: var(--calcite-tile-heading-text-color); + color: var(--calcite-tile-heading-text-color, var(--calcite-internal-tile-heading-text-color)); font-weight: var(--calcite-font-weight-medium); line-height: 1.20313rem; overflow-wrap: break-word; @@ -94,25 +117,31 @@ } .description { - color: var(--calcite-tile-description-text-color); + color: var(--calcite-tile-description-text-color, var(--calcite-internal-tile-description-text-color)); font-weight: var(--calcite-font-weight-regular); overflow-wrap: break-word; } +calcite-icon { + --calcite-icon-color: var( + --calcite-tile-icon-color, + var(--calcite-internal-tile-icon-color, var(--calcite-color-text-3)) + ); + + &.selection-icon { + --calcite-icon-color: var(--calcite-internal-tile-select-icon-color); + } +} + :host([alignment="center"]) { .icon { align-self: center; } - .text-content-container { - justify-content: center; - } .text-content { text-align: center; } slot[name="content-start"]::slotted(*), - slot[name="content-end"]::slotted(*), - slot[name="content-top"]::slotted(*), - slot[name="content-bottom"]::slotted(*) { + slot[name="content-end"]::slotted(*) { align-self: center; } } @@ -189,6 +218,8 @@ :host([selection-appearance="border"][layout="horizontal"]), :host([selection-appearance="border"][layout="vertical"]) { .container.selected:focus::before { + --calcite-internal-tile-shadow: inset 0 0 0 1px var(--calcite-color-brand); + block-size: 100%; box-shadow: inset 0 0 0 1px var(--calcite-color-brand); content: ""; @@ -202,21 +233,28 @@ :host([selection-appearance="border"][layout="horizontal"]) { .container.selected { - box-shadow: inset 0 -4px 0 0 var(--calcite-color-brand); + --calcite-internal-tile-shadow: inset 0 -4px 0 0 var(--calcite-color-brand); } } :host([selection-appearance="border"][layout="vertical"]) { .container.selected { - box-shadow: inset 4px 0 0 0 var(--calcite-color-brand); + --calcite-internal-tile-shadow: inset 4px 0 0 0 var(--calcite-color-brand); + } +} + +:host([href]:active:not([disabled])) { + .container { + box-shadow: 0 0 0 3px var(--calcite-tile-border-color); } } :host([href]:focus:not([disabled])), :host([href]:hover:not([disabled])) { - --calcite-tile-border-color: var(--calcite-color-text-link); - --calcite-tile-heading-text-color: var(--calcite-color-text-link); - --calcite-icon-color: var(--calcite-color-text-link); + --calcite-internal-tile-border-color: var(--calcite-color-text-link); + --calcite-internal-tile-heading-text-color: var(--calcite-color-text-link); + --calcite-internal-tile-icon-color: var(--calcite-color-text-link); + --calcite-ui-icon-color: var(--calcite-color-text-link); .container { position: relative; z-index: var(--calcite-z-index); @@ -225,35 +263,35 @@ :host([href]:active:not([disabled])) { .container { - box-shadow: 0 0 0 3px var(--calcite-tile-border-color); + --calcite-internal-tile-shadow: 0 0 0 3px var(--calcite-tile-border-color); } } +:host(:hover:not([disabled])), +:host([active]:not([disabled])) { + --calcite-internal-tile-description-text-color: var(--calcite-color-text-2); + --calcite-internal-tile-heading-text-color: var(--calcite-color-text-1); +} + :host([embed]) { .container { - box-shadow: none; + --calcite-internal-tile-shadow: none; padding: 0; } } :host([selection-mode="none"]) { .container { - outline-color: var(--calcite-tile-border-color); + --calcite-internal-tile-outline-color: var(--calcite-internal-tile-border-color); + &:focus { - outline-color: var(--calcite-color-brand); + --calcite-internal-tile-outline-color: var(--calcite-color-brand); position: relative; } } } @include disabled(); - -:host(:hover:not([disabled])), -:host([active]:not([disabled])) { - --calcite-tile-description-text-color: var(--calcite-color-text-2); - --calcite-tile-heading-text-color: var(--calcite-color-text-1); -} - @include base-component(); ::slotted(*) { From c7c4f5e324629807de59df1c09d183478f3513c5 Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Wed, 2 Oct 2024 15:48:15 -0700 Subject: [PATCH 02/30] updating storybook and demo pages for theming examples --- .../src/custom-theme.stories.ts | 5 +- .../src/custom-theme/tile.ts | 21 ++ .../src/demos/tile-group.html | 265 ++++++++++++++++++ 3 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 packages/calcite-components/src/custom-theme/tile.ts diff --git a/packages/calcite-components/src/custom-theme.stories.ts b/packages/calcite-components/src/custom-theme.stories.ts index 79d3a34c968..d1d80f0435a 100644 --- a/packages/calcite-components/src/custom-theme.stories.ts +++ b/packages/calcite-components/src/custom-theme.stories.ts @@ -35,6 +35,7 @@ import { slider } from "./custom-theme/slider"; import { tabs } from "./custom-theme/tabs"; import { textArea, textAreaTokens } from "./custom-theme/text-area"; import { avatarIcon, avatarInitials, avatarThumbnail, avatarTokens } from "./custom-theme/avatar"; +import { tileTokens, tile } from "./custom-theme/tile"; const globalTokens = { calciteColorBrand: "#007ac2", @@ -115,7 +116,7 @@ const kitchenSink = (args: Record, useTestValues = false) =>
${checkbox}
${chips} ${pagination} ${slider} -
${datePicker} ${tabs} ${loader} ${calciteSwitch} ${avatarIcon} ${avatarInitials} ${avatarThumbnail} ${progress} ${handle} ${textArea} ${popover}
+
${datePicker} ${tabs} ${loader} ${calciteSwitch} ${avatarIcon} ${avatarInitials} ${avatarThumbnail} ${progress} ${handle} ${textArea} ${popover} ${tile}
${alert} @@ -142,6 +143,7 @@ export default { ...progressTokens, ...inputTokens, ...textAreaTokens, + ...tileTokens, }, }; @@ -169,6 +171,7 @@ export const theming = (): string => { ...progressTokens, ...inputTokens, ...textAreaTokens, + ...tileTokens, }, true, ); diff --git a/packages/calcite-components/src/custom-theme/tile.ts b/packages/calcite-components/src/custom-theme/tile.ts new file mode 100644 index 00000000000..fad697cb46d --- /dev/null +++ b/packages/calcite-components/src/custom-theme/tile.ts @@ -0,0 +1,21 @@ +import { html } from "../../support/formatting"; + +export const tileTokens = { + calciteTileBackgroundColor: "", + calciteTileBorderColor: "", + calciteTileDescriptionTextColor: "", + calciteTileHeadingTextColor: "", + calciteTileIconColor: "", + calciteTileSelectionIconColor: "", + calciteTileSelectionIconColorHover: "", + calciteTileShadow: "", +}; + +export const tile = html` + +`; diff --git a/packages/calcite-components/src/demos/tile-group.html b/packages/calcite-components/src/demos/tile-group.html index c139d6c1fe3..dc8818d7f22 100644 --- a/packages/calcite-components/src/demos/tile-group.html +++ b/packages/calcite-components/src/demos/tile-group.html @@ -1592,6 +1592,182 @@ + + + +
+
themed single
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + +
+
themed multiple
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+
+
@@ -2389,6 +2565,95 @@ + + + +
+
themed
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+