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.
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.
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.
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.
| 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.
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.
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.
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.
@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.
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.
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.