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

chore(cssTokenValues): provide default value map as a util #10828

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
32 changes: 16 additions & 16 deletions packages/calcite-components/src/tests/utils/cssTokenValues.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
export const tokenValueMap = {
background$: "rgb(252, 244, 52)",
"text-color$": "rgb(239, 118, 39)",
"shadow-color$": "0, 191, 255",
"border-color$": "rgb(156, 89, 209)",
"background-color$": "rgb(252, 244, 52)",
hover$: "rgb(255, 105, 180)",
pressed$: "rgb(44, 44, 44)",
selected$: "rgb(156, 89, 209)",
shadow$:
"rgb(255, 255, 255) 0px 0px 0px 4px, rgb(255, 105, 180) 0px 0px 0px 5px inset, rgb(0, 191, 255) 0px 0px 0px 9px",
"(z-index)$": "42",
"(columns|gap|height|offset|radius|size|size-y|size-x|space|space-x|space-y|width)": "42px",
color$: "rgb(0, 191, 255)",
} as const;

/**
* Sets the value of a CSS variable to a test value.
* This is useful for testing themed components.
Expand All @@ -6,22 +22,6 @@
* @returns string - the new value for the token
*/
export function getTokenValue(token: string): string {
const tokenValueMap = {
background$: "rgb(252, 244, 52)",
"text-color$": "rgb(239, 118, 39)",
"border-color$": "rgb(156, 89, 209)",
"background-color$": "rgb(252, 244, 52)",
color$: "rgb(0, 191, 255)",
hover$: "rgb(255, 105, 180)",
pressed$: "rgb(44, 44, 44)",
press$: "rgb(44, 44, 44)",
selected$: "rgb(156, 89, 209)",
shadow$:
"rgb(255, 255, 255) 0px 0px 0px 4px, rgb(255, 105, 180) 0px 0px 0px 5px inset, rgb(0, 191, 255) 0px 0px 0px 9px",
"(z-index)$": "42",
"(columns|gap|height|offset|radius|size|size-y|size-x|space|space-x|space-y|width|margin-bottom)": "42px",
} as const;

const match = Object.entries(tokenValueMap).find(([regexStr]) => {
return new RegExp(regexStr, "g").test(token);
});
Expand Down
Loading