Skip to content

Commit

Permalink
tweaked transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz committed Jun 17, 2024
1 parent 231f324 commit e23ab66
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/cli/src/tokens/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as R from 'ramda';
import type { Transform } from 'style-dictionary/types';

import { noCase } from './utils/noCase';
import { getValue } from './utils/utils';
import { getValue, typeEquals } from './utils/utils';

const isPx = R.test(/\b\d+px\b/g);

export const sizeRem: Transform = {
name: 'ds/size/toRem',
type: 'value',
transitive: true,
filter: (token) => ['sizing', 'spacing', 'borderRadius'].includes(token.type as string),
filter: (token) => typeEquals(['sizing', 'spacing', 'borderRadius', 'fontsizes'], token),
transform: (token, config) => {
const value = getValue<string>(token);

Expand Down Expand Up @@ -51,12 +51,8 @@ export const typographyShorthand: Transform = {
type: 'value',
transitive: true,
filter: (token) => token.type === 'typography',
transform: (token, config) => {
transform: (token) => {
const typography = getValue<Typgraphy>(token);

const baseFontPx = (config.basePxFontSize as unknown as number) || 16;
const fontSize = `${parseInt(typography.fontSize) / baseFontPx}rem`;

return `${typography.fontWeight} ${fontSize}/${typography.lineHeight} '${typography.fontFamily}'`;
return `${typography.fontWeight} ${typography.fontSize}/${typography.lineHeight} '${typography.fontFamily}'`;
},
};

0 comments on commit e23ab66

Please sign in to comment.