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(progress): add component tokens #10267

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { accessible, hidden, renders } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { accessible, hidden, renders, themed } from "../../tests/commonTests";
import { CSS } from "./resources";

describe("calcite-progress", () => {
describe("renders", () => {
Expand All @@ -16,4 +18,21 @@ describe("calcite-progress", () => {
describe("accessible with value", () => {
accessible(`<calcite-progress value="50" type="indeterminate" text="percentage"></calcite-progress>`);
});

describe("theme", () => {
themed(html`<calcite-progress text="optional text" type="determinate" value="0.5"></calcite-progress>`, {
"--calcite-progress-background-color": {
shadowSelector: `.${CSS.track}`,
targetProp: "backgroundColor",
},
"--calcite-progress-fill-color": {
shadowSelector: `.${CSS.bar}`,
targetProp: "backgroundColor",
},
"--calcite-progress-text-color": {
shadowSelector: `.${CSS.text}`,
targetProp: "color",
},
});
});
});
18 changes: 15 additions & 3 deletions packages/calcite-components/src/components/progress/progress.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* CSS Custom Properties
*
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-progress-background-color: Defines the background color of the component.
* @prop --calcite-progress-fill-color: Defines the background color of the progress bar.
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
* @prop --calcite-progress-text-color: Defines the text color of the component.
*/

@import "../../assets/styles/animation";

:host {
Expand All @@ -12,11 +22,13 @@

.track {
@apply z-default w-full overflow-hidden;
background: theme("borderColor.color.3");
background-color: var(--calcite-progress-background-color, var(--calcite-color-border-3));
}

.bar {
@apply bg-brand z-default;
@apply z-default;

background-color: var(--calcite-progress-fill-color, var(--calcite-color-brand));
}

@media (forced-colors: active) {
Expand All @@ -42,7 +54,7 @@

.text {
@apply text-n2h px-0 pt-4 pb-0 text-center font-medium;
color: var(--calcite-color-text-2);
color: var(--calcite-progress-text-color, var(--calcite-color-text-2));
}

@keyframes looping-progress-bar-ani {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const CSS = {
track: "track",
bar: "bar",
text: "text",
};
7 changes: 6 additions & 1 deletion packages/calcite-components/src/custom-theme.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { icon } from "./custom-theme/icon";
import { loader } from "./custom-theme/loader";
import { notices } from "./custom-theme/notice";
import { pagination } from "./custom-theme/pagination";
import { progress, progressTokens } from "./custom-theme/progress";
import { segmentedControl } from "./custom-theme/segmented-control";
import { slider } from "./custom-theme/slider";
import { calciteSwitch } from "./custom-theme/switch";
Expand Down Expand Up @@ -104,7 +105,9 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
<div>${checkbox}</div>
${chips} ${pagination} ${slider}
</div>
<div class="demo-column">${datePicker} ${tabs} ${loader} ${calciteSwitch}</div>
<div class="demo-column">${datePicker} ${tabs} ${loader} ${calciteSwitch}
<div style="margin-top: 40px">${progress}</div>
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</div>`;
Expand All @@ -119,6 +122,7 @@ export default {
...actionPadTokens,
...actionGroupTokens,
...cardTokens,
...progressTokens,
},
};

Expand All @@ -135,6 +139,7 @@ export const theming_TestOnly = (): string => {
...actionPadTokens,
...actionGroupTokens,
...cardTokens,
...progressTokens,
},
true,
);
Expand Down
9 changes: 9 additions & 0 deletions packages/calcite-components/src/custom-theme/progress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { html } from "../../support/formatting";

export const progressTokens = {
calciteProgressBackgroundColor: "",
calciteProgressFillColor: "",
calciteProgressTextColor: "",
};

export const progress = html`<calcite-progress text="optional text" type="determinate" value="0.5"></calcite-progress>`;
Loading