styling

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package styling resolves lys-shell's design tokens to concrete colors. 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

View Source
const LegacyUserStylesFile = "index.scss"

LegacyUserStylesFile is the SCSS entry lys-shell read before its styles became plain CSS.

View Source
const RemBase = tokens.RemPx

RemBase is the rem the stylesheet's base values multiply.

View Source
const UserStylesFile = "index.css"

UserStylesFile is the user's stylesheet under <configDir>/styles/.

Variables

View Source
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.

View Source
var StaticCSS = concatSheets()

StaticCSS is the built-in stylesheet: every file in sheetOrder, concatenated.

Functions

func BarCSS

BarCSS is the bar's variable block: scale, colors, borders, the pixel-rounded spacing, the button opacity and weight, the group chrome, and the shadow. The background opacity is the one the styling lets surfaces show.

func BundleCSS

func BundleCSS(cfg *config.Config, palette config.Palette, p *Palette) string

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, the type scale, and the spacing, radii and field.

func ButtonCSS

ButtonCSS is one bar button's variable block: the five colors, each a threshold override when one is active, and the bar's button border width.

func ColorMix

func ColorMix(a, b render.Color, pct int) render.Color

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: 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

func HexRGBA(c render.Color) string

HexRGBA renders a premultiplied color as the straight-alpha #rrggbbaa (or #rrggbb when opaque) form lys-ui stylesheets parse.

func HighContrastPalette

func HighContrastPalette(dark bool) config.Palette

HighContrastPalette is the shell's high-contrast palette: lys-ui's HighContrastTheme for light, its inverse for dark.

func LoadMatugen

func LoadMatugen(path string, isLight bool) (config.Palette, error)

LoadMatugen reads a matugen palette: primary doubles as blue, tertiary is yellow, secondary green, error red.

func LoadPywal

func LoadPywal(path string, isLight bool) (config.Palette, error)

LoadPywal reads pywal's colors.json: the special background and foreground, color1-4 as red/green/yellow/blue, color7 muted.

func LoadWallust

func LoadWallust(path string, isLight bool) (config.Palette, error)

LoadWallust reads wallust's cached palette: color3 red, color4 green, color5 yellow, color6 primary and blue, color7 muted.

func MetricsCSS

func MetricsCSS() string

MetricsCSS declares tokens' spacing, radius and field on :root: each rem step times --global-scale, its bar twins over --bar-scale, the pill radius, and the field's fill and ring as mixes of --palette-fg.

func NotificationCSS

NotificationCSS declares the popup cards' resting surface: the card color, the palette's elevated surface, at popup-opacity as the styling lets surfaces show it.

func ParseHex

func ParseHex(s string) (render.Color, bool)

ParseHex is parseHex for callers outside styling: a CSS hex color as a premultiplied render.Color.

func ResolveColor

func ResolveColor(cv config.ColorValue, p *Palette) (render.Color, bool)

ResolveColor resolves a config ColorValue against the palette: Auto defers to the accent, 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: 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: 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 ResolveLabelColor

ResolveLabelColor is a bar button's text color: the threshold override when one is active, else the configured color through ResolveColorCSS. Under high contrast a custom hex from either yields to the field's default token, which the high-contrast palette keeps legible.

func ResolvePalette

func ResolvePalette(fallback config.Palette, s config.StylingConfig) (config.Palette, error)

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. The wallpaper provider without a palette (no wallpaper is set) is fallback, as that is no failure.

func RoundingRadiusPx

func RoundingRadiusPx(level config.RoundingLevel, scale float64) int

RoundingRadiusPx resolves a rounding level to corner pixels: tokens' radius scale at RemBase times the scale, with full pinned at tokens.RadiusFullPx unscaled.

func ThemeCSS

ThemeCSS is the runtime theme block: the :root custom properties for the palette, the dropdown surface, fonts, scales, the bar-button pixel overrides, and the rounding tokens. The caller passes the result of ResolvePalette, so the provider failure surfaces as an error to log. The output is the full ":root { ... }" rule.

func TokensCSS

func TokensCSS(p *Palette) string

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

func ToolkitRadiusPx() int

ToolkitRadiusPx is lys-ui's default corner radius, what the default rounding level resolves to.

func TryUserCSS

func TryUserCSS(configDir string) (string, error)

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

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

func UserCSS(configDir string) string

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

func UserStylesDir(configDir string) (string, bool)

UserStylesDir returns <configDir>/styles/ when it is a directory.

func WidthStyle

func WidthStyle(px int) string

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

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
	// HighContrast derives the tokens for high contrast: muted and subtle
	// text and every border are the text color itself.
	HighContrast bool
}

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 (ShellPalette).

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

func PaletteFromHex(p config.Palette) (*Palette, error)

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.

func ShellPalette

func ShellPalette(s config.StylingConfig) (config.Palette, *Palette, error)

ShellPalette is the palette the shell draws with, in hex and as render colors: the provider's (ResolvePalette over the active palette), or with high contrast on the high-contrast palette in the provider's lightness (or the forced appearance). A provider failure keeps the configured palette and an unparsable palette the compiled Default; either failure is returned for the caller to log, and the palette is always usable.

func (*Palette) Token

func (p *Palette) Token(t config.CssToken) (render.Color, bool)

Token resolves one design token against the palette: the color-mix table, one entry per token; a token without a mix is a palette color passed through. It is the only definition of the tokens.

type TextRole

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

func TextRoles() []TextRole

TextRoles is every role, smallest first.

func (TextRole) BarToken

func (r TextRole) BarToken() string

BarToken is the role's custom property for the bar, scaled by --bar-scale.

func (TextRole) Px

func (r TextRole) Px(rem, scale float64) float64

Px is the role's size in pixels over a body of rem pixels at scale.

func (TextRole) Ratio

func (r TextRole) Ratio() float64

Ratio is the role's size relative to body.

func (TextRole) Token

func (r TextRole) Token() string

Token is the role's custom property for surfaces scaled by --global-scale.

Directories

Path Synopsis
Package material computes Material You color schemes from an image, a port of Google's material-color-utilities (the TypeScript release 0.4.0, 2021 color spec): CAM16 and HCT, the Celebi quantizer (Wu, then WSMeans), the seed scorer, tonal palettes and the dynamic scheme roles of every variant, at any contrast level.
Package material computes Material You color schemes from an image, a port of Google's material-color-utilities (the TypeScript release 0.4.0, 2021 color spec): CAM16 and HCT, the Celebi quantizer (Wu, then WSMeans), the seed scorer, tonal palettes and the dynamic scheme roles of every variant, at any contrast level.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL