.class {
color: hsla(34deg, 20%, 40%); // ✔ valid
// `hsl(34deg, 20%, 40%)`
color: hsla(34, 20%, 40%); // ✔ valid
// `hsl(34deg, 20%, 40%)`
color: hsl(34, 35%, 92%, 0.2); // ✔ valid
// `hsla(34deg, 35%, 92%, 0.2)`
color: hsla(.5turn, 20%, 40%);
// `hsl(180deg, 20%, 40%)` // ✔ valid since SASS 1.52.1
// `hsl(1deg, 20%, 40%)` // ❌ invalid, should be `180deg`
color: hsl(34, 20, 40, var(--some-number, 'aa')); // ❌ invalid, missing `deg` and `%`
// `hsla(34, 20, 40, var(--some-number, 'aa'))`
color: hsl(34deg, 20, 40, .8); // ✔ valid, warns about missing `%` (deprecated)
// `hsla(34deg, 20%, 40%, 0.8)`
color: hsla(34 35 92); // ✔ valid, warns about missing `%` (deprecated)
// `hsl(34deg, 35%, 92%)`
color: hsl(34 35 92 / .5); // ✔ valid, warns about missing `%` (deprecated)
// `hsla(34deg, 35%, 92%, 0.5)`
color: hsl(34 35 92 / var(--some-number)); // ❌ invalid, missing `deg` and `%`
// `hsl(34 35 92/var(--some-number))`
}
My initial plan for this package was to not upgrade it to Dart SASS. But unfortunately,
hslandhslaremain global (despite the existence of a namespacedcolormodule withcolor.hue(),color.saturate()andcolor.lightness()) and their behavior is still chaotic.Current algorithm and examples
Basically, the current result of using
hslandhslaseems to follow this decision tree:hsl/hsla, it’s left untouched by SASS;degto the hue;turnorrad, it replaces it bydegwithout converting;%in saturation and lightness;hslwith alpha channel, replaceshslbyhsla;hslawithout alpha channel, replaceshslabyhsl.This matches phase 1 of 3 (or 2 of 3 for the hue) in the deprecation plan for color units, leading to these outputs:
For these reasons, this package is (unfortunately) still useful in Dart SASS. No matter the deprecation phase, for now there’s no decent plan for
hslandhsla.Currently,
hsl.scssperfectly works both@importand@use, but its documentation should be improved to reflect the current state ofhsl/hslain SASS.Related tasks:
@debugmode #4