Skip to content

feat(fab): add component tokens #11838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion packages/calcite-components/src/components/fab/fab.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
import { describe, expect, it } from "vitest";
import { accessible, defaults, disabled, hidden, renders } from "../../tests/commonTests";
import { accessible, defaults, disabled, hidden, renders, themed } from "../../tests/commonTests";
import { findAll } from "../../tests/utils";
import { html } from "../../../support/formatting";
import { CSS } from "./resources";

describe("calcite-fab", () => {
Expand Down Expand Up @@ -148,4 +149,40 @@ describe("calcite-fab", () => {
});
});
});

describe("theme", () => {
describe("default", () => {
themed(html`<calcite-fab></calcite-fab>`, {
"--calcite-fab-background-color": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.button} >>> button`,
},
"--calcite-fab-border-color": {
targetProp: "borderColor",
shadowSelector: `.${CSS.button} >>> button`,
},
"--calcite-fab-corner-radius": {
targetProp: "borderRadius",
shadowSelector: `.${CSS.button} >>> button`,
},
"--calcite-fab-text-color": {
targetProp: "color",
shadowSelector: `.${CSS.button} >>> button`,
},
"--calcite-fab-shadow": {
targetProp: "boxShadow",
shadowSelector: `.${CSS.button}`,
},
});
});

describe("loader", () => {
themed(html`<calcite-fab loading></calcite-fab>`, {
"--calcite-fab-loader-color": {
targetProp: "color",
shadowSelector: `.${CSS.button} >>> button >>> calcite-loader`,
},
});
});
});
});
27 changes: 25 additions & 2 deletions packages/calcite-components/src/components/fab/fab.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
/**
* CSS Custom Properties
*
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-fab-background-color: Specifies the component's background color.
* @prop --calcite-fab-border-color: Specifies the component's border color.
* @prop --calcite-fab-corner-radius: Specifies the component's corner radius.
* @prop --calcite-fab-text-color: Specifies the component's text color.
* @prop --calcite-fab-loader-color: Specifies the component's loader color.
* @prop --calcite-fab-shadow: Specifies the component's shadow.
*/

:host {
@apply flex bg-transparent;
@apply flex;

background-color: transparent;
}

@include disabled();

calcite-button {
@apply shadow-2;
--calcite-fab-shadow-internal: 0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);
box-shadow: var(--calcite-fab-shadow, var(--calcite-fab-shadow-internal));

&:hover {
@apply shadow-2-lg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: can the user customize the shadow when hovered/active using --calcite-fab-shadow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shadow for hover and active is going away and designers advised not to add tokens for these in the time being.

}
&:active {
@apply shadow-2-sm;
}

--calcite-button-background-color: var(--calcite-fab-background-color);
--calcite-button-border-color: var(--calcite-fab-border-color);
--calcite-button-corner-radius: var(--calcite-fab-corner-radius);
--calcite-button-text-color: var(--calcite-fab-text-color);
--calcite-button-loader-color: var(--calcite-fab-loader-color);
}

@include base-component();
6 changes: 6 additions & 0 deletions packages/calcite-components/src/custom-theme.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { chips, chipTokens } from "./custom-theme/chips";
import { comboboxItem, comboboxItemTokens, selectedComboboxItem } from "./custom-theme/combobox-item";
import { datePicker, datePickerRange, datePickerTokens } from "./custom-theme/date-picker";
import { dropdown, DropdownGroupTokens, DropdownItemTokens, DropdownTokens } from "./custom-theme/dropdown";
import { fab, fabLoading, fabTokens } from "./custom-theme/fab";
import { flow, flowTokens } from "./custom-theme/flow";
import { graph, graphTokens } from "./custom-theme/graph";
import { handle, handleTokens } from "./custom-theme/handle";
Expand Down Expand Up @@ -166,6 +167,10 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
<div class="demo-column">${datePicker}</div>
<div class="demo-column">${datePickerRange}</div>
</div>
<div class="demo-row">
<div class="demo-column">${fab}</div>
<div class="demo-column">${fabLoading}</div>
</div>
<div class="demo-row">
<div class="demo-column">${inputMessage}</div>
</div>
Expand Down Expand Up @@ -194,6 +199,7 @@ const componentTokens = {
...DropdownTokens,
...DropdownItemTokens,
...DropdownGroupTokens,
...fabTokens,
...flowTokens,
...handleTokens,
...inlineEditableTokens,
Expand Down
13 changes: 13 additions & 0 deletions packages/calcite-components/src/custom-theme/fab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { html } from "../../support/formatting";

export const fabTokens = {
calciteFabBackgroundColor: "",
calciteFabBorderColor: "",
calciteFabCornerRadius: "",
calciteFabTextColor: "",
calciteFabLoaderColor: "",
calciteFabShadow: "",
};

export const fab = html`<calcite-fab></calcite-fab>`;
export const fabLoading = html`<calcite-fab loading></calcite-fab>`;