Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion packages/calcite-components/src/components/swatch/swatch.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,20 @@ describe("calcite-swatch", () => {
describe("themed", () => {
describe("default", () => {
themed(html`calcite-swatch`, {
"--calcite-swatch-corner-radius": { shadowSelector: `.${CSS.container}`, targetProp: "borderRadius" },
"--calcite-swatch-corner-radius": [
{ shadowSelector: `.${CSS.container}`, targetProp: "borderRadius" },
{ shadowSelector: `#${IDS.swatchRect}`, targetProp: "rx" },
],
});
});
describe("solid ", () => {
themed(html`<calcite-swatch color="#ff8200"></calcite-swatch>`, {
"--calcite-swatch-corner-radius": [{ shadowSelector: `#${IDS.swatchSolid}`, targetProp: "rx" }],
});
});
describe("transparent ", () => {
themed(html`<calcite-swatch color="rgba(255, 255, 255, 0.5)"></calcite-swatch>`, {
"--calcite-swatch-corner-radius": [{ shadowSelector: `#${IDS.swatchTransparent}`, targetProp: "rx" }],
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
stroke: var(--calcite-color-text-1);
stroke-width: var(--calcite-border-width-md);
stroke-opacity: 0.3;
rx: var(--calcite-swatch-corner-radius);
}

.internal-svg-disabled {
Expand Down
10 changes: 10 additions & 0 deletions packages/calcite-components/src/custom-theme.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ import { meter, meterTokens } from "./custom-theme/meter";
import { table, tableTokens } from "./custom-theme/table";
import { carousel, carouselTokens } from "./custom-theme/carousel";
import { dialog, dialogTokens } from "./custom-theme/dialog";
import { swatchGroup, swatchGroupTokens } from "./custom-theme/swatch-group";
import { swatch, swatchTokens } from "./custom-theme/swatch";

const globalTokens = {
calciteColorBrand: "#007ac2",
Expand Down Expand Up @@ -245,6 +247,12 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
<div class="demo-row">
<div class="demo-column">${dialog}</div>
</div>
<div class="demo-row">
<div class="demo-column">${swatchGroup}</div>
</div>
<div class="demo-row">
<div class="demo-column">${swatch}</div>
</div>
</div>`;

const componentTokens = {
Expand Down Expand Up @@ -314,6 +322,8 @@ const componentTokens = {
...tableTokens,
...carouselTokens,
...dialogTokens,
...swatchGroupTokens,
...swatchTokens,
};

export default {
Expand Down
16 changes: 16 additions & 0 deletions packages/calcite-components/src/custom-theme/swatch-group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { html } from "../../support/formatting";

export const swatchGroupTokens = {
calciteSwatchGroupSpace: "",
};

export const swatchGroup = html`
<calcite-swatch-group label="demo-group-label" selection-mode="single-persist" id="single-persist-programmatic">
<calcite-swatch color="#aabbcc" label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch color="#ddeeff" selected label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch color="#112233" label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch color="#445566" label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch color="#425262" disabled label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch color="" label="example" value="calcite swatch"></calcite-swatch>
</calcite-swatch-group>
`;
7 changes: 7 additions & 0 deletions packages/calcite-components/src/custom-theme/swatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { html } from "../../support/formatting";

export const swatchTokens = {
calciteSwatchCornerRadius: "",
};

export const swatch = html` <calcite-swatch color="#aabbcc" label="example" value="calcite swatch"></calcite-swatch> `;
27 changes: 26 additions & 1 deletion packages/calcite-components/src/demos/swatch-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,32 @@ <h2>Swatch group selection mode examples</h2>
<calcite-swatch-group
label="demo-group-label"
selection-mode="multiple"
style="--calcite-swatch-corner-radius: 8px"
style="--calcite-swatch-corner-radius: 2px"
>
<calcite-swatch label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch label="example" color="#ff0000" value="calcite swatch"></calcite-swatch>
<calcite-swatch label="example" value="calcite swatch">
<img src="_assets/images/pattern-2.png" slot="image" />
</calcite-swatch>
<calcite-swatch label="example" color="rgba(250,210,150,0.2)" value="calcite swatch">
<img src="_assets/images/pattern-2.png" slot="image" />
</calcite-swatch>
<calcite-swatch label="example" value="calcite swatch">
<img src="_assets/images/hatch-3.png" slot="image" />
</calcite-swatch>
<calcite-swatch label="example" color="rgba(25,25,25,0.1)" value="calcite swatch"></calcite-swatch>
<calcite-swatch label="example" disabled color="#ddd" value="calcite swatch">
<img src="_assets/images/hatch-3.png" slot="image" />
</calcite-swatch>
<calcite-swatch label="example" disabled color="#ff00ee" value="calcite swatch"> </calcite-swatch>
</calcite-swatch-group>
</div>
<div class="parent">
<div class="child">Themed</div>
<calcite-swatch-group
label="demo-group-label"
selection-mode="multiple"
style="--calcite-swatch-corner-radius: 9999px"
>
<calcite-swatch label="example" value="calcite swatch"></calcite-swatch>
<calcite-swatch label="example" color="#ff0000" value="calcite swatch"></calcite-swatch>
Expand Down
Loading