Skip to content

Commit

Permalink
feat(tab-title): add icon start/end custom CSS prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfranco committed Nov 25, 2024
1 parent 1fb5af1 commit 4832009
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { newE2EPage, E2EPage, E2EElement } from "@arcgis/lumina-compiler/puppeteerTesting";
import { describe, expect, it, beforeEach } from "vitest";
import { disabled, HYDRATED_ATTR, renders, hidden } from "../../tests/commonTests";
import { disabled, HYDRATED_ATTR, renders, hidden, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { CSS } from "./resources";

Expand Down Expand Up @@ -344,4 +344,19 @@ describe("calcite-tab-title", () => {
await page.keyboard.press("Enter");
expect(activeEventSpy).toHaveReceivedEventTimes(2);
});

describe("theme", () => {
describe("start/end icons", () => {
themed(html` <calcite-tab-title icon-start="banana" icon-end="3d-glasses">close me</calcite-tab-title>`, {
"--calcite-tab-end-icon-color": {
shadowSelector: `.${CSS.iconEnd}`,
targetProp: "color",
},
"--calcite-tab-start-icon-color": {
shadowSelector: `.${CSS.iconStart}`,
targetProp: "color",
},
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* CSS Custom Properties
*
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-tab-end-icon-color: Specifies the component's `iconEnd` color. Fallback to `--calcite-icon-color`.
* @prop --calcite-tab-start-icon-color: Specifies the component's `iconStart` color. Fallback to `--calcite-icon-color`.
*/

:host {
@apply block outline-none;
margin-inline-start: theme("margin.0");
Expand Down Expand Up @@ -64,7 +73,7 @@
}

.container {
@apply relative
@apply relative
box-border
content-center
cursor-pointer
Expand Down Expand Up @@ -221,10 +230,12 @@

.content--has-text .calcite-tab-title--icon.icon-start {
margin-inline-end: var(--calcite-spacing-sm);
color: var(--calcite-tab-start-icon-color, var(--calcite-icon-color));
}

.content--has-text .calcite-tab-title--icon.icon-end {
margin-inline-start: var(--calcite-spacing-sm);
color: var(--calcite-tab-end-icon-color, var(--calcite-icon-color));
}

.close-button {
Expand Down
34 changes: 16 additions & 18 deletions packages/calcite-components/src/custom-theme.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { progress, progressTokens } from "./custom-theme/progress";
import { segmentedControl } from "./custom-theme/segmented-control";
import { slider, sliderTokens } from "./custom-theme/slider";
import { switchTokens } from "./custom-theme/switch";
import { tabs } from "./custom-theme/tabs";
import { tabs, tabsBordered, tabsTokens } from "./custom-theme/tabs";
import { textArea, textAreaTokens } from "./custom-theme/text-area";
import { tooltip, tooltipTokens } from "./custom-theme/tooltip";
import { avatarIcon, avatarInitials, avatarThumbnail, avatarTokens } from "./custom-theme/avatar";
Expand Down Expand Up @@ -125,46 +125,44 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
${chips} ${pagination} ${slider}
</div>
<div class="demo-column">
${datePicker} ${tabs} ${label} ${link} ${list} ${loader} ${calciteSwitch} ${avatarIcon} ${avatarInitials}
${avatarThumbnail} ${progress} ${handle} ${textArea} ${popover} ${tile} ${tooltip}
${datePicker} ${tabs} ${tabsBordered} ${label} ${link} ${list} ${loader} ${calciteSwitch} ${avatarIcon}
${avatarInitials} ${avatarThumbnail} ${progress} ${handle} ${textArea} ${popover} ${tile} ${tooltip}
</div>
<div class="demo-column">
${navigation} ${navigationLogos} ${navigationUsers}
</div>
${alert}
<div class="demo-column">${navigation} ${navigationLogos} ${navigationUsers}</div>
${alert}
</div>
</div>`;

const componentTokens = {
...globalTokens,
...accordionTokens,
...accordionItemTokens,
...actionTokens,
...accordionTokens,
...actionBarTokens,
...actionGroupTokens,
...actionMenuTokens,
...actionPadTokens,
...actionTokens,
...alertTokens,
...avatarTokens,
...cardTokens,
...alertTokens,
...chipTokens,
...checkboxTokens,
...chipTokens,
...handleTokens,
...inputTokens,
...labelTokens,
...linkTokens,
...listTokens,
...navigationLogoTokens,
...navigationTokens,
...navigationUserTokens,
...popoverTokens,
...progressTokens,
...inputTokens,
...sliderTokens,
...switchTokens,
...tabsTokens,
...textAreaTokens,
...navigationLogoTokens,
...navigationUserTokens,
...tooltipTokens,
...tileTokens,
...navigationTokens,
...sliderTokens,
...tooltipTokens,
};

export default {
Expand Down
119 changes: 111 additions & 8 deletions packages/calcite-components/src/custom-theme/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,113 @@
import { html } from "../../support/formatting";

export const tabs = html`<calcite-tabs>
<calcite-tab-nav slot="title-group">
<calcite-tab-title selected>Tab 1 Title</calcite-tab-title>
<calcite-tab-title>Tab 2 Title</calcite-tab-title>
<calcite-tab-title>Tab 3 Title</calcite-tab-title>
<calcite-tab-title>Tab 4 Title</calcite-tab-title>
</calcite-tab-nav>
</calcite-tabs>`;
export const tabsTokens = {
// additional tokens will be added in https://github.com/Esri/calcite-design-system/pull/10532/
calciteTabEndIconColor: "",
calciteTabStartIconColor: "",
};

export const tabs = html`
<style>
calcite-tabs {
width: 400px;
}
</style>
<calcite-tabs position="bottom">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right" selected
>Tab 1 Title
</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 2 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 3 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 4 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 5 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 6 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 7 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
<br />
<calcite-tabs position="top">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right" selected
>Tab 1 Title
</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 2 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 3 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 4 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 5 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 6 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 7 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
`;

export const tabsBordered = html`
<style>
calcite-tabs {
width: 400px;
}
</style>
<calcite-tabs bordered position="bottom">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right" selected
>Tab 1 Title
</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 2 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 3 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 4 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 5 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 6 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 7 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
<br />
<calcite-tabs position="top">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right" selected
>Tab 1 Title
</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 2 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 3 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 4 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 5 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 6 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 7 Title</calcite-tab-title>
<calcite-tab-title closable icon-start="arrow-left" icon-end="arrow-right">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
`;
108 changes: 108 additions & 0 deletions packages/calcite-components/src/demos/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,114 @@
</calcite-tabs>
</div>
</div>

<!-- additional tokens will be added in https://github.com/Esri/calcite-design-system/pull/10532/ -->
<demo-theme
tokens="
"
>
<style>
calcite-tabs {
width: 400px;
}
</style>

<div class="parent">
<div class="child right-aligned-text">Theme</div>

<div class="child">
<calcite-tabs position="bottom" style="--calcite-tab-end-icon-color: purple">
<calcite-tab-nav slot="title-group">
<calcite-tab-title icon-start="banana" icon-end="3d-glasses" selected>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 3 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 4 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 5 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 6 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 7 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>

<br />

<calcite-tabs position="top" style="--calcite-tab-end-icon-color: purple">
<calcite-tab-nav slot="title-group">
<calcite-tab-title icon-start="banana" icon-end="3d-glasses" selected>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 3 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 4 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 5 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 6 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 7 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
</div>

<div class="child">
<calcite-tabs bordered style="--calcite-tab-start-icon-color: red" position="bottom">
<calcite-tab-nav slot="title-group">
<calcite-tab-title icon-start="banana" icon-end="3d-glasses" selected>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 3 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 4 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 5 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 6 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 7 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>

<br />

<calcite-tabs bordered style="--calcite-tab-start-icon-color: red">
<calcite-tab-nav slot="title-group">
<calcite-tab-title icon-start="banana" icon-end="3d-glasses" selected>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 3 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 4 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 5 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 6 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 7 Title</calcite-tab-title>
<calcite-tab-title icon-start="banana" icon-end="3d-glasses">Tab 8 Title</calcite-tab-title>
</calcite-tab-nav>
<calcite-tab selected>Tab 1 Content</calcite-tab>
<calcite-tab>Tab 2 Content</calcite-tab>
<calcite-tab>Tab 3 Content</calcite-tab>
<calcite-tab>Tab 4 Content</calcite-tab>
<calcite-tab>Tab 5 Content</calcite-tab>
<calcite-tab>Tab 6 Content</calcite-tab>
<calcite-tab>Tab 7 Content</calcite-tab>
<calcite-tab>Tab 8 Content</calcite-tab>
</calcite-tabs>
</div>
</div>
</demo-theme>
</demo-dom-swapper>

<script>
Expand Down
3 changes: 3 additions & 0 deletions packages/calcite-components/src/tests/utils/cssTokenValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/
export function getTokenValue(token: string): string {
const tokenValueMap = {
// granular patterns for the same token must be listed first to match correctly
background$: "rgb(252, 244, 52)",
"text-color$": "rgb(239, 118, 39)",
"border-color$": "rgb(156, 89, 209)",
"background-color$": "rgb(252, 244, 52)",
"start-icon-color$": "rgb(213, 156, 74)",
"end-icon-color$": "rgb(98, 213, 180)",
color$: "rgb(0, 191, 255)",
hover$: "rgb(255, 105, 180)",
pressed$: "rgb(44, 44, 44)",
Expand Down

0 comments on commit 4832009

Please sign in to comment.