Skip to content

Commit

Permalink
Merge branch 'main' into add-system-color-stories
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbsmith authored Apr 3, 2024
2 parents dec368d + ed9b451 commit ff67e89
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
14 changes: 14 additions & 0 deletions packages/canvas-tokens-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @workday/canvas-tokens-web

## 1.3.0

### Minor Changes

- **Infrastructure**

- chore: Add transform to handle opacity as percentage
([#100](https://github.com/Workday/canvas-tokens/pull/100))
([@RayRedGoose](https://github.com/RayRedGoose))

**Other**

- feat: Add missing system color tokens ([@alanbsmith](https://github.com/alanbsmith))

## 1.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-tokens-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@workday/canvas-tokens-web",
"version": "1.2.0",
"version": "1.3.0",
"description": "Canvas design tokens for web",
"author": "Workday, Inc. (https://www.workday.com)",
"license": "CC-BY-ND-4.0",
Expand Down
37 changes: 34 additions & 3 deletions packages/canvas-tokens/tokens/web/sys.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"type": "color",
"description": "Page background"
},
"softer": {
"value": "{palette.soap.100}",
"type": "color",
"description": "Disabled inputs and column headers"
},
"strong": {
"value": "{palette.soap.400}",
"type": "color",
Expand All @@ -45,12 +50,16 @@
}
},
"muted": {
"default": {
"value": "{palette.licorice.300}",
"softer": {
"value": "{palette.licorice.100}",
"type": "color"
},
"soft": {
"value": "{palette.licorice.100}",
"value": "{palette.licorice.200}",
"type": "color"
},
"default": {
"value": "{palette.licorice.300}",
"type": "color"
},
"strong": {
Expand Down Expand Up @@ -207,6 +216,11 @@
"value": "{palette.blueberry.500}",
"type": "color",
"description": "Branded hover text"
},
"stronger": {
"value": "{palette.blueberry.600}",
"type": "color",
"description": "Active links"
}
},
"caution": {
Expand Down Expand Up @@ -316,6 +330,11 @@
}
},
"muted": {
"soft": {
"value": "{palette.licorice.200}",
"type": "color",
"description": "Tab item text"
},
"default": {
"value": "{palette.licorice.300}",
"type": "color",
Expand Down Expand Up @@ -383,6 +402,11 @@
"value": "{palette.licorice.500}",
"type": "color",
"description": "Input hover"
},
"inverse": {
"value": "{palette.soap.300}",
"type": "color",
"description": "Borders on checkboxes and radios"
}
},
"contrast": {
Expand Down Expand Up @@ -500,6 +524,13 @@
"description": "Stronger blue"
}
},
"gold": {
"stronger": {
"value": "{palette.toasted-marshmallow.600}",
"type": "color",
"description": "Foregrounds in low emphasis status indicators"
}
},
"green": {
"default": {
"value": "{palette.green-apple.400}",
Expand Down
5 changes: 5 additions & 0 deletions packages/canvas-tokens/utils/filters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ export const isComposite: Matcher = ({type}) => {
export const isNotComposite: Matcher = token => {
return !isComposite(token);
};

export const isBaseOpacity: Matcher = token => {
const [level, category] = token.path;
return level === 'base' && category === 'opacity' && parseFloat(token.value) > 1;
};
10 changes: 10 additions & 0 deletions packages/canvas-tokens/utils/spec/transforms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,14 @@ describe('transforms', () => {

expect(result).toBe(expected);
});

it('should convert opacity to number below 1', () => {
const result = transforms['value/opacity'].transformer(
{...defaultToken, value: '40'},
defaultOptions
);
const expected = '0.4';

expect(result).toBe(expected);
});
});
6 changes: 6 additions & 0 deletions packages/canvas-tokens/utils/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export const transforms: Record<string, Transform> = {
matcher: filter.isSysColor,
transformer: flatRGBAColor,
},
'value/opacity': {
type: 'value',
transitive: true,
matcher: filter.isBaseOpacity,
transformer: ({value}) => `${value / 100}`,
},
// transform function that changes a value to its CSS var name
'value/variables': {
type: 'value',
Expand Down

0 comments on commit ff67e89

Please sign in to comment.