meduzen / true-hsl.scss Goto Github PK
View Code? Open in Web Editor NEWLet HSL stay HSL in SCSS.
License: Do What The F*ck You Want To Public License
Let HSL stay HSL in SCSS.
License: Do What The F*ck You Want To Public License
Context: #2.
To be done after #3.
Like in double-dash.scss
My initial plan for this package was to not upgrade it to Dart SASS. But unfortunately, hsl
and hsla
remain global (despite the existence of a namespaced color
module with color.hue()
, color.saturate()
and color.lightness()
) and their behavior is still chaotic.
Basically, the current result of using hsl
and hsla
seems to follow this decision tree:
hsl
/hsla
, it’s left untouched by SASS;deg
to the hue;turn
or rad
, it replaces it by deg
without converting;%
in saturation and lightness;hsl
with alpha channel, replaces hsl
by hsla
;hsla
without alpha channel, replaces hsla
by hsl
.This matches phase 1 of 3 (or 2 of 3 for the hue) in the deprecation plan for color units, leading to these outputs:
.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))`
}
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 hsl
and hsla
.
Currently, hsl.scss
perfectly works both @import
and @use
, but its documentation should be improved to reflect the current state of hsl
/hsla
in SASS.
Related tasks:
Context: #2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.