Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS - Add useFontWeightAsNumbers flag #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tchief
Copy link
Contributor

@tchief tchief commented Aug 19, 2024

Changes to existing exporters

  • CSS - Add useFontWeightAsNumbers flag

@tchief tchief marked this pull request as ready for review August 19, 2024 10:36
@tchief tchief requested a review from JiriTrecak August 19, 2024 10:36
Copy link

@honzatmn honzatmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't thin we should merge this before we resolve the issue with invalid values for font weight (which is the currently wrong behavior actually)

However, if we want to introduce the useFontWeightAsNumbers flag, it could be useful if the behavior will change to the one described in my other comment. But I see that more like a new feature of the exporter

allowReferences: exportConfiguration.useReferences,
decimals: exportConfiguration.colorPrecision,
colorFormat: exportConfiguration.colorFormat,
tokenToVariableRef: (t) => {
return `var(--${tokenVariableName(t, tokenGroups)})`
},
})

if (exportConfiguration.useFontWeightAsNumbers && token.tokenType === TokenType.fontWeight) {
let candidate = +(value?.replaceAll('"', ''))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, it should never return the value wrapped in quotes for font-weight, that's invalid CSS then. So the current behavior of this flag (when turned off) will lead to incorrect values

  • when i see useFontWeightAsNumbers flag, my expectations are that string values (such as bold, semibold, normal, etc) will be returned as 700, 600, 500 instead of the word. But it's not what this does

Here is a mapping table from OpenType specs:
CleanShot 2024-08-25 at 11 52 48@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants