Skip to main content

ferro_theme/
token.rs

1//! Fixed semantic token vocabulary for ferro-theme/v2.
2//!
3//! Defines ~30 semantic slots that every theme must provide. Tokens are
4//! CSS custom properties resolved by the Tailwind v4 `@theme` directive.
5//! Components reference them as utility classes (`bg-primary`, `text-surface`, etc.).
6
7// Surface tokens — structural background hierarchy
8/// Background of the page.
9pub const TOKEN_BACKGROUND: &str = "--color-background";
10/// Raised surface above background (panels, sidebars).
11pub const TOKEN_SURFACE: &str = "--color-surface";
12/// Card background (further raised above surface).
13pub const TOKEN_CARD: &str = "--color-card";
14/// Default border color.
15pub const TOKEN_BORDER: &str = "--color-border";
16/// Primary text color.
17pub const TOKEN_TEXT: &str = "--color-text";
18/// Muted/secondary text color.
19pub const TOKEN_TEXT_MUTED: &str = "--color-text-muted";
20
21// Role tokens — semantic color roles
22/// Primary action color (buttons, links, highlights).
23pub const TOKEN_PRIMARY: &str = "--color-primary";
24/// Foreground color on primary backgrounds.
25pub const TOKEN_PRIMARY_FOREGROUND: &str = "--color-primary-foreground";
26/// Secondary action color.
27pub const TOKEN_SECONDARY: &str = "--color-secondary";
28/// Foreground color on secondary backgrounds.
29pub const TOKEN_SECONDARY_FOREGROUND: &str = "--color-secondary-foreground";
30/// Accent color for decorative highlights.
31pub const TOKEN_ACCENT: &str = "--color-accent";
32/// Destructive / danger actions.
33pub const TOKEN_DESTRUCTIVE: &str = "--color-destructive";
34/// Success / confirmation state.
35pub const TOKEN_SUCCESS: &str = "--color-success";
36/// Warning / caution state.
37pub const TOKEN_WARNING: &str = "--color-warning";
38
39// Shape tokens — border radius scale
40/// Extra-small border radius.
41pub const TOKEN_RADIUS_SM: &str = "--radius-sm";
42/// Medium border radius (default for most elements).
43pub const TOKEN_RADIUS_MD: &str = "--radius-md";
44/// Large border radius (cards, modals).
45pub const TOKEN_RADIUS_LG: &str = "--radius-lg";
46/// Full (pill) border radius.
47pub const TOKEN_RADIUS_FULL: &str = "--radius-full";
48
49// Shadow tokens — elevation scale
50/// Subtle shadow (inputs, small cards).
51pub const TOKEN_SHADOW_SM: &str = "--shadow-sm";
52/// Medium shadow (floating panels).
53pub const TOKEN_SHADOW_MD: &str = "--shadow-md";
54/// Large shadow (modals, popovers).
55pub const TOKEN_SHADOW_LG: &str = "--shadow-lg";
56
57// Typography tokens — font family scale only; Tailwind size scale stays as-is
58/// Sans-serif font stack.
59pub const TOKEN_FONT_SANS: &str = "--font-sans";
60/// Monospace font stack.
61pub const TOKEN_FONT_MONO: &str = "--font-mono";
62
63// Density token — base spacing unit
64/// Base spacing unit; all spacing utilities resolve as calc(var(--spacing) * N).
65pub const TOKEN_SPACING: &str = "--spacing";
66
67// Motion tokens — frequency-tiered transition discipline
68/// Fast transition duration (micro-interactions: hover, toggles). Default: 120ms.
69pub const TOKEN_MOTION_DURATION_FAST: &str = "--motion-duration-fast";
70/// Base transition duration (dropdowns, modals, toasts). Default: 220ms.
71pub const TOKEN_MOTION_DURATION_BASE: &str = "--motion-duration-base";
72/// Slow transition duration (drawers, page-level reveals). Default: 320ms.
73pub const TOKEN_MOTION_DURATION_SLOW: &str = "--motion-duration-slow";
74/// Standard easing curve (calm, settled, no bounce).
75pub const TOKEN_MOTION_EASE: &str = "--motion-ease";
76
77// Focus token — uniform keyboard-navigation ring
78/// Focus-visible ring color for interactive components.
79pub const TOKEN_COLOR_RING: &str = "--color-ring";
80
81// Display font token
82/// Display/heading font family; defaults to var(--font-sans).
83pub const TOKEN_FONT_DISPLAY: &str = "--font-display";
84
85/// All token names in the ferro-theme/v2 vocabulary (30 slots).
86pub const ALL_TOKENS: &[&str] = &[
87    TOKEN_BACKGROUND,
88    TOKEN_SURFACE,
89    TOKEN_CARD,
90    TOKEN_BORDER,
91    TOKEN_TEXT,
92    TOKEN_TEXT_MUTED,
93    TOKEN_PRIMARY,
94    TOKEN_PRIMARY_FOREGROUND,
95    TOKEN_SECONDARY,
96    TOKEN_SECONDARY_FOREGROUND,
97    TOKEN_ACCENT,
98    TOKEN_DESTRUCTIVE,
99    TOKEN_SUCCESS,
100    TOKEN_WARNING,
101    TOKEN_RADIUS_SM,
102    TOKEN_RADIUS_MD,
103    TOKEN_RADIUS_LG,
104    TOKEN_RADIUS_FULL,
105    TOKEN_SHADOW_SM,
106    TOKEN_SHADOW_MD,
107    TOKEN_SHADOW_LG,
108    TOKEN_FONT_SANS,
109    TOKEN_FONT_MONO,
110    TOKEN_SPACING,
111    TOKEN_MOTION_DURATION_FAST,
112    TOKEN_MOTION_DURATION_BASE,
113    TOKEN_MOTION_DURATION_SLOW,
114    TOKEN_MOTION_EASE,
115    TOKEN_COLOR_RING,
116    TOKEN_FONT_DISPLAY,
117];
118
119#[cfg(test)]
120mod tests {
121    use super::*;
122
123    #[test]
124    fn all_tokens_len_is_30() {
125        assert_eq!(
126            ALL_TOKENS.len(),
127            30,
128            "ALL_TOKENS must have exactly 30 slots"
129        );
130    }
131}