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
- Variables
- func BarCSS(bar config.BarConfig, s config.StylingConfig) string
- func BundleCSS(cfg *config.Config, palette config.Palette, p *Palette) string
- func ButtonCSS(b config.ButtonConfig, bar config.BarConfig, s config.StylingConfig, ...) 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 HighContrastPalette(dark bool) config.Palette
- 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 MetricsCSS() string
- func NotificationCSS(p config.Palette, n config.NotificationConfig, s config.StylingConfig) 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 ResolveLabelColor(b config.ButtonConfig, s config.StylingConfig, t config.ThresholdColors) 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 = tokens.RemPx
RemBase is the rem the stylesheet's base values multiply.
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, s config.StylingConfig) string
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 ¶
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 ¶
func ButtonCSS(b config.ButtonConfig, bar config.BarConfig, s config.StylingConfig, t config.ThresholdColors) string
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 ¶
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 ¶
HexRGBA renders a premultiplied color as the straight-alpha #rrggbbaa (or #rrggbb when opaque) form lys-ui stylesheets parse.
func HighContrastPalette ¶
HighContrastPalette is the shell's high-contrast palette: lys-ui's HighContrastTheme for light, its inverse for dark.
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 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 ¶
func NotificationCSS(p config.Palette, n config.NotificationConfig, s config.StylingConfig) string
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 ¶
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, 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 ¶
func ResolveLabelColor(b config.ButtonConfig, s config.StylingConfig, t config.ThresholdColors) string
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 ¶
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 ¶
func ThemeCSS(p config.Palette, general config.GeneralConfig, bar config.BarConfig, s config.StylingConfig) string
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
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 (TextRole) BarToken ¶
BarToken is the role's custom property for the bar, scaled by --bar-scale.
Source Files
¶
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. |