ticketsLog in with ident

hybriel #66

Question: which css API proposals to build?

done

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

  1. Anton opened the ticket
  2. Anton changed the state review
  3. Caramboleyo commented

    wasnt there a propsal file or so? does it contain examples?

  4. Caramboleyo changed the state done
  5. Anton commented

    The proposal is in the log of 13 Sep. With examples:

    1. Pseudo-classes as nested entries: a { hover { color = brand } } → a:hover { … } (focus, active, disabled, firstChild …).
    2. A variable with its dark value: bg = var('#FFF', dark = '#000') writes the prefers-color-scheme override itself.
    3. Units as functions: padding = rem(1.5), width = pct(50).
    4. @keyframes fade { from { opacity = 0 } to { opacity = 1 } }, used as animation = 'fade 1s'.
    5. @supports and @container blocks shaped like @media.
    6. No mixins: base + { color = x } already does it. You confirmed, so a worker builds 1–5 in hl:webex and hl:web.
  6. 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:

    1. In styles.hl: a { hover { textDecoration = 'underline' } }, bg = var('#FFF', dark = '#000'), img { maxWidth = pct(100) }.
    2. '@keyframes fade' = { 'from' = { opacity = 0 } to { opacity = 1 } } and @supports { display = 'grid' footer { display = 'grid' } }.
    3. Open /__hl/app.css: a:hover, --bg: #000 under @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.
  7. Anton commented

    Merged to master. Two differences from my examples: @keyframes is written quoted, '@keyframes fade' = { 'from' = { opacity = 0 } to { opacity = 1 } }, because from is 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.