feat: change data-size to work like Figma size mode#3866
Conversation
🦋 Changeset detectedLatest commit: ca6b261 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c4251ac to
84429bb
Compare
0101eea to
8a38225
Compare
8a38225 to
edcb56b
Compare
|
This looks really good. We'll have a deeper look at this once more people are back from vacation |
c9bd3a8 to
68b4e76
Compare
|
Could you add a changeset? |
68b4e76 to
a36c16c
Compare
… `--ds-size: <mode>`
|
Something funky is going on with the rounding here that causes md and lg to have same size? https://codepen.io/Oddbj-rn-vernes/pen/jEbdVPX?editors=1100 scroll down to line 70 here where it says Edit: i tested with the earlier version not-simplified by multiplying everything with Edit2: ok its not so funky but rather makes sense if you look at the numbers more closely |
…e` on parent actually scale these four components
I was a bit confused about what you meant at first @oddvernes , but you're totally right. In the "simplified" version, when rounding is supported, the resulting values for "md" and "lg" are the same! Also, the "sm" sizes increase less per size than before. So I'll have to revert this 🤔 |
|
Looking really good now! 👍 Interestingly |
Nice 🎉
Interesting! For instance this... ...rounds to 140px in Firefox, but 139px in Safari. I guess floating point gonna float 🤷♀️ |
|
This is looking good to me! I've tested a bit and can't find any glaring issues |
I went through the visual diff thoroughly now, and discovered that Chip is larger than before. This is the only unexpected diff, though. Looking into it now! |
@Barsnes <div data-size="sm">
<Chip.Radio>Label</Chip.Radio>
</div>...would result in a 24px height Chip, while this: <div>
<Chip.Radio data-size="sm">Label</Chip.Radio>
</div>...would result in a 28px height chip 🤯 The new Chip size behavior in this PR matches Chip sizes in Figma "Designsystemet - Core UI Kit" — sm = 28px, md = 32px, lg = 37px — so I'm concluding that this is a bugfix 🎉 |
well spotted, I have not gone through the visual tests yet. |
Co-authored-by: Tobias Barsnes <tobias.barsnes@digdir.no>

resolves #3547
Summary
Changes size and font-size variable generation to not use the local font size (em) but rather the
--ds-size-mode-font-sizevariable. This can be set usingdata-size="<mode>"attribute or--ds-size: var(--ds-size--<mode>)css, where<mode>issm,mdorlg.Read Sizes in code for info on how size modes work after these changes.
There are no breaking API changes, but potentially large spacing changes when size variables have been applied on
Headingelements (typically asmargin)Checks
pnpm changesetif relevant)