Skip to content

Commit e1a8444

Browse files
authored
feat(fab): add component tokens (#11838)
**Related Issue:** #7180 Adds the following tokens for `fab` component. `--calcite-fab-background-color`: Specifies the component's background color. `--calcite-fab-border-color`: Specifies the component's border color. `--calcite-fab-corner-radius`: Specifies the component's corner radius. `--calcite-fab-text-color`: Specifies the component's text color. `--calcite-fab-loader-color`: Specifies the component's loader color. `--calcite-fab-shadow`: Specifies the component's shadow.
1 parent df4d6b0 commit e1a8444

File tree

4 files changed

+82
-3
lines changed

4 files changed

+82
-3
lines changed

Diff for: packages/calcite-components/src/components/fab/fab.e2e.ts

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
22
import { describe, expect, it } from "vitest";
3-
import { accessible, defaults, disabled, hidden, renders } from "../../tests/commonTests";
3+
import { accessible, defaults, disabled, hidden, renders, themed } from "../../tests/commonTests";
44
import { findAll } from "../../tests/utils";
5+
import { html } from "../../../support/formatting";
56
import { CSS } from "./resources";
67

78
describe("calcite-fab", () => {
@@ -148,4 +149,40 @@ describe("calcite-fab", () => {
148149
});
149150
});
150151
});
152+
153+
describe("theme", () => {
154+
describe("default", () => {
155+
themed(html`<calcite-fab></calcite-fab>`, {
156+
"--calcite-fab-background-color": {
157+
targetProp: "--calcite-button-background-color",
158+
shadowSelector: `.${CSS.button}`,
159+
},
160+
"--calcite-fab-border-color": {
161+
targetProp: "--calcite-button-border-color",
162+
shadowSelector: `.${CSS.button}`,
163+
},
164+
"--calcite-fab-corner-radius": {
165+
targetProp: "--calcite-button-corner-radius",
166+
shadowSelector: `.${CSS.button}`,
167+
},
168+
"--calcite-fab-text-color": {
169+
targetProp: "--calcite-button-text-color",
170+
shadowSelector: `.${CSS.button}`,
171+
},
172+
"--calcite-fab-shadow": {
173+
targetProp: "boxShadow",
174+
shadowSelector: `.${CSS.button}`,
175+
},
176+
});
177+
});
178+
179+
describe("loader", () => {
180+
themed(html`<calcite-fab loading></calcite-fab>`, {
181+
"--calcite-fab-loader-color": {
182+
targetProp: "--calcite-button-loader-color",
183+
shadowSelector: `.${CSS.button}`,
184+
},
185+
});
186+
});
187+
});
151188
});
+25-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
1+
/**
2+
* CSS Custom Properties
3+
*
4+
* These properties can be overridden using the component's tag as selector.
5+
*
6+
* @prop --calcite-fab-background-color: Specifies the component's background color.
7+
* @prop --calcite-fab-border-color: Specifies the component's border color.
8+
* @prop --calcite-fab-corner-radius: Specifies the component's corner radius.
9+
* @prop --calcite-fab-text-color: Specifies the component's text color.
10+
* @prop --calcite-fab-loader-color: Specifies the component's loader color.
11+
* @prop --calcite-fab-shadow: Specifies the component's shadow.
12+
*/
13+
114
:host {
2-
@apply flex bg-transparent;
15+
@apply flex;
16+
17+
background-color: transparent;
318
}
419

520
@include disabled();
621

722
calcite-button {
8-
@apply shadow-2;
23+
--calcite-fab-shadow-internal: 0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);
24+
box-shadow: var(--calcite-fab-shadow, var(--calcite-fab-shadow-internal));
25+
926
&:hover {
1027
@apply shadow-2-lg;
1128
}
1229
&:active {
1330
@apply shadow-2-sm;
1431
}
32+
33+
--calcite-button-background-color: var(--calcite-fab-background-color);
34+
--calcite-button-border-color: var(--calcite-fab-border-color);
35+
--calcite-button-corner-radius: var(--calcite-fab-corner-radius);
36+
--calcite-button-text-color: var(--calcite-fab-text-color);
37+
--calcite-button-loader-color: var(--calcite-fab-loader-color);
1538
}
1639

1740
@include base-component();

Diff for: packages/calcite-components/src/custom-theme.stories.ts

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { chips, chipTokens } from "./custom-theme/chips";
2424
import { comboboxItem, comboboxItemTokens, selectedComboboxItem } from "./custom-theme/combobox-item";
2525
import { datePicker, datePickerRange, datePickerTokens } from "./custom-theme/date-picker";
2626
import { dropdown, DropdownGroupTokens, DropdownItemTokens, DropdownTokens } from "./custom-theme/dropdown";
27+
import { fab, fabLoading, fabTokens } from "./custom-theme/fab";
2728
import { flow, flowTokens } from "./custom-theme/flow";
2829
import { graph, graphTokens } from "./custom-theme/graph";
2930
import { handle, handleTokens } from "./custom-theme/handle";
@@ -167,6 +168,10 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
167168
<div class="demo-column">${datePicker}</div>
168169
<div class="demo-column">${datePickerRange}</div>
169170
</div>
171+
<div class="demo-row">
172+
<div class="demo-column">${fab}</div>
173+
<div class="demo-column">${fabLoading}</div>
174+
</div>
170175
<div class="demo-row">
171176
<div class="demo-column">${inputMessage}</div>
172177
</div>
@@ -195,6 +200,7 @@ const componentTokens = {
195200
...DropdownTokens,
196201
...DropdownItemTokens,
197202
...DropdownGroupTokens,
203+
...fabTokens,
198204
...flowTokens,
199205
...handleTokens,
200206
...inlineEditableTokens,

Diff for: packages/calcite-components/src/custom-theme/fab.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { html } from "../../support/formatting";
2+
3+
export const fabTokens = {
4+
calciteFabBackgroundColor: "",
5+
calciteFabBorderColor: "",
6+
calciteFabCornerRadius: "",
7+
calciteFabTextColor: "",
8+
calciteFabLoaderColor: "",
9+
calciteFabShadow: "",
10+
};
11+
12+
export const fab = html`<calcite-fab></calcite-fab>`;
13+
export const fabLoading = html`<calcite-fab loading></calcite-fab>`;

0 commit comments

Comments
 (0)