Skip to content

Commit

Permalink
fix: ts/color/css/hexrgba to apply to all color type tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Jul 8, 2023
1 parent 1243f97 commit 6a6a5d2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-walls-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': patch
---

ts/color/css/hexrgba to correctly apply on all color typed tokens, including those containing references.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/registerTransforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export async function registerTransforms(sd: Core, transformOpts?: TransformOpti
name: 'ts/color/css/hexrgba',
type: 'value',
transitive: true,
matcher: token => typeof token.value === 'string' && token.value.startsWith('rgba(#'),
matcher: token => typeof token.value === 'string' && token.type === 'color',
transformer: token => transformHEXRGBaForCSS(token.value),
});

Expand Down
3 changes: 3 additions & 0 deletions test/integration/sd-transforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('sd-transforms smoke tests', () => {

it('supports tokens-studio tokens', async () => {
const file = await promises.readFile(outputFilePath, 'utf-8');
console.log(file);
expect(file).to.include(`:root {
--sdDimensionScale: 2;
--sdDimensionXs: 4px;
Expand Down Expand Up @@ -76,6 +77,8 @@ describe('sd-transforms smoke tests', () => {
--sdShadow: inset 0 4px 10px 0 rgba(0,0,0,0.4);
--sdBorderWidth: 5px;
--sdBorder: 5px solid #000000;
--sdColor: #FF00FF;
--sdUsesColor: rgba(255, 0, 255, 1);
}`);
});
});
8 changes: 8 additions & 0 deletions test/integration/tokens/sd-transforms.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,13 @@
"color": "#000000"
},
"type": "border"
},
"color": {
"value": "#FF00FF",
"type": "color"
},
"usesColor": {
"value": "rgba( {color}, 1)",
"type": "color"
}
}

0 comments on commit 6a6a5d2

Please sign in to comment.