Skip to content
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

feat(chip): add component tokens #10179

Merged
merged 20 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9507e9a
feat(chip): refactor chip for component tokens
alisonailea Aug 27, 2024
c6d5f1b
test(chip): add component tokens to stories
alisonailea Aug 28, 2024
a7ddcc2
fix(chip): remove mouse state tokens
alisonailea Aug 28, 2024
b226cb9
test(chip): update e2e tests
alisonailea Aug 28, 2024
b052c8d
feat(chip-group): add component tokens
alisonailea Aug 28, 2024
865757a
Merge branch 'dev' of github.com:Esri/calcite-design-system into ali-…
alisonailea Aug 28, 2024
3b0ac61
Revert "feat(chip-group): add component tokens"
alisonailea Aug 30, 2024
2332a09
fix(chip): chip element spacing
alisonailea Aug 31, 2024
5fe9b0c
fix(chip): internal variables in selection states
alisonailea Sep 2, 2024
819021c
fix(chip): minor issues with spacing
alisonailea Sep 6, 2024
798c7c4
fix(chip): add chip-icon-color token
alisonailea Sep 10, 2024
f9d0ec0
fix(chip): add select and close token options
alisonailea Sep 10, 2024
b6e6c97
test(chip): simplify theme tests
alisonailea Sep 11, 2024
d9cad9a
test(chip): fix theme setup
alisonailea Sep 11, 2024
be4ac0f
Revert package.json in test(chip): simplify theme tests”
alisonailea Sep 11, 2024
a709177
refactor(chip): restore —calcite-icon-color styles
alisonailea Sep 12, 2024
89fa877
Merge branch 'dev' of github.com:Esri/calcite-design-system into ali-…
alisonailea Sep 12, 2024
a8e74a8
Merge branch 'dev' into astump/7180-chip
alisonailea Sep 13, 2024
9ce58e7
Merge branch 'dev' into astump/7180-chip
alisonailea Sep 16, 2024
fa3f3e7
chore(custom-theme): fix imports
alisonailea Sep 16, 2024
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
37 changes: 37 additions & 0 deletions packages/calcite-components/src/assets/styles/includes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,40 @@
}
}
}

@mixin close-button($size: "var(--calcite-internal-close-size, 1.5rem /* 24px */)", $padding: "0") {
Copy link
Member

Choose a reason for hiding this comment

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

Sidebar: we'll need to consolidate this with the x-button mixin above. Related #6640.

.close {
@apply border-none
cursor-pointer
focus-base
items-center
m-0
rounded-half
transition-default;

background-color: var(--calcite-close-background-color, var(--calcite-color-transparent));
-webkit-appearance: none;
display: flex;
align-content: center;
justify-content: center;
color: var(--calcite-close-icon-color, var(--calcite-color-text-1));
block-size: #{$size};
inline-size: #{$size};
padding: #{$padding};

&:hover,
&:focus {
background-color: var(--calcite-close-background-color-hover, var(--calcite-color-transparent-hover));
}
&:focus {
@apply focus-inset;
}
&:active {
background-color: var(--calcite-close-background-color-press, var(--calcite-color-transparent-press));
}

calcite-icon {
color: inherit;
}
}
}
83 changes: 67 additions & 16 deletions packages/calcite-components/src/components/chip/chip.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { newE2EPage } from "@stencil/core/testing";
import { accessible, disabled, focusable, hidden, renders, slots, t9n } from "../../tests/commonTests";
import { accessible, disabled, focusable, hidden, renders, slots, t9n, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { CSS, SLOTS } from "./resources";

describe("calcite-chip", () => {
Expand Down Expand Up @@ -151,21 +152,6 @@ describe("calcite-chip", () => {
let chipCloseButtonFocusStyle;
let chipCloseButtonHoverStyle;

it("should have defined CSS custom properties", async () => {
page = await newE2EPage({ html: chipSnippet });
const chipStyles = await page.evaluate(() => {
const chip = document.querySelector("calcite-chip");
chip.style.setProperty("--calcite-chip-transparent-hover", "rgba(3, 2, 20, 0.14)");
chip.style.setProperty("--calcite-chip-transparent-press", "rgba(4, 10, 4, 0.31");
return {
hoverFocus: window.getComputedStyle(chip).getPropertyValue("--calcite-chip-transparent-hover"),
active: window.getComputedStyle(chip).getPropertyValue("--calcite-chip-transparent-press"),
};
});
expect(chipStyles.hoverFocus).toEqual("rgba(3, 2, 20, 0.14)");
expect(chipStyles.active).toEqual("rgba(4, 10, 4, 0.31");
});

describe("when mode attribute is not provided", () => {
it("should render chip pseudo classes with default values tied to mode", async () => {
page = await newE2EPage({ html: chipSnippet });
Expand Down Expand Up @@ -238,4 +224,69 @@ describe("calcite-chip", () => {
describe("translation support", () => {
t9n("calcite-chip");
});

describe("themed", () => {
describe("default", () => {
themed(html`calcite-chip`, {
"--calcite-chip-background-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "backgroundColor",
},
"--calcite-chip-text-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "color",
},
"--calcite-chip-corner-radius": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderRadius",
},
});
});

describe("appearance='outline'", () => {
themed(html`<calcite-chip appearance="outline">Layers</calcite-chip>`, {
"--calcite-chip-border-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderColor",
},
});
});

describe("closable", () => {
themed(html`<calcite-chip closable>Layers</calcite-chip>`, {
"--calcite-chip-close-icon-color": {
shadowSelector: `.${CSS.close}`,
targetProp: "color",
},
});
});

describe("selectable", () => {
describe("default", () => {
themed(html`<calcite-chip selection-mode="single">Layers</calcite-chip>`, {
"--calcite-chip-select-icon-color": {
shadowSelector: `.${CSS.selectIcon}`,
targetProp: "color",
},
});
});
describe("selected", () => {
themed(html`<calcite-chip selection-mode="single" selected>Layers</calcite-chip>`, {
"--calcite-chip-select-icon-color-pressed": {
shadowSelector: `.${CSS.selectIcon}`,
targetProp: "color",
},
});
});
});

describe("icon", () => {
themed(html`<calcite-chip icon="layer">Layers</calcite-chip>`, {
"--calcite-chip-icon-color": {
shadowSelector: `.${CSS.chipIcon}`,
targetProp: "color",
},
});
});
});
});
Loading
Loading