pub struct RoleColor {
pub color: Hsla,
pub foreground: Hsla,
pub hover_mix: f32,
/* private fields */
}Expand description
A semantic color role (accent, default, success, warning, danger).
v3 removed numbered scales; a role carries only its base value and readable foreground, and every other shade is derived.
Fields§
§color: Hslae.g. --accent.
foreground: Hslae.g. --accent-foreground.
hover_mix: f32Weight of foreground in the *-hover mix. 0.10 for the status and
accent roles, 0.04 for default.
Implementations§
Source§impl RoleColor
impl RoleColor
pub fn new(color: Hsla, foreground: Hsla) -> Self
Sourcepub fn with_hover_mix(self, hover_mix: f32) -> Self
pub fn with_hover_mix(self, hover_mix: f32) -> Self
default mixes only 4% of its foreground on hover.
Sourcepub fn with_soft_mix(self, soft: f32, soft_hover: f32) -> Self
pub fn with_soft_mix(self, soft: f32, soft_hover: f32) -> Self
Sets the shares of the role color in --role-soft and
--role-soft-hover (default sits at 50/60, the rest at 15/20 in
light and 12/16 in dark for the cooler roles).
Sourcepub fn with_soft_foreground_mix(self, color: f32, foreground: f32) -> Self
pub fn with_soft_foreground_mix(self, color: f32, foreground: f32) -> Self
--role-soft-foreground: color-mix(in oklab, var(--role) C%, var(--foreground) F%)
Sourcepub fn with_vibrant_palette(self, vibrant: bool) -> Self
pub fn with_vibrant_palette(self, vibrant: bool) -> Self
Opts this role into [data-vibrant-palette="true"]. Set through
crate::ThemeBuilder::vibrant_palette, which fans the flag out over
every role at once, the way the attribute selector does.
Sourcepub fn is_vibrant_palette(&self) -> bool
pub fn is_vibrant_palette(&self) -> bool
Whether this role resolves its soft foreground with the vibrant weights.
Sourcepub fn with_soft_foreground_role(self) -> Self
pub fn with_soft_foreground_role(self) -> Self
--default-soft-foreground: var(--default-foreground)
Sourcepub fn hover(&self) -> Hsla
pub fn hover(&self) -> Hsla
--color-accent-hover: color-mix(in oklab, var(--accent) 90%, var(--accent-foreground) 10%)
Sourcepub fn soft(&self) -> Hsla
pub fn soft(&self) -> Hsla
--color-accent-soft: color-mix(in oklab, var(--accent) 15%, transparent)
Sourcepub fn soft_hover(&self) -> Hsla
pub fn soft_hover(&self) -> Hsla
--color-accent-soft-hover: color-mix(in oklab, var(--accent) 20%, transparent)
Sourcepub fn soft_foreground(&self, page_foreground: Hsla) -> Hsla
pub fn soft_foreground(&self, page_foreground: Hsla) -> Hsla
--color-accent-soft-foreground: color-mix(in oklab, var(--accent) 70%, var(--foreground) 30%)
The mixing roles blend against the page foreground, so pass the live
ThemeColors::foreground — a ThemeBuilder::foreground override then
flows through without rebuilding the theme.
pub fn with_alpha(&self, alpha: f32) -> Hsla
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoleColor
impl RefUnwindSafe for RoleColor
impl Send for RoleColor
impl Sync for RoleColor
impl Unpin for RoleColor
impl UnsafeUnpin for RoleColor
impl UnwindSafe for RoleColor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more