Skip to main content

Theme

Struct Theme 

Source
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 str

Display name, e.g. "Raven Dark".

§palette: Palette

Color tokens.

§typography: Typography

Type scale.

§spacing: Spacing

Spacing scale.

§radii: Radii

Corner radii.

§elevation: Elevation

Shadow tokens.

§material: Material

Surface material.

§interaction: Interaction

Interaction sizing and motion preferences.

§motion: MotionTokens

Motion tokens.

Implementations§

Source§

impl Theme

Source

pub const fn builtin() -> [Self; 3]

The themes that come with RavenRS.

Source

pub fn base(&self) -> Self

The built-in theme this one started from, by its name; itself when it did not.

Source

pub fn changed_tokens(&self) -> usize

How many tokens differ from base.

Source

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.

Source

pub fn from_tokens_json(text: &str) -> Result<Self, 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

Source

pub const fn raven_dark() -> Self

The default theme: deep neutrals with a single blue-violet accent.

Source

pub const fn raven_light() -> Self

Light theme: near-white surfaces with the same blue-violet accent.

Source

pub const fn raven_glass() -> Self

Translucent surfaces over a deep canvas. Until the compositor’s backdrop blur lands, glass surfaces render as their translucent fill.

Source

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);
Source

pub fn text(&self, style: TextStyle) -> TypeStyle

Returns the type style for a named step of the scale.

Source

pub fn card_padding(&self) -> Insets

Padding of a card (space-6).

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Theme

Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Theme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Theme) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.