use nugu.nu # Map Nugu's semantic palette onto spindraw's CSS roles (assets/nugu.css in the spindraw repo). # Derived roles use the same OkLab mixing as nugu.nu, with one rule for both modes. def mix [color: string, fraction: float] { pastel mix --colorspace OkLab --fraction $fraction $color | pastel format hex | ansi strip } def textcolor [] { pastel textcolor | pastel format hex | ansi strip } # Roles for one mode. `light` is passed along so print roles stay paper-like in both modes. def roles [p: record, light: record] { let text = $p.content.normal let background = $p.content.backdrop # Panels sit one step away from the backdrop, toward the light end in light mode and up from black in dark mode. let surface = if $p.content.backdrop == $light.content.backdrop { $background | pastel lighten 0.04 | pastel format hex | ansi strip } else { $p.ui.backdrop } let accent = ($p.content.accent | mix $text 0.12) let paper = if $p.content.backdrop == $light.content.backdrop { $surface } else { $background } let print_paper = ($light.content.backdrop | pastel lighten 0.04 | pastel format hex | ansi strip) { background: $background surface: $surface surface-2: ($surface | mix $background 0.5) text: $text muted: ($text | mix $surface 0.35) accent: $accent on-accent: ($accent | textcolor) border: $p.content.unfocus success: $p.content.focus warning: $p.warning error: $p.error info: $p.info focus: $p.content.important_local paper: $paper ink: $p.content.important_local card: ($paper | mix $text 0.14) card-edge: $p.content.unfocus target: ($paper | mix $text 0.3) print-ink: $light.content.normal print-muted: $light.content.minor print-paper: $print_paper print-cut: ($print_paper | mix $light.content.normal 0.12) } } def declarations [p: record, light: record, indent: string] { roles $p $light | transpose name value | each { |r| $"($indent)--($r.name): ($r.value);" } | str join (char nl) } # CSS custom properties for light and dark: the OS preference picks the mode unless # overrides it. export def css [] { let light = (nugu light).palette let dark = (nugu dark).palette $"/* Generated from Nugu spindraw.nu + nugu.nu + base.toml. Do not edit. * Regenerate with: just spindraw /assets/nugu.css */ :root, :root[data-theme=\"light\"] { color-scheme: light; (declarations $light $light ' ') } @media \(prefers-color-scheme: dark\) { :root:not\([data-theme=\"light\"]\) { color-scheme: dark; (declarations $dark $light ' ') } } :root[data-theme=\"dark\"] { color-scheme: dark; (declarations $dark $light ' ') } " }