pub struct Theme {
pub name: &'static str,
pub palette: Palette,
pub typography: Typography,
pub spacing: Spacing,
pub radii: Radii,
pub elevation: Elevation,
pub material: Material,
pub interaction: Interaction,
pub motion: MotionTokens,
}Expand description
A complete theme: palette plus the shared scales.
Fields§
§name: &'static strDisplay name, e.g. "Raven Dark".
palette: PaletteColor tokens.
typography: TypographyType scale.
spacing: SpacingSpacing scale.
radii: RadiiCorner radii.
elevation: ElevationShadow tokens.
material: MaterialSurface material.
interaction: InteractionInteraction sizing and motion preferences.
motion: MotionTokensMotion tokens.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn base(&self) -> Theme
pub fn base(&self) -> Theme
The built-in theme this one started from, by its name; itself when it did not.
Sourcepub fn changed_tokens(&self) -> usize
pub fn changed_tokens(&self) -> usize
How many tokens differ from base.
Sourcepub fn to_tokens_json(&self) -> String
pub fn to_tokens_json(&self) -> String
What differs from base as JSON, with the same names as
docs/design-system/tokens.json, for keeping or handing over.
Sourcepub fn from_tokens_json(text: &str) -> Result<Theme, String>
pub fn from_tokens_json(text: &str) -> Result<Theme, String>
A theme from what to_tokens_json wrote. Anything it does not
recognize, or a size too far out to read, refuses the whole text, which may come from anywhere.
Source§impl Theme
impl Theme
Sourcepub const fn raven_dark() -> Theme
pub const fn raven_dark() -> Theme
The default theme: deep neutrals with a single blue-violet accent.
Sourcepub const fn raven_light() -> Theme
pub const fn raven_light() -> Theme
Light theme: near-white surfaces with the same blue-violet accent.
Sourcepub const fn raven_glass() -> Theme
pub const fn raven_glass() -> Theme
Translucent surfaces over a deep canvas. Until the compositor’s backdrop blur lands, glass surfaces render as their translucent fill.
Sourcepub fn color(&self, role: Semantic) -> Color
pub fn color(&self, role: Semantic) -> Color
Resolves a semantic color role in this theme.
use ravenrs_style::{Semantic, Theme};
let theme = Theme::raven_dark();
assert_eq!(theme.color(Semantic::Accent), theme.palette.accent);Sourcepub fn text(&self, style: TextStyle) -> TypeStyle
pub fn text(&self, style: TextStyle) -> TypeStyle
Returns the type style for a named step of the scale.
Sourcepub fn card_padding(&self) -> Insets
pub fn card_padding(&self) -> Insets
Padding of a card (space-6).