Refactor fluidRange() with CSS clamp()
fcisio opened this issue · 1 comments
fcisio commented
Summary
Hi! Working with styles objects, I use between()
most ofter, since fluidRange()
outputs media queries and it creates collisions in the object.
Both functions do the same thing, but fluidRange()
actually locks the min and max values.
Wanting to lock these values without outputting media queries, I've made my own version, leveraging CSS clamp()
.
Basic Example
const fluidRange = (min, max, [from, to] = ['375px', '2500px']) =>
`clamp(${min}, ${between(min, max, from, to)}, ${max})`
Outputs
clamp(45px, calc(21.18px + 6.35vw), 180px)
Reasoning
This change doesn't alter the current behavior of fluidRange()
, and it's way lighter.