Skip to content

Commit

Permalink
fix: support fontWeight attribute in fontSize token
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyeop committed Nov 7, 2024
1 parent f560a5b commit c6c55c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/font-size.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ describe(`font size`, () => {
tw = create({ theme: { fontSize: { xs: [`0.75rem`, { letterSpacing: `1px` }] } } });
expect(tw`text-xs`).toEqual({ fontSize: 12, letterSpacing: 1 });

tw = create({ theme: { fontSize: { xs: [`0.75rem`, { fontWeight: `700` }] } } });
expect(tw`text-xs`).toEqual({ fontSize: 12, fontWeight: 700 });

tw = create({
theme: {
fontSize: { xs: [`0.75rem`, { lineHeight: `0.5rem`, letterSpacing: `1px` }] },
Expand Down
6 changes: 5 additions & 1 deletion src/resolve/font-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function fontSize(
);
}

const { lineHeight, letterSpacing } = otherProps;
const { lineHeight, letterSpacing, fontWeight } = otherProps;
if (lineHeight) {
mergeStyle(`lineHeight`, calculateLineHeight(lineHeight, style), style);
}
Expand All @@ -59,6 +59,10 @@ export default function fontSize(
mergeStyle(`letterSpacing`, letterSpacing, style);
}

if (fontWeight) {
mergeStyle(`fontWeight`, fontWeight, style);
}

return complete(style);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tw-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PluginFunction } from './types';
type TwFontSize =
| string
| [string, string]
| [string, { lineHeight?: string; letterSpacing?: string }];
| [string, { lineHeight?: string; letterSpacing?: string; fontWeight?: string }];

type TwScreen = string | { max?: string; min?: string };

Expand Down

0 comments on commit c6c55c3

Please sign in to comment.