props overwrite user-provided props. If you don't wish to overwrite user-values, replace "=" here with "??=" */
@@ -150,7 +151,7 @@ export class DropdownGroup extends LitElement {
return (
{dropdownSeparator}
diff --git a/packages/calcite-components/src/components/dropdown-group/resources.ts b/packages/calcite-components/src/components/dropdown-group/resources.ts
new file mode 100644
index 00000000000..f758f3a2918
--- /dev/null
+++ b/packages/calcite-components/src/components/dropdown-group/resources.ts
@@ -0,0 +1,4 @@
+export const CSS = {
+ title: "dropdown-title",
+ separator: "dropdown-separator",
+};
diff --git a/packages/calcite-components/src/components/dropdown-item/dropdown-item.e2e.ts b/packages/calcite-components/src/components/dropdown-item/dropdown-item.e2e.ts
index 2e9ea86c24c..5969634a9d3 100644
--- a/packages/calcite-components/src/components/dropdown-item/dropdown-item.e2e.ts
+++ b/packages/calcite-components/src/components/dropdown-item/dropdown-item.e2e.ts
@@ -1,6 +1,8 @@
import { newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
import { describe, expect, it } from "vitest";
-import { focusable, renders, hidden, disabled } from "../../tests/commonTests";
+import { focusable, renders, hidden, disabled, themed } from "../../tests/commonTests";
+import { ComponentTestTokens } from "../../tests/commonTests/themed";
+import { CSS } from "./resources";
describe("calcite-dropdown-item", () => {
describe("renders", () => {
@@ -50,4 +52,95 @@ describe("calcite-dropdown-item", () => {
expect(itemChangeSpy).toHaveReceivedEventTimes(3);
});
+
+ describe("theme", () => {
+ describe("default", () => {
+ const tokens: ComponentTestTokens = {
+ "--calcite-dropdown-item-text-color": {
+ targetProp: "color",
+ shadowSelector: `.${CSS.container}`,
+ selector: `calcite-dropdown-item`,
+ },
+ "--calcite-dropdown-item-background-color-hover": {
+ targetProp: "backgroundColor",
+ shadowSelector: `.${CSS.container}`,
+ state: "hover",
+ selector: `calcite-dropdown-item`,
+ },
+ "--calcite-dropdown-item-background-color-press": {
+ targetProp: "backgroundColor",
+ shadowSelector: `.${CSS.container}`,
+ state: { press: `calcite-dropdown-item >>> .${CSS.container}` },
+ selector: `calcite-dropdown-item`,
+ },
+ "--calcite-dropdown-item-icon-color-hover": {
+ targetProp: "color",
+ shadowSelector: `.${CSS.icon}`,
+ state: "hover",
+ selector: "calcite-dropdown-item",
+ },
+ "--calcite-dropdown-item-text-color-press": [
+ {
+ targetProp: "color",
+ shadowSelector: `.${CSS.container}`,
+ selector: "calcite-dropdown-item",
+ state: "focus",
+ },
+ {
+ targetProp: "color",
+ shadowSelector: `.${CSS.container}`,
+ selector: "calcite-dropdown-item",
+ state: "hover",
+ },
+ {
+ targetProp: "color",
+ shadowSelector: `.${CSS.link}`,
+ selector: "calcite-dropdown-item",
+ state: "hover",
+ },
+ {
+ targetProp: "color",
+ shadowSelector: `.${CSS.container}`,
+ selector: "calcite-dropdown-item",
+ state: { press: `calcite-dropdown-item >>> .${CSS.container}` },
+ },
+ {
+ targetProp: "color",
+ shadowSelector: `.${CSS.link}`,
+ selector: "calcite-dropdown-item",
+ state: { press: `calcite-dropdown-item >>> .${CSS.container}` },
+ },
+ ],
+ };
+ themed(
+ `
+ 1
+ 2
+ `,
+ tokens,
+ );
+ });
+ describe("selected", () => {
+ const tokens: ComponentTestTokens = {
+ "--calcite-dropdown-item-icon-color-press": {
+ targetProp: "color",
+ shadowSelector: `calcite-icon`,
+ selector: `calcite-dropdown-item`,
+ },
+ "--calcite-dropdown-item-text-color-press": {
+ targetProp: "color",
+ shadowSelector: `.${CSS.container}`,
+ selector: `calcite-dropdown-item`,
+ },
+ };
+ themed(
+ `
+ 1
+ 2
+ 3
+ `,
+ tokens,
+ );
+ });
+ });
});
diff --git a/packages/calcite-components/src/components/dropdown-item/dropdown-item.scss b/packages/calcite-components/src/components/dropdown-item/dropdown-item.scss
index 084f6ebb548..6bfc30f142c 100644
--- a/packages/calcite-components/src/components/dropdown-item/dropdown-item.scss
+++ b/packages/calcite-components/src/components/dropdown-item/dropdown-item.scss
@@ -1,11 +1,25 @@
+/**
+ * CSS Custom Properties
+ *
+ * These properties can be overridden using the component's tag as selector.
+ *
+ * @prop --calcite-dropdown-item-background-color-hover: Specifies the background color of the dropdown item when hovered.
+ * @prop --calcite-dropdown-item-background-color-press: Specifies the background color of the dropdown item when selected or active.
+ * @prop --calcite-dropdown-item-icon-color-hover: Specifies the color of the dropdown item icon when hovered.
+ * @prop --calcite-dropdown-item-icon-color-press: Specifies the color of the dropdown item icons when selected or active.
+ * @prop --calcite-dropdown-item-text-color-press: Specifies the color of the dropdown item text when selected or active.
+ * @prop --calcite-dropdown-item-text-color: Specifies the color of the dropdown item text.
+*/
+
@mixin item-styling {
- @apply text-color-3
- relative
+ @apply relative
flex
flex-grow
cursor-pointer
items-center
no-underline;
+
+ color: var(--calcite-dropdown-item-text-color, var(--calcite-color-text-3));
}
:host {
@@ -88,39 +102,48 @@
:host(:focus) {
.container {
@apply focus-inset text-color-1 no-underline;
+ color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1));
+ }
+}
+
+:host(:hover:not([disabled])) {
+ .container {
+ background-color: var(--calcite-dropdown-item-background-color-hover, var(--calcite-color-foreground-2));
}
}
+:host(:active:not([disabled])) .container {
+ background-color: var(--calcite-dropdown-item-background-color-press, var(--calcite-color-foreground-3));
+}
+
:host(:hover:not([disabled])),
:host(:active:not([disabled])) {
.container {
- @apply bg-foreground-2 text-color-1 no-underline;
+ @apply no-underline;
+ color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1));
}
.dropdown-link {
- @apply text-color-1;
+ color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1));
}
}
-:host(:active:not([disabled])) .container {
- @apply bg-foreground-3;
-}
-
:host([selected]) .container:not(.container--none-selection),
:host([selected]) .dropdown-link {
- @apply text-color-1 font-medium;
- & calcite-icon {
- color: theme("backgroundColor.brand");
+ @apply font-medium;
+ color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1));
+
+ calcite-icon {
+ color: var(--calcite-dropdown-item-icon-color-press, var(--calcite-color-brand));
}
}
:host(:hover:not([disabled])) .dropdown-item-icon {
- color: theme("borderColor.color.1");
+ color: var(--calcite-dropdown-item-icon-color-hover, var(--calcite-color-border-1));
@apply opacity-100;
}
:host([selected]) .dropdown-item-icon {
- color: theme("backgroundColor.brand");
@apply opacity-100;
}
diff --git a/packages/calcite-components/src/components/dropdown/dropdown.e2e.ts b/packages/calcite-components/src/components/dropdown/dropdown.e2e.ts
index abd3d67cc07..ddcf8d5d258 100644
--- a/packages/calcite-components/src/components/dropdown/dropdown.e2e.ts
+++ b/packages/calcite-components/src/components/dropdown/dropdown.e2e.ts
@@ -22,6 +22,7 @@ import {
} from "../../tests/utils";
import type { DropdownItem } from "../dropdown-item/dropdown-item";
import type { Button } from "../button/button";
+import { ComponentTestTokens, themed } from "../../tests/commonTests/themed";
import { CSS } from "./resources";
describe("calcite-dropdown", () => {
@@ -1467,4 +1468,18 @@ describe("calcite-dropdown", () => {
expect(await isElementFocused(page, "#item-2")).toBe(true);
});
});
+
+ describe("theme", () => {
+ const tokens: ComponentTestTokens = {
+ "--calcite-dropdown-width": {
+ targetProp: "inlineSize",
+ shadowSelector: `.${CSS.content}`,
+ },
+ "--calcite-dropdown-background-color": {
+ targetProp: "backgroundColor",
+ shadowSelector: `.${CSS.content}`,
+ },
+ };
+ themed(``, tokens);
+ });
});
diff --git a/packages/calcite-components/src/components/dropdown/dropdown.scss b/packages/calcite-components/src/components/dropdown/dropdown.scss
index b5588f0b87d..7a2347dc0b0 100644
--- a/packages/calcite-components/src/components/dropdown/dropdown.scss
+++ b/packages/calcite-components/src/components/dropdown/dropdown.scss
@@ -4,6 +4,7 @@
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-dropdown-width: Specifies the width of the component's wrapper.
+* @prop --calcite-dropdown-background-color: Specifies the background color of the component.
*/
:host {
@@ -18,12 +19,12 @@
@include floating-ui-elem-anim(".calcite-dropdown-wrapper");
.calcite-dropdown-content {
- @apply bg-foreground-1
- w-auto
+ @apply w-auto
overflow-y-auto
overflow-x-hidden
max-h-menu;
- inline-size: var(--calcite-dropdown-width);
+ inline-size: var(--calcite-dropdown-width, var(--calcite-internal-dropdown-width));
+ background-color: var(--calcite-dropdown-background-color, var(--calcite-color-foreground-1));
}
.calcite-trigger-container {
@@ -32,21 +33,21 @@
}
.width-s {
- --calcite-dropdown-width: theme("spacing.48");
+ --calcite-internal-dropdown-width: theme("spacing.48");
}
.width-m {
- --calcite-dropdown-width: theme("spacing.56");
+ --calcite-internal-dropdown-width: theme("spacing.56");
}
.width-l {
- --calcite-dropdown-width: theme("spacing.64");
+ --calcite-internal-dropdown-width: theme("spacing.64");
}
@media (forced-colors: active) {
/* use real border since box-shadow is removed in high contrast mode */
:host([open]) .calcite-dropdown-wrapper {
- border: 1px solid canvasText;
+ border: var(--calcite-border-width-sm) solid canvasText;
}
}
diff --git a/packages/calcite-components/src/custom-theme.stories.ts b/packages/calcite-components/src/custom-theme.stories.ts
index fc6be4faae7..ba204147148 100644
--- a/packages/calcite-components/src/custom-theme.stories.ts
+++ b/packages/calcite-components/src/custom-theme.stories.ts
@@ -23,7 +23,7 @@ import { checkbox, checkboxTokens } from "./custom-theme/checkbox";
import { chips, chipTokens } from "./custom-theme/chips";
import { comboboxItem } from "./custom-theme/combobox-item";
import { datePicker, datePickerRange, datePickerTokens } from "./custom-theme/date-picker";
-import { dropdown } from "./custom-theme/dropdown";
+import { dropdown, DropdownGroupTokens, DropdownItemTokens, DropdownTokens } from "./custom-theme/dropdown";
import { flow, flowTokens } from "./custom-theme/flow";
import { graph, graphTokens } from "./custom-theme/graph";
import { handle, handleTokens } from "./custom-theme/handle";
@@ -175,6 +175,9 @@ const componentTokens = {
...checkboxTokens,
...chipTokens,
...datePickerTokens,
+ ...DropdownTokens,
+ ...DropdownItemTokens,
+ ...DropdownGroupTokens,
...flowTokens,
...handleTokens,
...inlineEditableTokens,
diff --git a/packages/calcite-components/src/custom-theme/dropdown.ts b/packages/calcite-components/src/custom-theme/dropdown.ts
index b1321acf630..774ad2fcbc6 100644
--- a/packages/calcite-components/src/custom-theme/dropdown.ts
+++ b/packages/calcite-components/src/custom-theme/dropdown.ts
@@ -1,10 +1,32 @@
import { html } from "../../support/formatting";
-export const dropdown = html`
+export const DropdownTokens = {
+ calciteDropdownWidth: "",
+ calciteDropdownBackgroundColor: "",
+};
+
+export const DropdownGroupTokens = {
+ calciteDropdownGroupBorderColor: "",
+ calciteDropdownGroupTitleTextColor: "",
+};
+
+export const DropdownItemTokens = {
+ calciteDropdownItemTextColor: "",
+ calciteDropdownItemBackgroundColorHover: "",
+ calciteDropdownItemBackgroundColorPress: "",
+ calciteDropdownItemIconColorHover: "",
+ calciteDropdownItemIconColorPress: "",
+ calciteDropdownItemTextColorPress: "",
+};
+
+export const dropdown = html`
Primary
List
Grid
Table
+
+ Home
+
`;