-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Make use of the css min()
function
#110
Comments
Firefox already supports this https://caniuse.com/#feat=css-math-functions |
For the early adopters out here, you can now install this implementation with:
Docs: https://github.com/twbs/rfs/tree/min-function Planning to release this on npm as an alpha in the comming days/ weeks. Descided to make an alpha release since the support is still not big enough |
Hi @MartijnCuppens , any issue in having this rolled out in main? The min seems supported in most browsers and works great and it shrinkens the css. |
Could also adopt
|
In version 10.0.0-alpha.0 I had for
with the known issues about the division warnings. But now I am getting only the |
Here is a loosely worked out function which does the job with version 10.0.0 @use "../../node_modules/rfs/scss" as rfs;
/*
Adapted helper inspired from 10.0.0-alpha.0 version which uses min instead of media queries
*/
@function rfs-value-min($value) {
$rfs-val: rfs.rfs-value($value);
$rfs-fluid-val: rfs.rfs-fluid-value($value);
@if $rfs-val == $rfs-fluid-val {
@return $rfs-val;
}
@return min($rfs-val, $rfs-fluid-val);
} Usage h1 {
font-size: rfs-value-min(2.5rem);
}
h5 {
font-size: rfs-value-min(1.25rem);
} Output h1 {
font-size: min(2.5rem, calc(1.375rem + 1.5vw));
}
h5 {
font-size: 1.25rem;
} |
To me, it seems with |
Hopefully one day the
min()
function will be implemented by all major browsers and that could simplify RFS a lot. Instead of the mixin, we can make use of a function to generate the value.For example:
would generate:
Other positive side effects are:
mixin
because you know it's going to a value and not "some lines of code"Only downside is that the disabled/enabled classes won't work anymore, but I have no clue if this feature is even used.
Currently Safari kind of supports
min()
, but it's still not perfect when resizing without the safari iframe hack (#14): https://codepen.io/MartijnCuppens/pen/ywaJpWBrowser support
Browser support is still an issue. Browser support so far:
The text was updated successfully, but these errors were encountered: