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

test(loader): add component token E2E tests #9726

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
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
}

.number-button-item {
padding-block: 0px;
padding-block: 0;
padding-inline: 0.5rem /* 8px */;
}
}
Expand Down
113 changes: 112 additions & 1 deletion packages/calcite-components/src/components/loader/loader.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { newE2EPage } from "@stencil/core/testing";
import { hidden, renders } from "../../tests/commonTests";
import { hidden, renders, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";

describe("calcite-loader", () => {
describe("renders", () => {
Expand Down Expand Up @@ -55,4 +56,114 @@ describe("calcite-loader", () => {
expect(loader).toHaveAttribute("id");
expect(loader.getAttribute("id").length).toEqual(36);
});

describe("theme", () => {
describe("default", () => {
themed("calcite-loader", {
"--calcite-loader-color": {
targetProp: "stroke",
},
"--calcite-loader-size": [
{
targetProp: "minBlockSize",
},
{
shadowSelector: ".loader__svgs",
targetProp: "blockSize",
},
{
shadowSelector: ".loader__svgs",
targetProp: "inlineSize",
},
{
shadowSelector: ".loader__svg",
targetProp: "blockSize",
},
{
shadowSelector: ".loader__svg",
targetProp: "inlineSize",
},
],
});
});

describe("determinate", () => {
themed(html` <calcite-loader text="loading..." type="determinate" value="100"></calcite-loader>`, {
"--calcite-loader-color": {
shadowSelector: ".loader__percentage",
targetProp: "color",
},
"--calcite-loader-size": [
{
shadowSelector: ".loader__percentage",
targetProp: "inlineSize",
},
],
"--calcite-loader-text-color": [
{
shadowSelector: ".loader__percentage",
targetProp: "color",
},
{
shadowSelector: ".loader__text",
targetProp: "color",
},
],
"--calcite-loader-track-color": {
targetProp: "stroke",
},
});
});

describe("inline", () => {
themed(html`<calcite-loader inline></calcite-loader>`, {
"--calcite-loader-size": [
{
targetProp: "blockSize",
},
{
targetProp: "inlineSize",
},
],
});
});

describe("deprecated", () => {
describe("default", () => {
themed(`calcite-loader`, {
"--calcite-loader-font-size": {
targetProp: "fontSize",
},
"--calcite-loader-padding": {
targetProp: "paddingBlock",
},
});

describe("inline", () => {
themed(html`<calcite-loader inline></calcite-loader>`, {
"--calcite-loader-size-inline": [
{
targetProp: "blockSize",
},
{
targetProp: "minBlockSize",
},
{
targetProp: "inlineSize",
},
],
});
});

describe("determinate", () => {
themed(html`<calcite-loader type="determinate" value="10"></calcite-loader>`, {
"--calcite-loader-font-size": {
shadowSelector: ".loader__percentage",
targetProp: "fontSize",
},
});
});
});
});
});
});
14 changes: 7 additions & 7 deletions packages/calcite-components/src/components/loader/loader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-loader-color: defines the color of the component.
* @prop --calcite-loader-font-size: Specifies the font size of the loading percentage when type is `"determinate"`.
* @prop --calcite-loader-font-size: [Deprecated] Specifies the font size of the loading percentage when type is `"determinate"`.
* @prop --calcite-loader-padding: [Deprecated] Use --calcite-loader-space instead. Specifies the padding of the loader.
* @prop --calcite-loader-space: Specifies the padding of the loader.
* @prop --calcite-loader-size-inline: [Deprecated] Use --calcite-loader-size. The width and height of an inline loader.
* @prop --calcite-loader-size: The width and height of a loader.
* @prop --calcite-loader-size: [Deprecated] The width and height of a loader.
* @prop --calcite-loader-text-color: defines the text color of a loader.
* @prop --calcite-loader-track-color-determinate: defines the track color of a "determinate" loader
* @prop --calcite-loader-track-color: defines the track color of a "determinate" loader
*
*/
@import "../../assets/styles/animation";
Expand Down Expand Up @@ -41,17 +41,17 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159;

:host([scale="s"]) {
--calcite-internal-loader-font-size: theme("fontSize.n2");
--calcite-internal-loader-size: theme("spacing.8");
--calcite-internal-loader-size-fallback: theme("spacing.8");
}

:host([scale="m"]) {
--calcite-internal-loader-font-size: theme("fontSize.0");
--calcite-internal-loader-size: theme("spacing.16");
--calcite-internal-loader-size-fallback: theme("spacing.16");
}

:host([scale="l"]) {
--calcite-internal-loader-font-size: theme("fontSize.2");
--calcite-internal-loader-size: theme("spacing.24");
--calcite-internal-loader-size-fallback: theme("spacing.24");
}

:host([no-padding]) {
Expand Down Expand Up @@ -114,7 +114,7 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159;

:host([type="determinate"]) {
@apply animate-none;
stroke: var(--calcite-loader-track-color-determinate, var(--calcite-color-border-3));
stroke: var(--calcite-loader-track-color, var(--calcite-color-border-3));

.loader__svgs {
@apply animate-none;
Expand Down