hybriel
Question: which css API proposals to build?
opened by Anton
opened · updated
Six proposals from 13 Sep: pseudo-classes as nested entries, a variable carrying its dark-mode value, unit functions, @keyframes, @supports and @container. No mixins. My recommendation: all six.
History
Anton opened the ticket Anton changed the state review Caramboleyo commented wasnt there a propsal file or so? does it contain examples?
Caramboleyo changed the state done Anton commented The proposal is in the log of 13 Sep. With examples:
- Pseudo-classes as nested entries:
a { hover { color = brand } }→a:hover { … }(focus, active, disabled, firstChild …). - A variable with its dark value:
bg = var('#FFF', dark = '#000')writes the prefers-color-scheme override itself. - Units as functions:
padding = rem(1.5),width = pct(50). @keyframes fade { from { opacity = 0 } to { opacity = 1 } }, used asanimation = 'fade 1s'.@supportsand@containerblocks shaped like@media.- No mixins:
base + { color = x }already does it. You confirmed, so a worker builds 1–5 in hl:webex and hl:web.
- Pseudo-classes as nested entries:
Anton commented Built (branch css-api, not merged yet): nested pseudo-classes,
var(…, dark = …), rem/px/pct, @keyframes, @supports/@container. All five work in hl:web and hl:webex.Test:
- In styles.hl:
a { hover { textDecoration = 'underline' } },bg = var('#FFF', dark = '#000'),img { maxWidth = pct(100) }. '@keyframes fade' = { 'from' = { opacity = 0 } to { opacity = 1 } }and@supports { display = 'grid' footer { display = 'grid' } }.- Open /__hl/app.css:
a:hover,--bg: #000under@media (prefers-color-scheme: dark),100%,@keyframes fade,@supports (display: grid).
Details:
- @keyframes needs quotes:
'@keyframes fade' = { 'from' = … }. The unquoted@keyframes fade { from { … } }needs a language change; that question is with Anton. - rem/px/pct and var work only in styles files, not in a component's Style (same limit var already had).
- Examples and the full list of forms are in COMPONENTS.md §4.
- In styles.hl:
Anton commented Merged to master. Two differences from my examples: @keyframes is written quoted,
'@keyframes fade' = { 'from' = { opacity = 0 } to { opacity = 1 } }, becausefromis a keyword; and rem/px/pct/var work in styles files only, not in a component.var(…, small = …)is not built: no width is defined for small.
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.