ColorPalette

Struct ColorPalette 

Source
pub struct ColorPalette {
    pub primary: Color,
    pub secondary: Color,
    pub surface: Color,
    pub background: Color,
    pub error: Color,
    pub warning: Color,
    pub success: Color,
    pub on_primary: Color,
    pub on_secondary: Color,
    pub on_surface: Color,
    pub on_background: Color,
    pub on_error: Color,
}
Expand description

A color palette for theming.

Fields§

§primary: Color

Primary brand color

§secondary: Color

Secondary brand color

§surface: Color

Surface/background color

§background: Color

Background color

§error: Color

Error/danger color

§warning: Color

Warning color

§success: Color

Success color

§on_primary: Color

Text on primary

§on_secondary: Color

Text on secondary

§on_surface: Color

Text on surface

§on_background: Color

Text on background

§on_error: Color

Text on error

Implementations§

Source§

impl ColorPalette

Source

pub fn check_contrast(&self) -> Vec<ContrastCheck>

Check all foreground/background combinations for WCAG compliance. Returns a list of contrast checks for each semantic color pair.

Source

pub fn passes_wcag_aa(&self) -> bool

Check if all color pairs pass WCAG AA.

Source

pub fn passes_wcag_aaa(&self) -> bool

Check if all color pairs pass WCAG AAA.

Source

pub fn failing_aa(&self) -> Vec<ContrastCheck>

Get any failing contrast pairs for WCAG AA.

Source

pub fn light() -> ColorPalette

Create a light color palette. All color combinations pass WCAG AA (4.5:1 contrast ratio).

Source

pub fn dark() -> ColorPalette

Create a dark color palette.

Trait Implementations§

Source§

impl Clone for ColorPalette

Source§

fn clone(&self) -> ColorPalette

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ColorPalette

Source§

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

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

impl Default for ColorPalette

Source§

fn default() -> ColorPalette

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

impl<'de> Deserialize<'de> for ColorPalette

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ColorPalette, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ColorPalette

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ColorPalette

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ColorPalette

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,