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: ColorPrimary brand color
secondary: ColorSecondary brand color
surface: ColorSurface/background color
background: ColorBackground color
error: ColorError/danger color
warning: ColorWarning color
success: ColorSuccess color
on_primary: ColorText on primary
on_secondary: ColorText on secondary
on_surface: ColorText on surface
on_background: ColorText on background
on_error: ColorText on error
Implementations§
Source§impl ColorPalette
impl ColorPalette
Sourcepub fn check_contrast(&self) -> Vec<ContrastCheck>
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.
Sourcepub fn passes_wcag_aa(&self) -> bool
pub fn passes_wcag_aa(&self) -> bool
Check if all color pairs pass WCAG AA.
Sourcepub fn passes_wcag_aaa(&self) -> bool
pub fn passes_wcag_aaa(&self) -> bool
Check if all color pairs pass WCAG AAA.
Sourcepub fn failing_aa(&self) -> Vec<ContrastCheck>
pub fn failing_aa(&self) -> Vec<ContrastCheck>
Get any failing contrast pairs for WCAG AA.
Sourcepub fn light() -> ColorPalette
pub fn light() -> ColorPalette
Create a light color palette. All color combinations pass WCAG AA (4.5:1 contrast ratio).
Sourcepub fn dark() -> ColorPalette
pub fn dark() -> ColorPalette
Create a dark color palette.
Trait Implementations§
Source§impl Clone for ColorPalette
impl Clone for ColorPalette
Source§fn clone(&self) -> ColorPalette
fn clone(&self) -> ColorPalette
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ColorPalette
impl Debug for ColorPalette
Source§impl Default for ColorPalette
impl Default for ColorPalette
Source§fn default() -> ColorPalette
fn default() -> ColorPalette
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ColorPalette
impl<'de> Deserialize<'de> for ColorPalette
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ColorPalette, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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
impl PartialEq for ColorPalette
Source§impl Serialize for ColorPalette
impl Serialize for ColorPalette
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
impl StructuralPartialEq for ColorPalette
Auto Trait Implementations§
impl Freeze for ColorPalette
impl RefUnwindSafe for ColorPalette
impl Send for ColorPalette
impl Sync for ColorPalette
impl Unpin for ColorPalette
impl UnwindSafe for ColorPalette
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more