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:
.title {
padding: rfs(2rem);
font-size: rfs(4rem);
}
would generate:
.title {
padding: min(2rem, calc(1.325rem + 0.9vw));
font-size: min(4rem, calc(1.525rem + 3.3vw));
}
Other positive side effects are:
- We can use the same syntax in every language (sass, scss, less, stylus & PostCSS)
- It's a bit more predictable than the
mixin because you know it's going to a value and not "some lines of code"
- Mixins don't work with plugins like stylelint-order, the function would fix this.
- Custom properties (css variables) can be set to a value which can be reused in css.
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/ywaJpW
Browser support
Browser support is still an issue. Browser support so far:
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:
mixinbecause 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: