-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(styles): add tokens get function #3502
Conversation
|
d383a4f
to
5ccfb01
Compare
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.
Dang, I had so much fun. If we use one map, we loose the discoverability of all the tokens that belong to one component. What we could do instead is using a convention for the map name, so you'd only had to provide the name of the component without |
This will as well not work without any problem, because we have 3 different files where the map could come from (elements, components, utilities). |
@gfellerph as far as I know, Sass doesn’t allow retrieving variables using a dynamic name like $tokens: (
'h1': (
'post-h1-font-family': var(--post-sem-font-family-default),
),
);
map.get($tokens, h1, post-h1-font-family)
@oliverschuerch is it necessary to have 3 separate files? If so, we could also create 3 files for the token functions: |
@alizedebray and @gfellerph // here you could also load elements and/or utilities
@use '../tokens/components' as components;
@use '../functions/tokens' as tokens;
// set the default map to use or always use the third function parameter to specify a different map.
tokens.$default-map: components.$post-body;
/*
lets say you have the following keys in the map:
- 'post-html-something'
- 'post-body-font-family'
- 'post-body-font-size'
- 'post-body-margin'
then use it like so:
tokens.get($prefix, $key-name, $map)
while $prefix can be used with or without "post-"
*/
html {
something: tokens.get('html', 'something');
}
body {
font-family: tokens.get('post-body', 'font-family');
font-family: tokens.get('body', 'font-family');
font-family: tokens.get('body-font', 'family');
font-size: tokens.get('body-font', 'size');
font-family: tokens.get('body', 'font-family', $my-custom-map); // use a different map than the default one
} I've pushed this solution. Try it out if you like ;) |
This would be a possible solution, but as soon as we add another file (like 'elements', 'components' or 'utilities') we would need to add more functions. |
Sure, though this will probably not happen happen too often. |
96a2959
to
88c6ce0
Compare
88c6ce0
to
34568ba
Compare
…wDOM) implementation
Depends on #3506 |
Quality Gate passedIssues Measures |
No description provided.