Tunal/crates/tunal/ui/theme.slint
astar76 c94b868b2e S005: overlay layer, menu with submenu, modal dialog, toast stack
Menus, dialogs and toasts draw on an own full-window layer so they can
play exit motion; gallery pages show them open for screenshots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:06:17 -06:00

101 lines
4.2 KiB
Text

// Design tokens. Colours are set from Rust (theme_bridge.rs); everything else is fixed.
export struct TypeStyle {
size: length,
weight: int,
line-height: length,
}
export global Theme {
in-out property <bool> dark;
// Material 3 colour roles (tonal spot scheme from the portal accent).
in-out property <color> primary;
in-out property <color> on-primary;
in-out property <color> primary-container;
in-out property <color> on-primary-container;
in-out property <color> inverse-primary;
in-out property <color> secondary;
in-out property <color> on-secondary;
in-out property <color> secondary-container;
in-out property <color> on-secondary-container;
in-out property <color> tertiary;
in-out property <color> on-tertiary;
in-out property <color> tertiary-container;
in-out property <color> on-tertiary-container;
in-out property <color> error;
in-out property <color> on-error;
in-out property <color> error-container;
in-out property <color> on-error-container;
in-out property <color> surface;
in-out property <color> surface-dim;
in-out property <color> surface-bright;
in-out property <color> surface-container-lowest;
in-out property <color> surface-container-low;
in-out property <color> surface-container;
in-out property <color> surface-container-high;
in-out property <color> surface-container-highest;
in-out property <color> on-surface;
in-out property <color> surface-variant;
in-out property <color> on-surface-variant;
in-out property <color> inverse-surface;
in-out property <color> inverse-on-surface;
in-out property <color> outline;
in-out property <color> outline-variant;
in-out property <color> shadow;
in-out property <color> scrim;
// Shape: corner radii. Concentric nesting: inner = outer - padding.
out property <length> corner-none: 0px;
out property <length> corner-xs: 4px;
out property <length> corner-sm: 8px;
out property <length> corner-md: 12px;
out property <length> corner-lg: 16px;
out property <length> corner-xl: 28px;
// Fully rounded ends for a shape of the given height.
public pure function corner-full(height: length) -> length {
height / 2
}
// Spacing on a 4 px grid.
out property <length> space-1: 4px;
out property <length> space-2: 8px;
out property <length> space-3: 12px;
out property <length> space-4: 16px;
out property <length> space-6: 24px;
out property <length> space-8: 32px;
// Hairline borders.
out property <length> hairline: 1px;
// Floating surfaces (menus, dialogs, toasts, tooltips): one soft shadow, mixed from
// `shadow`. Resting surfaces have none.
out property <length> float-shadow-blur: 12px;
out property <length> float-shadow-offset: 4px;
out property <float> float-shadow-opacity: 0.18;
// Dims the window behind a modal dialog, mixed from `scrim`.
out property <float> scrim-opacity: 0.32;
// Gap kept between a floating surface and the window edge.
out property <length> window-margin: 8px;
// Keyboard focus ring, drawn outside the control's shape.
out property <length> focus-ring-width: 2px;
out property <length> focus-ring-offset: 2px;
// Type: the system UI face plus the icon font; four sizes.
out property <string> icon-font: "Material Symbols Rounded";
out property <TypeStyle> title-large: { size: 22px, weight: 400, line-height: 28px };
out property <TypeStyle> title-medium: { size: 16px, weight: 500, line-height: 24px };
out property <TypeStyle> body-medium: { size: 14px, weight: 400, line-height: 20px };
out property <TypeStyle> body-small: { size: 12px, weight: 400, line-height: 16px };
out property <TypeStyle> label-large: { size: 14px, weight: 500, line-height: 20px };
out property <TypeStyle> label-medium: { size: 12px, weight: 500, line-height: 16px };
// State-layer opacities: tint = role.with-alpha(state-*).
out property <float> state-hover: 0.08;
out property <float> state-focus: 0.10;
out property <float> state-press: 0.10;
out property <float> state-drag: 0.16;
out property <float> disabled-content: 0.38;
out property <float> disabled-container: 0.12;
}