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

Support w3c working group design tokens spec #244

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 12 additions & 8 deletions docs/ui/src/js/createOutputParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function createJSOutput() {

let paramOutputString = `${joinedDeclarations}

let ${themeName.replace(/\s/g, '')} = new Leo.Theme({
let ${themeName.replace(/[^a-zA-Z0-9_$]/g, '_')} = new Leo.Theme({
colors: [${colorNames.map((n) => camelCase(n))}],
backgroundColor: ${camelCase(_theme.backgroundColor.name)},
lightness: ${_theme.lightness},
contrast: ${_theme.contrast},
saturation: ${_theme.saturation},
output: "${_theme.output}"
output: "${_theme.output}",
formula: "${_theme.formula}"
});`;

Expand Down Expand Up @@ -115,26 +115,30 @@ function createTokensOutput() {
let backgroundColor = _theme.contrastColors[0].background;

let backgroundColorObj = {
value: backgroundColor,
type: 'color',
description: `UI background color. All color contrasts evaluated and generated against this color.`
$value: backgroundColor,
$type: 'color',
$description: `UI background color. All color contrasts evaluated and generated against this color.`
};
themeObj['Background'] = backgroundColorObj;

let formulaString = _theme.formula === 'wcag2' ? 'WCAG 2.x (relative luminance)' : 'WCAG 3 (APCA)';
let largeText = _theme.formula === 'wcag3' ? 60 : 3;
let smallText = _theme.formula === 'wcag3' ? 75 : 4.5;

let formulaString = _theme.formula === 'wcag2' ? 'WCAG 2.x (relative luminance)' : 'WCAG 3 (APCA)';
let largeText = _theme.formula === 'wcag3' ? 60 : 3;
let smallText = _theme.formula === 'wcag3' ? 75 : 4.5;

for (let i = 1; i < contrastColors.length; i++) {
let thisColor = contrastColors[i];
for (let j = 0; j < thisColor.values.length; j++) {
let color = thisColor.values[j];
let descriptionText = color.contrast < largeText ? textLowContrast : color.contrast >= largeText && color.contrast < smallText ? textLarge : textSmall;

let colorObj = {
value: color.value,
type: 'color',
description: `${descriptionText} ${formulaString} contrast is ${color.contrast}:1 against background ${backgroundColor}`
$value: color.value,
$type: 'color',
$description: `${descriptionText} ${formulaString} contrast is ${color.contrast}:1 against background ${backgroundColor}`
};
themeObj[color.name] = colorObj;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/contrast-colors/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ function convertColorValue(color, format, object = false) {
if (letter === 'l' || letter === 'j') {
rnd += '%';
}
if (letter === 'h') {
rnd += 'deg';
}
}
} else if (space !== 'hsluv') {
if (letter === 's' || letter === 'l' || letter === 'v') {
Expand All @@ -363,8 +360,6 @@ function convertColorValue(color, format, object = false) {
rnd = round(ch * 100);
rnd += '%';
}
} else if (letter === 'h' && !object) {
rnd += 'deg';
}
}
return rnd;
Expand Down
Loading