Documentation
¶
Overview ¶
Package styling resolves lys-shell's design tokens to concrete colors: the Go counterpart of crates/wayle-styling. The palette is the runtime source of truth and every token is a color-mix derivation from it, defined once in Palette.Token: TokensCSS hands the stylesheet the same colors lys-ui's theme and the painters use.
Index ¶
- Constants
- Variables
- func BarCSS(bar config.BarConfig, provider config.ThemeProvider) string
- func BundleCSS(cfg *config.Config, palette config.Palette, p *Palette) string
- func ButtonCSS(b config.ButtonConfig, bar config.BarConfig, provider config.ThemeProvider, ...) string
- func ColorMix(a, b render.Color, pct int) render.Color
- func ContainerCSS(c config.ContainerConfig, bar config.BarConfig, provider config.ThemeProvider) string
- func EnsureUserStylesScaffold(configDir string)
- func HexRGBA(c render.Color) string
- func LoadMatugen(path string, isLight bool) (config.Palette, error)
- func LoadPywal(path string, isLight bool) (config.Palette, error)
- func LoadWallust(path string, isLight bool) (config.Palette, error)
- func ParseHex(s string) (render.Color, bool)
- func ResolveColor(cv config.ColorValue, p *Palette) (render.Color, bool)
- func ResolveColorCSS(value, fieldDefault config.ColorValue, provider config.ThemeProvider) string
- func ResolveIconColor(b config.ButtonConfig, variant config.BarButtonVariant, ...) string
- func ResolvePalette(fallback config.Palette, s config.StylingConfig) (config.Palette, error)
- func RoundingRadiusPx(level config.RoundingLevel, scale float64) int
- func ThemeCSS(p config.Palette, general config.GeneralConfig, bar config.BarConfig, ...) string
- func TokensCSS(p *Palette) string
- func TryUserCSS(configDir string) (string, error)
- func UserCSS(configDir string) string
- func UserStylesDir(configDir string) (string, bool)
- type Palette
Constants ¶
const LegacyUserStylesFile = "index.scss"
LegacyUserStylesFile is the SCSS entry lys-shell read before its styles became plain CSS.
const RemBase = 16.0
RemBase is the rem the stylesheet's base values multiply: styling.rs's REM_BASE.
const UserStylesFile = "index.css"
UserStylesFile is the user's stylesheet under <configDir>/styles/.
Variables ¶
var ErrPaletteNotFound = errors.New("styling: palette file not found")
ErrPaletteNotFound reports that a provider's palette file does not exist yet (Error::PaletteNotFound); the extractor has not run.
var StaticCSS = concatSheets()
StaticCSS is the built-in stylesheet: every file in sheetOrder, concatenated.
Functions ¶
func BarCSS ¶
func BarCSS(bar config.BarConfig, provider config.ThemeProvider) string
BarCSS is the bar's variable block (crates/lys-shell/src/shell/bar/ styling.rs build_css): scale, colors, borders, the pixel-rounded spacing, the button opacity and weight, the group chrome, and the shadow.
func BundleCSS ¶
BundleCSS is the built-in stylesheet under cfg's theme: the static rules, the palette and config block for palette, and the tokens resolved from p, the same palette as render colors.
func ButtonCSS ¶
func ButtonCSS(b config.ButtonConfig, bar config.BarConfig, provider config.ThemeProvider, t config.ThresholdColors) string
ButtonCSS is one bar button's variable block (bar_buttons/styling.rs build_css): the five colors, each a threshold override when one is active, and the bar's button border width.
func ColorMix ¶
ColorMix interpolates two premultiplied colors: color-mix(in srgb, a pct%, b). CSS interpolates premultiplied channels, which is exactly what interpolating render.Color's bytes does — straight-alpha edge cases (mixing with transparent) come out right by construction.
func ContainerCSS ¶
func ContainerCSS(c config.ContainerConfig, bar config.BarConfig, provider config.ThemeProvider) string
ContainerCSS is a bar container's variable block (bar_container/styling.rs build_css): background, border color, and the bar's button border width, zero while border-show is off.
func EnsureUserStylesScaffold ¶
func EnsureUserStylesScaffold(configDir string)
EnsureUserStylesScaffold creates <configDir>/styles/ and a starter index.css when either is missing. It is a no-op once both exist, and never overwrites the user's file; failures are logged, not returned, so scaffolding never blocks startup.
func HexRGBA ¶
HexRGBA renders a premultiplied color as the straight-alpha #rrggbbaa (or #rrggbb when opaque) form lys-ui stylesheets parse.
func LoadMatugen ¶
LoadMatugen reads a matugen palette: primary doubles as blue, tertiary is yellow, secondary green, error red.
func LoadPywal ¶
LoadPywal reads pywal's colors.json: the special background and foreground, color1-4 as red/green/yellow/blue, color7 muted.
func LoadWallust ¶
LoadWallust reads wallust's cached palette: color3 red, color4 green, color5 yellow, color6 primary and blue, color7 muted.
func ParseHex ¶
ParseHex is parseHex for callers outside styling: a CSS hex color as a premultiplied render.Color.
func ResolveColor ¶
ResolveColor resolves a config ColorValue against the palette: Auto defers to the accent (ColorValue::to_css's documented fallback), transparent is fully transparent, custom hex parses, tokens go through the token table. An invalid hex or unknown token is a load- time error by construction; the bool return covers the custom hex that only fails at resolve time.
func ResolveColorCSS ¶
func ResolveColorCSS(value, fieldDefault config.ColorValue, provider config.ThemeProvider) string
ResolveColorCSS is a color field's CSS (resolve_color in crates/wayle-widgets/src/styling.rs): tokens, transparent, and auto pass through as CSS so a palette swap follows; a custom hex is used under the lys-shell provider but falls back to the field's schema default under an extractor, where a fixed hex has no mapping.
func ResolveIconColor ¶
func ResolveIconColor(b config.ButtonConfig, variant config.BarButtonVariant, provider config.ThemeProvider) string
ResolveIconColor is a bar button's icon color (resolve_icon_color in crates/wayle-widgets/src/components/bar_buttons/component.rs): the custom-hex fallback of ResolveColorCSS, then auto resolves to the module's accent token under the basic variant and to fg-on-accent on the block-prefix and icon-square chrome.
func ResolvePalette ¶
ResolvePalette is the active palette for the configured theme provider (resolve_palette): the lys-shell provider is fallback itself, the extractors load the file extract.ColorsPath names for their tool, with the forced appearance overriding the tool's own light setting. A provider that fails yields fallback and the failure, which the caller logs — the palette is always usable, as in Rust, which logs and falls back.
func RoundingRadiusPx ¶
func RoundingRadiusPx(level config.RoundingLevel, scale float64) int
RoundingRadiusPx resolves a rounding level to corner pixels: the --radius-* table (css/tokens/index.css) times the scale, with full pinned at 9999px unscaled.
func ThemeCSS ¶
func ThemeCSS(p config.Palette, general config.GeneralConfig, bar config.BarConfig, s config.StylingConfig) string
ThemeCSS is the runtime theme block, byte for byte the Rust theme_css (crates/wayle-styling/src/lib.rs): the :root custom properties for the palette, the dropdown surface, fonts, scales, the bar-button pixel overrides, and the rounding tokens. Rust resolves the palette inside theme_css; here the caller passes the result of ResolvePalette, so the provider failure surfaces as an error to log instead of a hidden log line. The output is the full ":root { ... }" rule.
func TokensCSS ¶
TokensCSS declares every palette token (--bg-overlay, --accent, ...) as the color Palette.Token resolves for p: the Go table is the one definition the stylesheet, lys-ui's theme and the settings swatches all read.
func TryUserCSS ¶
TryUserCSS is UserCSS surfacing the failure. ("", nil) means the file does not exist. A leftover styles/index.scss is an error naming the CSS file that replaces it, so its rules never silently stop applying.
func UserCSS ¶
UserCSS is the user's optional overrides at <configDir>/styles/index.css. A failure is logged and yields "", so a broken user stylesheet leaves the rest of the bundle intact.
func UserStylesDir ¶
UserStylesDir returns <configDir>/styles/ when it is a directory.
Types ¶
type Palette ¶
type Palette struct {
Bg, Surface, Elevated render.Color
Fg, FgMuted render.Color
Primary render.Color
Red, Yellow render.Color
Green, Blue render.Color
}
Palette is the runtime color palette — the --palette-* custom properties. Themes replace it wholesale.
func ConfigPalette ¶
func ConfigPalette(s config.StylingConfig) (*Palette, error)
ConfigPalette is the render palette the styling config resolves to: the active palette through its provider, a failing provider leaving the configured palette (as Rust logs and falls back), an unparsable one the compiled Default. Failures are returned for the caller to log; the palette is always usable.
func Default ¶
func Default() *Palette
Default is the built-in catppuccin-mocha palette, the set the shell falls back to when a palette cannot be resolved.
func PaletteFromHex ¶
PaletteFromHex converts a resolved hex palette to the render-color Palette the Go painters consume. A provider can hand back any string, so an unparsable color is an error naming the slot.