Skip to main content

Tokens

Struct Tokens 

Source
pub struct Tokens { /* private fields */ }
Expand description

一份主题在某一明暗档下的全部实际取值。

Implementations§

Source§

impl Tokens

Source

pub fn name(&self) -> &str

主题名(Astryx defineTheme({ name }))。

Source

pub fn is_dark(&self) -> bool

Source

pub fn scales(&self) -> Scales

Source

pub fn value(&self, name: &str) -> Option<&Value>

按变量名原文读任意 token(DevTools / showcase 用)。

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>

Source

pub fn color(&self, token: ColorToken) -> Color

Source

pub fn length(&self, token: LengthToken) -> f32

Source

pub fn spacing(&self, step: SpacingStep) -> f32

Source

pub fn duration(&self, token: DurationToken) -> f32

Source

pub fn font_size(&self, token: FontSizeToken) -> f32

Source

pub fn font_weight(&self, token: FontWeightToken) -> f32

Source

pub fn shadow(&self, token: ShadowToken) -> Shadow

Source

pub fn easing(&self, token: EasingToken) -> [f32; 4]

Source

pub fn text_role(&self, role: TextRole) -> TextRoleStyle

Source

pub fn border_width(&self) -> f32

边框宽度(--border-width)。

Source

pub fn focus(&self) -> FocusTokens

Source

pub fn radius(&self) -> RadiusTokens

Source

pub fn element_size(&self) -> SizeTokens

控件三档高度(--size-element-sm/md/lg)。

Source

pub fn hovered(&self, base: Color) -> Color

base 上盖 --color-overlay-hover。

Source

pub fn pressed(&self, base: Color) -> Color

base 上盖 --color-overlay-pressed。

Source

pub fn color_rows(&self) -> Vec<(&'static str, Color)>

全部颜色 token 的当前值(showcase / DevTools 的 token 表格用)。

Trait Implementations§

Source§

impl Clone for Tokens

Source§

fn clone(&self) -> Self

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 Debug for Tokens

Source§

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

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

impl PartialEq for Tokens

Source§

fn eq(&self, other: &Self) -> 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 Tokens

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.