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 NotificationCSS(p config.Palette, n config.NotificationConfig) string
- 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 ToolkitRadiusPx() int
- func TryUserCSS(configDir string) (string, error)
- func TypeScaleCSS() string
- func UserCSS(configDir string) string
- func UserStylesDir(configDir string) (string, bool)
- func WidthStyle(px int) string
- func WorkspacesCSS(c config.CompositorWorkspacesConfig, otherMonitor *config.ColorValue, ...) string
- type Palette
- type TextRole
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, the tokens resolved from p, the same palette as render colors, and the type scale.
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 NotificationCSS ¶ added in v0.2.0
func NotificationCSS(p config.Palette, n config.NotificationConfig) string
NotificationCSS declares the popup cards' resting surface: the card color, the palette's elevated surface, at popup-opacity.
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 ToolkitRadiusPx ¶ added in v0.2.0
func ToolkitRadiusPx() int
ToolkitRadiusPx is lys-ui's default corner radius, what the default rounding level resolves to.
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 TypeScaleCSS ¶ added in v0.2.0
func TypeScaleCSS() string
TypeScaleCSS declares every role's tokens on :root: rem times the role's ratio times --global-scale, and the bar's twin over --bar-scale.
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.
func WidthStyle ¶ added in v0.2.0
WidthStyle is the inline style that makes a widget exactly px wide, its border included: lys-ui's explicit width for content that fills whatever width it is offered (an Item, a progress bar), on a surface that would otherwise offer it the whole output.
func WorkspacesCSS ¶ added in v0.2.0
func WorkspacesCSS(c config.CompositorWorkspacesConfig, otherMonitor *config.ColorValue, bar config.BarConfig) string
WorkspacesCSS is a workspaces module's variable block, the colors workspaces.css reads: the state colors, the container background, and the border-show border at the bar's button border width, zero while border-show is off. otherMonitor is hyprland's active-on-other-monitor color, nil for the other compositors.
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.
type TextRole ¶ added in v0.2.0
type TextRole int
TextRole is one step of the type scale every surface sizes its text from: a ratio of the desktop's body size (1rem, the desktop font).
const ( // Caption is secondary text: descriptions, statuses, section headers. Caption TextRole = iota // Body is running text, labels and controls. Body // Subtitle is a card or item heading one step above body. Subtitle // Title is a page or window heading. Title // Display is a large readout: a percentage, a temperature, a PIN. Display // Hero is a prominent readout: the dropdown clock. Hero // Poster is a readout read from across the room: the lock screen clock. Poster )
func TextRoles ¶ added in v0.2.0
func TextRoles() []TextRole
TextRoles is every role, smallest first.
func (TextRole) BarToken ¶ added in v0.2.0
BarToken is the role's custom property for the bar, scaled by --bar-scale.
func (TextRole) Px ¶ added in v0.2.0
Px is the role's size in pixels over a body of rem pixels at scale.