Sass
sass/rem-helper
Sizes are converted with the project's px-to-rem function, never by dividing by a hard-coded base by hand.
drobnastatycznefe-sass
W projekcie raport i explain zastępują przykład w nawiasach klamrowych własnym narzędziem projektu.
Dlaczego
A project that has a conversion function (Foundation's rem-calc(), or its own rem() or to-rem()) has one place that knows the root font size. A hand-written math.div(24px, 16px) * 1rem, #{24 / 16}rem or calc(24rem / 16) copies that base into the stylesheet: when the base changes, or a reviewer looks for every size, the copies are missed and spacing drifts.
Poprawka
Call the project's helper with the design value in pixels: rem-calc(16px) (the helper is rem-calc, defined in the project's Sass functions). The rule runs only when the profile records the helper (profile.helpers["rem-function"]) and no build step converts px for you; raw px sizes are reported by css/rem-helper, this rule reports conversions written by hand.
Przykłady
// bad
.card { padding: math.div(24px, 16px) * 1rem; font-size: #{18 / 16}rem; }
// good
@use 'functions' as *;
.card { padding: rem-calc(24px); font-size: rem-calc(18px); }Źródła
Fakty
- Identyfikator
sass/rem-helper- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
scssvuesvelteastro- Tylko w projektach z
sass- Wymaga narzędzia projektu
rem-function- Uczy jej skill
fe-sassSass (SCSS)- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain sass/rem-helper