-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add responsive font sizes #33543
Add responsive font sizes #33543
Conversation
Size Change: +369 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
const minMaxRate = '8vw'; | ||
const slope = '0'; | ||
const space = '\\s*'; | ||
const valueRefex = new RegExp( |
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.
I guess this should be valueRegex
? 😄
const minFontSize = '12px'; | ||
const valueMatcher = '(?<val>[0-9\\.]*[a-z%]*)'; | ||
const valuePlaceholder = '\\k<val>'; | ||
const minMaxRate = '8vw'; |
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.
we need to consider which ones we'd want to express as attributes without UI so they can be changed by patterns for finer control
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.
When we introduce these attributes, we'll be introducing new things to support (bc) and things we can't revisit. I personally feel it's wiser to do it in the other direction. Meaning build a UI to tweak some of these values but store it like today (custom values), validate that it's the kind of customization we want and then split the attribute.
Alternatively, we should find a way to mark blocks/patterns using this new attribute format as something very experimental that can potentially break in the future.
@@ -18,11 +18,32 @@ import RangeControl from '../range-control'; | |||
import { default as UnitControl, useCustomUnits } from '../unit-control'; | |||
import CustomSelectControl from '../custom-select-control'; | |||
import { VisuallyHidden } from '../visually-hidden'; | |||
import CheckboxControl from '../checkbox-control'; |
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.
I'd like to try making this a default for font-sizes above a given threshold and maybe opt-in for em/rem.
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.
There's a lot of variation depending on device size, but generally I've found that font sizes that are 64px
and above tend to break poorly on small screens. Maybe we use that as a threshold and see how it feels?
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.
Yes, that'd be a reasonable start, I think.
); | ||
|
||
function clampValue( value ) { | ||
return `clamp( calc( ${ minFontSize } - ( ( ${ minFontSize } - ${ value } ) * ${ slope } ) ) , ${ value } , calc( calc( ${ minFontSize } + ${ minMaxRate } ) + ( ( ${ value } - calc( ${ minFontSize } + ${ minMaxRate } ) ) * ${ slope } ) ) )`; |
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.
@youknowriad I'm having trouble wrapping my head around each part of these equations. Would you mind annotating this a little more? Or if you can point me to a reference/purpose for the slope value here that'd be helpful too. That's the part I'm getting tripped up on.
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.
It is based on this exploration https://observablehq.com/@eeeps/modulating-input-font-sizes we'll definitely need more inline documentation about this.
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.
That's really helpful, especially the visualization. Thank you!
I'd love to pick this back up. Can we add a generic |
Hi, I have applied responsive fonts in the mobile version of a project, where the font size is a function of the size of the title of product. It will be great if you can incorporate it in to your project, also considering the cases of "load more", "infinite scroll" implementations of lists that required additional theme customizations. Will be happy to share my plugin |
Just experimenting with opinionated responsive font sizes.