Skip to content

Commit

Permalink
fix(web): Fix letter-spacing transformer (#25)
Browse files Browse the repository at this point in the history
Updates the letter-spacing transformer to use `rem` instead of `em`.

[category:Web Infrastructure]
  • Loading branch information
alanbsmith authored Sep 27, 2023
1 parent dc1fce0 commit 26bcaa7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/canvas-tokens/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ StyleDictionary.registerTransformGroup({
'value/hex-to-rgba',
'value/wrapped-font-family',
'value/math',
'value/spacing-em',
'value/spacing-rem',
'value/flatten-rgba',
],
});
Expand Down
6 changes: 3 additions & 3 deletions packages/canvas-tokens/utils/spec/transforms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ describe('transforms', () => {
expect(result).toBe(expected);
});

it('should add em to letter spacing values', () => {
const result = transforms['value/spacing-em'].transformer(
it('should convert letter spacing values from px to rem', () => {
const result = transforms['value/spacing-rem'].transformer(
{...defaultToken, value: '0.4'},
defaultOptions
);
const expected = '0.4em';
const expected = '0.025rem';

expect(result).toBe(expected);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/canvas-tokens/utils/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export const transforms: Record<string, Transform> = {
transformer: ({value}) => `"${value}"`,
},
// transform function that adds em to letter spacing values
'value/spacing-em': {
'value/spacing-rem': {
type: 'value',
transitive: true,
matcher: filter.isLetterSpacing,
transformer: ({value}) => `${value}em`,
transformer: ({value}) => `${value / 16}rem`,
},
// transform function that changes any border object value to its single line string
'value/flatten-border': {
Expand Down

0 comments on commit 26bcaa7

Please sign in to comment.