-
Notifications
You must be signed in to change notification settings - Fork 29
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: rem based dimensions #80
feat: rem based dimensions #80
Conversation
|
Hmm I don't think relative units are a good default for our transforms. Sometimes you need That said, I absolutely agree that for many semantic tokens, given you know some of the context (because they are semantic), transforming to |
That makes sense. What about shipping more options within the package though? So instead of changing the defaults, make people pick their own by simply mixing & matching transformations that are ready to go like..
|
Yeah I think it makes sense, shipping a How do we easily pass the baseFontSize option btw? As far as I know, you can't easily pass options to transforms except for: import { transformRem } from '@tokens-studio/sd-transforms';
StyleDictionary.registerTransform({
name: 'ts/size/rem',
type: 'value',
matcher: token =>
['sizing', 'spacing', 'borderRadius', 'fontSizes', 'dimension'].includes(
token.type,
),
transformer: token => transformRem(token.value, 24), // <-- pass 24 as base font size
}); Maybe that's acceptable, I'm fine with it personally.. for now. I think we need a better way in the future though. More on that at the bottom of this comment, but not required to address in this PR. If this sounds good to you, let's adjust the PR to not register it by default and change the function signature to: export function transformRem(tokenValue: string | undefined | number, baseFontSize = 16): string | undefined {} to simplify things a bit, as baseFontSize is the only option, the only foreseeable one for this transform I would say. What we would still need to finish the PR then is to:
Not for this PR, but in the futureSee issue: #87 |
hey there!
using rem as a unit compared to using pixels will make the web a much better place for visually impaired users, as typography and dimensions scale based on the scaling the user defined in their browser settings.
To get some info on the topic I can suggest these sources:
Our current project has a strong focus on accessibility - and while we created our own transformation on it I think the default provided by sd-transforms should be based on rem as well.
I excluded borders from this transformation as this can lead browser specific render issues and generally they offer no benefit to accessibility as borders aren't really content related, so there's no need for them to scale.
Let me know if you are open to the change so I can update the tests accordingly.