-
Notifications
You must be signed in to change notification settings - Fork 79
feat(alert): add component tokens #10218
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
Changes from 7 commits
1514217
403ca2d
6787eee
7d18aec
c52f2cb
2dbbeda
4db49bd
48a1243
0ee7704
4812669
1e873d2
3bfe325
7e20e2d
3cfbfc0
e375968
fe7f900
7b5c727
c272167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ import { E2EElement, E2EPage, newE2EPage } from "@stencil/core/testing"; | |
import { html } from "../../../support/formatting"; | ||
import { accessible, defaults, hidden, HYDRATED_ATTR, reflects, renders, t9n } from "../../tests/commonTests"; | ||
import { getElementXY, skipAnimations } from "../../tests/utils"; | ||
import { openClose } from "../../tests/commonTests"; | ||
import { CSS, DURATIONS } from "./resources"; | ||
import { openClose, themed } from "../../tests/commonTests"; | ||
import { CSS, DURATIONS, SLOTS } from "./resources"; | ||
import { alertQueueTimeoutMs } from "./AlertManager"; | ||
|
||
describe("defaults", () => { | ||
|
@@ -351,8 +351,8 @@ describe("calcite-alert", () => { | |
await page.setContent(alertSnippet); | ||
progressBarStyles = await page.evaluate(() => { | ||
const alert = document.querySelector("calcite-alert"); | ||
alert.style.setProperty("--calcite-alert-dismiss-progress-background", "white"); | ||
return window.getComputedStyle(alert).getPropertyValue("--calcite-alert-dismiss-progress-background"); | ||
alert.style.setProperty("--calcite-internal-alert-dismiss-progress-background", "white"); | ||
return window.getComputedStyle(alert).getPropertyValue("--calcite-internal-alert-dismiss-progress-background"); | ||
}); | ||
expect(progressBarStyles).toEqual("white"); | ||
}); | ||
|
@@ -594,4 +594,51 @@ describe("calcite-alert", () => { | |
describe("translation support", () => { | ||
t9n("calcite-alert"); | ||
}); | ||
|
||
describe("theme", () => { | ||
themed( | ||
html` | ||
<calcite-alert label="this is a default alert" scale="s"> | ||
<div slot="${SLOTS.title}">Test title</div> | ||
<div slot="${SLOTS.message}">Test message</div> | ||
</calcite-alert> | ||
`, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found out why the commented-out tokens were failing: diff --git i/packages/calcite-components/src/components/alert/alert.e2e.ts w/packages/calcite-components/src/components/alert/alert.e2e.ts
index b2ea33cbb..674b7ad02 100644
--- i/packages/calcite-components/src/components/alert/alert.e2e.ts
+++ w/packages/calcite-components/src/components/alert/alert.e2e.ts
@@ -605,39 +605,39 @@ describe("calcite-alert", () => {
`,
{
/*"--calcite-alert-width": {
- shadowSelector: `.${CSS.container}`,
- targetProp: "inlineSize",
- },*/
+ shadowSelector: `.${CSS.container}`, // 🕵 sizing styles depend on alert being open
+ targetProp: "inlineSize",
+ },*/
"--calcite-alert-background-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "backgroundColor",
},
/*"--calcite-alert-title-text-color": {
- shadowSelector: `.${CSS.textContainer}`,
+ shadowSelector: `.${CSS.textContainer}`, // 🕵️ text color is applied to the slotted content, this targets the slot parent
targetProp: "color",
},*/
/*"--calcite-alert-message-text-color": {
- shadowSelector: `.${CSS.textContainer}`,
- targetProp: "color",
- },*/
+ shadowSelector: `.${CSS.textContainer}`, // 🕵️ text color is applied to the slotted content, this targets the slot parent
+ targetProp: "color",
+ },*/
"--calcite-alert-corner-radius": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderRadius",
},
/*"--calcite-alert-close-background-color-hover": {
- shadowSelector: `.${CSS.close}`,
- targetProp: "backgroundColor",
- state: "hover",
- },*/
+ shadowSelector: `.${CSS.close}`,
+ targetProp: "backgroundColor",
+ state: "hover", // 🕵 stateful interactions depend on alert being open
+ },*/
/*"--calcite-alert-close-background-color-pressed": {
- shadowSelector: `.${CSS.close}`,
- targetProp: "backgroundColor",
- state: { press: { attribute: "class", value: CSS.close } },
- },*/
+ shadowSelector: `.${CSS.close}`,
+ targetProp: "backgroundColor",
+ state: { press: { attribute: "class", value: CSS.close } }, // 🕵 stateful interactions depend on alert being open
+ },*/
/*"--calcite-alert-dismiss-progress-background-color": {
- shadowSelector: `.${CSS.dismissProgress}`,
- targetProp: "backgroundColor",
- },*/
+ shadowSelector: `.${CSS.dismissProgress}`, // 🕵 the dismiss progress background color needs a different configuration (i.e., auto-close)
+ targetProp: "backgroundColor",
+ },*/
},
);
}); Some changes will require separate, different test HTML (see example). |
||
/*"--calcite-alert-width": { | ||
shadowSelector: `.${CSS.container}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you search for |
||
targetProp: "inlineSize", | ||
},*/ | ||
"--calcite-alert-background-color": { | ||
shadowSelector: `.${CSS.container}`, | ||
targetProp: "backgroundColor", | ||
}, | ||
/*"--calcite-alert-title-text-color": { | ||
shadowSelector: `.${CSS.textContainer}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your selector should target the slot="title" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated this test but it's still throwing an error.
|
||
targetProp: "color", | ||
},*/ | ||
/*"--calcite-alert-message-text-color": { | ||
shadowSelector: `.${CSS.textContainer}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as title this should target |
||
targetProp: "color", | ||
},*/ | ||
"--calcite-alert-corner-radius": { | ||
shadowSelector: `.${CSS.container}`, | ||
targetProp: "borderRadius", | ||
}, | ||
/*"--calcite-alert-close-background-color-hover": { | ||
shadowSelector: `.${CSS.close}`, | ||
targetProp: "backgroundColor", | ||
state: "hover", | ||
},*/ | ||
/*"--calcite-alert-close-background-color-pressed": { | ||
shadowSelector: `.${CSS.close}`, | ||
targetProp: "backgroundColor", | ||
state: { press: { attribute: "class", value: CSS.close } }, | ||
},*/ | ||
/*"--calcite-alert-dismiss-progress-background-color": { | ||
shadowSelector: `.${CSS.dismissProgress}`, | ||
targetProp: "backgroundColor", | ||
},*/ | ||
}, | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break this into a "default" alert test followed by additional tests to cover tokens only effected by certain props. I.E. Slotted content styles