Skip to content

[Bug]: missed lowercasing of font style "alone" in font weight tokens #267

Description

@nhoizey

What happened?

When I generate Sass variables based on font weight tokens coming from Figma, I get for example this:

$font-weight-400: 400;
$font-weight-500: 500;
$font-weight-700: 700;
$font-weight-400-italic: Italic;
$font-weight-500-italic: 500 italic;
$font-weight-700-italic: 700 italic;

The two last variables have italic as lowercase, but $font-weight-400-italic has a capital in Italic.

I think it's because there is no actual weight number in front of this font style.

The regex here allows it: https://github.com/tokens-studio/sd-transforms/blob/main/src/transformFontWeights.ts#L35-L38

But the conversion of font style here is "inside" the one for the font weight value, so if there is no font weight value, the font style is not converted: https://github.com/tokens-studio/sd-transforms/blob/main/src/transformFontWeights.ts#L55-L57

I guess the if (match.groups.style) should be outside the if (match?.groups?.weight).

I can make a PR if this is the correct fix.

Reproduction

No response

Expected output

No response

Version

0.14.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions