How should we vary font size with source and media queries? #1072
Replies: 4 comments
-
worth remembering they'll be tokenised and so gzipped away over the wire. and i'm pretty sure the setting an identical rule will not invalidate the existing one, so it shouldn't trigger a new paint (although the things that do change obviously will anyway) |
Beta Was this translation helpful? Give feedback.
-
The corresponding line heights are defined in the underlying design tokens so it's something we could expose which would allow you to do this: ${textSans.xsmall()}
${from.tablet} {
font-size: ${textSansSizes.xxxlarge}
line-height: ${textSansLineHeights.xxxlarge}
} I quite like the idea of Source components supporting media queries though. I've run into similar issues where I've needed one of the layout components to have different spacing at different viewport widths. That's a change that would require a lot more thought though. |
Beta Was this translation helpful? Give feedback.
-
I'd love to know how designers (and especially @guardian/design-system) think about this problem. Is it common enough, and does it materialise with enough consistency, that an abstraction for it ought to be reflected in the design system? Are font size and viewport width values always dependant on the specific circumstance in which they are being used, or do they follow established rules e.g. body text is always 16px at desktop, 14px at mobile?
This is something we started to explore with the Column component, albeit with varying columns widths at different viewport widths. I'm not sure how configurable you'd want to make these layout primitives though, you might want to create a higher order component that controls spacing at varying viewport widths for the specific use case? |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
Use-case
We would like to change the font size dependant on media queries. Pretty simple. We have come across two ways of doing this, both with drawbacks. I'll try outline those below.
1. Use static values to override
font-size
propertyExamples:
support-frontend
dotcom-rendering
Drawbacks:
font-size
&line-height
out of whack with Source2. Re-apply the whole font CSS block
Drawbacks:
font-family
e.g.Thoughts on the above solutions
While Option 2. creates excess bytes, it feels the most sustainable in regards to keeping a consistent UX for our readers.
Option 1. Adds maintenance overhead and potential design debt whenever it is used.
Which should we use?
Thinking forward
If the decision above is that both are substandard, there are some other options we could explore.
Use explicit values from source
Drawbacks:
line-height
corresponds with whichfont-size
for that specific font.Exclude properties
Partial function
Drawbacks:
Allow source to take charge of media queries?
We could include media queries, ensuring that all of our designs scale the same way. You could make this backwards compatible by making it opt-in e.g.
Drawbacks:
Benefits:
*Hard doesn't mean bad or we shouldn't try it
An all new API?
Drawbacks:
Benefits:
There's a few other solutions I could think of - but maybe some guiding principles could be more useful:
color-no-hex
indotcom-rendering
Beta Was this translation helpful? Give feedback.
All reactions