-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature] Add atomic font tokens #540
Conversation
…ng, size, and style), add font Figma output generation
…ing tokens by path
@@ -47,7 +91,7 @@ module.exports = { | |||
filter: 'filter/spacing/is-spacing', | |||
}, | |||
{ | |||
destination: 'types/theme.d.ts', | |||
destination: 'types/themes.d.ts', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to match JS file/export const naming.
Added @jessicawoodin to the PR to validate the modified tokens match her expectations and no values ended up out of sorts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions but overall looks good.
Lots of nice improvements to make the formats more generic. Wasn't aware of options
which makes reusing formats way easier. Great work.
packages/tokens/build.js
Outdated
@@ -43,6 +43,13 @@ const stripModeReducer = (result, token) => { | |||
return result | |||
} | |||
|
|||
/** Filter function to return tokens of category 'font', type from filter, and npm true */ | |||
const fontFilter = (token, fontType) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but suggest we follow the filterX
naming pattern and group with the other filters above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
packages/tokens/build.js
Outdated
|
||
/** Filter to tokens of category 'font', type 'letterSpacing', and npm true */ | ||
StyleDictionary.registerFilter({ | ||
name: 'filter/font/letterSpacing-npm', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest we stick to kebab case instead of mixing camel and kebab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Was naming it this way for the source file name, but looking at it holistically using the type name (kebab to follow the raw token name) probably makes more sense.
packages/tokens/build.js
Outdated
|
||
/** Filter to tokens of category 'font', type 'line-height', and npm true */ | ||
StyleDictionary.registerFilter({ | ||
name: 'filter/font/lineHeight-npm', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
packages/tokens/build.js
Outdated
if (dictionary.allTokens?.[0].attributes?.category === 'spacing') { | ||
const category = dictionary.allTokens?.[0].attributes?.category | ||
// Leave spacing and font tokens sorted by source (size) | ||
if (category === 'spacing' || category === 'font') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding a noSort
option here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, did Figma first and didn't figure out the options stuff until later. Updated.
Description of Change
Added 6 new sets of tokens forming the atomic basis for fonts:
Added new token attributes:
type
that refines category (e.g. typefamily
on categoryfont
)figma
that is set to true if the token should be part of figma exportnpm
that is set to true if the token should be part of the NPM/dist exportUpdated style-dictionary config/builds:
javascript/es6/simple-key-value
, used by colors/spacing + all new font tokenstypescript/es6-declarations/simple-key-value
, used by colors/spacing + all new font tokensjavascript/es6/fontIndex
, index within js/font foldertypescript/es6-declarations/fontIndex
, index within types/fontjson/dtcg
to handle new tokensjavascript/es6/vads-module-export
to be more easily modified in the future by looping through a list of filestypescript/es6-declarations/module
to be more easily modified in the future by looping through a list of filesFigma groupings were split to #495 in hopes of finding a more convenient way to handle them than opting to build the JSON stringwise like we do for other output files.
Testing Packages
Testing
Validated spacing/colors tokens still worked as expected. Validated new font tokens appear to work. Note: Bitter-Regular font family worked in web, but did not work in mobile as we don't have the font included yet (ticket #538).
One issue noted: when typing
font.
the global values documentation was not showing for the various token sets. It was unclear why this is the case since spacing does work and is typed as much the same it can be; additionally CMD + clicking into the set (e.g. font.family) and hovering over the typing there does show the global tooltip doc. Played with this for a bit and was unable to get it to work, but the tooltip doc values on the tokens themselves works fine so this was deemed acceptable since, if anyone is using these directly anyway vs typography tokens, they will almost certainly know which type of font tokens are needed in that line and once they havefont.family.
or similar the tooltip does have the doc of the token value.PR Checklist
Code reviewer validation:
changelog
label applied if it's to be included in the changelogPublish
If changes warrant a new version per the versioning guidelines and the PR is approved and ready to merge:
main
into branchmain