use iced::border::Border;
use iced::overlay::menu as overlay_menu;
use iced::widget::{
button, checkbox, container, pick_list, progress_bar, radio, rule, scrollable, slider,
text_input, toggler,
};
use iced::{Background, Color, Shadow};
use crate::chrome::Elevation;
use crate::m3::color::{face, layer_on};
use crate::m3::shape::Component;
use crate::m3::ControlState;
use crate::theme::{hover_fill, Tokens};
use crate::variant::Variant;
fn component_radius(c: Component) -> iced::border::Radius {
c.radius()
}
fn button_status(status: button::Status) -> ControlState {
match status {
button::Status::Active => ControlState::Enabled,
button::Status::Hovered => ControlState::Hovered,
button::Status::Pressed => ControlState::Pressed,
button::Status::Disabled => ControlState::Disabled,
}
}
pub fn fill(bg: Color, fg: Color) -> container::Style {
container::Style {
background: Some(Background::Color(bg)),
text_color: Some(fg),
snap: false,
..container::Style::default()
}
}
pub fn card(tok: Tokens, focus: bool) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(s.surface_container_low)),
text_color: Some(s.on_surface),
border: Border {
color: if focus { s.primary } else { s.outline_variant },
width: if focus { 2.0 } else { 1.0 },
radius: component_radius(Component::Card),
},
shadow: Elevation::Level1.shadow(),
snap: false,
}
}
pub fn outlined_card(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Some(s.on_surface),
border: Border {
color: s.outline,
width: 1.0,
radius: component_radius(Component::Card),
},
shadow: Shadow::default(),
snap: false,
}
}
pub fn raised_card(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(Elevation::Level2.surface(s))),
text_color: Some(s.on_surface),
border: Border {
color: s.outline_variant,
width: 0.0,
radius: component_radius(Component::Card),
},
shadow: Elevation::Level2.shadow(),
snap: false,
}
}
pub fn shell(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(s.surface)),
text_color: Some(s.on_surface),
border: Border {
color: s.outline,
width: 1.0,
radius: component_radius(Component::Shell),
},
shadow: Shadow::default(),
snap: false,
}
}
pub fn panel(tok: Tokens) -> container::Style {
let s = tok.scheme();
fill(s.surface_container_high, s.on_surface)
}
pub fn footer(tok: Tokens) -> container::Style {
let s = tok.scheme();
fill(s.surface_container_high, s.on_surface_variant)
}
pub fn hairline(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(s.outline_variant)),
snap: false,
..container::Style::default()
}
}
pub fn dim_backdrop(tok: Tokens) -> container::Style {
let scrim = tok.scheme().scrim;
container::Style {
background: Some(Background::Color(Color::from_rgba(
scrim.r, scrim.g, scrim.b, 0.32,
))),
snap: false,
..container::Style::default()
}
}
pub fn list_row(tok: Tokens, selected: bool) -> container::Style {
let s = tok.scheme();
if selected {
fill(s.secondary_container, s.on_secondary_container)
} else {
fill(Color::TRANSPARENT, s.on_surface)
}
}
pub fn list_row_hover(tok: Tokens, selected: bool) -> container::Style {
let s = tok.scheme();
if selected {
let bg = layer_on(s.secondary_container, s.on_secondary_container, 0.08);
fill(bg, s.on_secondary_container)
} else {
fill(hover_fill(tok), s.on_surface)
}
}
pub fn table_cell(tok: Tokens, selected: bool, focused: bool, zebra: bool) -> container::Style {
let s = tok.scheme();
let mut st = if selected {
fill(s.secondary_container, s.on_secondary_container)
} else if zebra {
fill(s.surface_container_high, s.on_surface)
} else {
fill(Color::TRANSPARENT, s.on_surface)
};
if focused {
if selected {
st.border = Border {
color: s.primary,
width: 2.0,
radius: 0.0.into(),
};
} else {
st = fill(s.primary_container, s.on_primary_container);
st.border = Border {
color: s.primary,
width: 2.0,
radius: 0.0.into(),
};
}
}
st
}
pub fn callout(tok: Tokens, kind: crate::toast::ToastKind) -> container::Style {
let s = tok.scheme();
let (bg, fg, border) = match kind {
crate::toast::ToastKind::Info => (s.primary_container, s.on_primary_container, s.primary),
crate::toast::ToastKind::Success => (
layer_on(s.surface, s.success, 0.16),
s.on_surface,
s.success,
),
crate::toast::ToastKind::Warning => (
layer_on(s.surface, s.warning, 0.16),
s.on_surface,
s.warning,
),
crate::toast::ToastKind::Danger => (s.error_container, s.on_error_container, s.error),
};
container::Style {
background: Some(Background::Color(bg)),
text_color: Some(fg),
border: Border {
color: border,
width: 1.0,
radius: component_radius(Component::Card),
},
shadow: Shadow::default(),
snap: false,
}
}
pub fn skeleton(tok: Tokens) -> container::Style {
let s = tok.scheme();
fill(s.surface_container_highest, s.on_surface_variant)
}
fn button_border(comp: Component) -> Border {
Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(comp),
}
}
fn button_face(
tok: Tokens,
variant: Variant,
state: ControlState,
) -> (Color, Color, Border, Shadow) {
let s = tok.scheme();
let surface = s.surface;
let pill = button_border(Component::Button);
match variant {
Variant::Primary => {
let (bg, fg) = face(s.primary, s.on_primary, surface, state);
(bg, fg, pill, Shadow::default())
}
Variant::Quiet => {
let (bg, fg) = face(
s.secondary_container,
s.on_secondary_container,
surface,
state,
);
(bg, fg, pill, Shadow::default())
}
Variant::Ghost => {
let (bg, fg) = match state {
ControlState::Disabled => {
(Color::TRANSPARENT, layer_on(surface, s.on_surface, 0.38))
}
ControlState::Hovered | ControlState::Focused => {
(layer_on(surface, s.primary, 0.08), s.primary)
}
ControlState::Pressed => (layer_on(surface, s.primary, 0.12), s.primary),
_ => (Color::TRANSPARENT, s.primary),
};
(bg, fg, pill, Shadow::default())
}
Variant::Chip => {
let (bg, fg) = face(
s.secondary_container,
s.on_secondary_container,
surface,
state,
);
(bg, fg, button_border(Component::Chip), Shadow::default())
}
Variant::Danger => {
let (bg, fg) = face(s.error, s.on_error, surface, state);
(bg, fg, pill, Shadow::default())
}
Variant::Success => {
let (bg, fg) = face(s.success, s.on_success, surface, state);
(bg, fg, pill, Shadow::default())
}
Variant::Warning => {
let (bg, fg) = face(s.warning, s.on_warning, surface, state);
(bg, fg, pill, Shadow::default())
}
Variant::Outlined => {
let (bg, fg) = match state {
ControlState::Disabled => {
(Color::TRANSPARENT, layer_on(surface, s.on_surface, 0.38))
}
ControlState::Hovered | ControlState::Focused => {
(layer_on(surface, s.primary, 0.08), s.primary)
}
ControlState::Pressed => (layer_on(surface, s.primary, 0.12), s.primary),
_ => (Color::TRANSPARENT, s.primary),
};
(
bg,
fg,
Border {
color: if matches!(state, ControlState::Disabled) {
s.outline.scale_alpha(0.38)
} else {
s.outline
},
width: 1.0,
radius: pill.radius,
},
Shadow::default(),
)
}
Variant::Elevated => {
let (bg, fg) = face(s.surface_container_high, s.primary, surface, state);
(bg, fg, pill, crate::m3::Elevation::Level1.shadow())
}
}
}
pub fn button_style(
tok: Tokens,
variant: Variant,
) -> impl Fn(&iced::Theme, button::Status) -> button::Style {
move |_theme, status| {
let state = button_status(status);
let (bg, fg, border, shadow) = button_face(tok, variant, state);
button::Style {
background: Some(Background::Color(bg)),
text_color: fg,
border,
shadow,
snap: false,
}
}
}
pub fn tab_style(
tok: Tokens,
active: bool,
) -> impl Fn(&iced::Theme, button::Status) -> button::Style {
move |_theme, status| {
let s = tok.scheme();
let state = button_status(status);
let bg = match (active, state) {
(true, _) => Some(Background::Color(Color::TRANSPARENT)),
(false, ControlState::Hovered | ControlState::Pressed) => {
Some(Background::Color(hover_fill(tok)))
}
_ => Some(Background::Color(Color::TRANSPARENT)),
};
button::Style {
background: bg,
text_color: if active {
s.primary
} else {
s.on_surface_variant
},
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(Component::Tab),
},
shadow: Shadow::default(),
snap: false,
}
}
}
pub fn tab_indicator(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(s.primary)),
snap: false,
..container::Style::default()
}
}
pub fn dialog_sheet_face(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(Elevation::Level3.surface(s))),
text_color: Some(s.on_surface),
border: Border {
color: s.outline_variant,
width: 0.0,
radius: component_radius(Component::Dialog),
},
shadow: Elevation::Level3.shadow(),
snap: false,
}
}
pub fn app_bar(tok: Tokens) -> container::Style {
let s = tok.scheme();
container::Style {
background: Some(Background::Color(s.surface_container)),
text_color: Some(s.on_surface),
border: Border {
color: s.outline_variant,
width: 0.0,
radius: component_radius(Component::AppBar),
},
shadow: Elevation::Level0.shadow(),
snap: false,
}
}
pub fn nav_rail(tok: Tokens, selected: bool) -> container::Style {
let s = tok.scheme();
if selected {
fill(s.secondary_container, s.on_secondary_container)
} else {
fill(Color::TRANSPARENT, s.on_surface_variant)
}
}
pub fn field_style(
tok: Tokens,
outlined: bool,
) -> impl Fn(&iced::Theme, text_input::Status) -> text_input::Style {
move |_theme, status| {
let s = tok.scheme();
let (border_color, width) = match status {
text_input::Status::Focused { .. } => (s.primary, 2.0),
text_input::Status::Hovered => (s.on_surface, 1.0),
text_input::Status::Disabled => (s.on_surface.scale_alpha(0.12), 1.0),
text_input::Status::Active => (s.outline, 1.0),
};
let bg = if outlined {
Color::TRANSPARENT
} else {
match status {
text_input::Status::Disabled => layer_on(s.surface, s.on_surface, 0.04),
_ => s.surface_container_highest,
}
};
text_input::Style {
background: Background::Color(bg),
border: Border {
color: border_color,
width,
radius: component_radius(Component::Field),
},
icon: s.on_surface_variant,
placeholder: s.on_surface_variant,
value: match status {
text_input::Status::Disabled => layer_on(s.surface, s.on_surface, 0.38),
_ => s.on_surface,
},
selection: s.secondary_container,
}
}
}
pub fn search_style(tok: Tokens) -> impl Fn(&iced::Theme, text_input::Status) -> text_input::Style {
move |_theme, status| {
let s = tok.scheme();
let (border_color, width) = match status {
text_input::Status::Focused { .. } => (s.primary, 2.0),
text_input::Status::Hovered => (s.on_surface, 1.0),
text_input::Status::Disabled => (s.on_surface.scale_alpha(0.12), 1.0),
text_input::Status::Active => (s.outline, 1.0),
};
let bg = match status {
text_input::Status::Disabled => layer_on(s.surface, s.on_surface, 0.04),
_ => s.surface_container_highest,
};
text_input::Style {
background: Background::Color(bg),
border: Border {
color: border_color,
width,
radius: component_radius(Component::Field),
},
icon: s.on_surface_variant,
placeholder: s.on_surface_variant,
value: match status {
text_input::Status::Disabled => layer_on(s.surface, s.on_surface, 0.38),
_ => s.on_surface,
},
selection: s.secondary_container,
}
}
}
pub fn picker_style(tok: Tokens) -> impl Fn(&iced::Theme, pick_list::Status) -> pick_list::Style {
move |_theme, status| {
let s = tok.scheme();
let hot = !matches!(status, pick_list::Status::Active);
pick_list::Style {
text_color: s.on_surface,
placeholder_color: s.on_surface_variant,
handle_color: s.on_surface_variant,
background: Background::Color(s.surface_container_highest),
border: Border {
color: if hot { s.primary } else { s.outline },
width: if hot { 2.0 } else { 1.0 },
radius: component_radius(Component::Field),
},
}
}
}
pub fn overlay_menu_style(tok: Tokens) -> impl Fn(&iced::Theme) -> overlay_menu::Style {
move |_theme| {
let s = tok.scheme();
overlay_menu::Style {
background: Background::Color(s.surface_container),
border: Border {
width: 1.0,
radius: component_radius(Component::Field),
color: s.outline_variant,
},
text_color: s.on_surface,
selected_text_color: s.on_secondary_container,
selected_background: Background::Color(s.secondary_container),
shadow: Elevation::Level2.shadow(),
}
}
}
pub fn checkbox_style(tok: Tokens) -> impl Fn(&iced::Theme, checkbox::Status) -> checkbox::Style {
move |_theme, status| {
let s = tok.scheme();
let (checked, disabled, hovered) = match status {
checkbox::Status::Active { is_checked } => (is_checked, false, false),
checkbox::Status::Hovered { is_checked } => (is_checked, false, true),
checkbox::Status::Disabled { is_checked } => (is_checked, true, false),
};
let (bg, border_c, icon) = if disabled {
(
layer_on(s.surface, s.on_surface, 0.12),
layer_on(s.surface, s.on_surface, 0.38),
s.surface,
)
} else if checked {
let base = s.primary;
let bg = if hovered {
layer_on(base, s.on_primary, 0.08)
} else {
base
};
(bg, s.primary, s.on_primary)
} else {
let bg = if hovered {
layer_on(s.surface, s.on_surface, 0.08)
} else {
s.surface_container_highest
};
(bg, s.outline, s.on_primary)
};
checkbox::Style {
background: Background::Color(bg),
icon_color: icon,
border: Border {
color: border_c,
width: 2.0,
radius: component_radius(Component::Field),
},
text_color: Some(if disabled {
layer_on(s.surface, s.on_surface, 0.38)
} else {
s.on_surface
}),
}
}
}
pub fn radio_style(tok: Tokens) -> impl Fn(&iced::Theme, radio::Status) -> radio::Style {
move |_theme, status| {
let s = tok.scheme();
let (selected, hovered) = match status {
radio::Status::Active { is_selected } => (is_selected, false),
radio::Status::Hovered { is_selected } => (is_selected, true),
};
let bg = if hovered {
layer_on(s.surface, s.primary, 0.08)
} else {
s.surface_container_highest
};
radio::Style {
background: Background::Color(bg),
dot_color: if selected {
s.primary
} else {
Color::TRANSPARENT
},
border_width: 2.0,
border_color: if selected { s.primary } else { s.outline },
text_color: Some(s.on_surface),
}
}
}
pub fn switch_style(tok: Tokens) -> impl Fn(&iced::Theme, toggler::Status) -> toggler::Style {
move |_theme, status| {
let s = tok.scheme();
let (on, disabled, hovered) = match status {
toggler::Status::Active { is_toggled } => (is_toggled, false, false),
toggler::Status::Hovered { is_toggled } => (is_toggled, false, true),
toggler::Status::Disabled { is_toggled } => (is_toggled, true, false),
};
let track = if disabled {
layer_on(s.surface, s.on_surface, 0.12)
} else if on {
let base = s.primary;
if hovered {
layer_on(base, s.on_primary, 0.08)
} else {
base
}
} else {
let base = s.surface_container_highest;
if hovered {
layer_on(base, s.on_surface, 0.08)
} else {
base
}
};
let thumb = if disabled {
layer_on(s.surface, s.on_surface, 0.38)
} else if on {
s.on_primary
} else {
s.outline
};
toggler::Style {
background: Background::Color(track),
background_border_width: if on { 0.0 } else { 2.0 },
background_border_color: if on { Color::TRANSPARENT } else { s.outline },
foreground: Background::Color(thumb),
foreground_border_width: 0.0,
foreground_border_color: Color::TRANSPARENT,
text_color: Some(s.on_surface),
border_radius: Some(component_radius(Component::Button)),
padding_ratio: 0.2,
}
}
}
pub fn slider_style(tok: Tokens) -> impl Fn(&iced::Theme, slider::Status) -> slider::Style {
move |_theme, status| {
let s = tok.scheme();
let handle_r = match status {
slider::Status::Active => 10.0,
slider::Status::Hovered | slider::Status::Dragged => 12.0,
};
slider::Style {
rail: slider::Rail {
backgrounds: (
Background::Color(s.primary),
Background::Color(s.surface_container_highest),
),
width: 4.0,
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(Component::Button),
},
},
handle: slider::Handle {
shape: slider::HandleShape::Circle { radius: handle_r },
background: Background::Color(s.primary),
border_width: 0.0,
border_color: s.outline,
},
}
}
}
pub fn progress_style(tok: Tokens) -> impl Fn(&iced::Theme) -> progress_bar::Style {
move |_theme| {
let s = tok.scheme();
progress_bar::Style {
background: Background::Color(s.surface_container_highest),
bar: Background::Color(s.primary),
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(Component::Button),
},
}
}
}
pub fn rule_style(tok: Tokens) -> impl Fn(&iced::Theme) -> rule::Style {
move |_theme| {
let s = tok.scheme();
rule::Style {
color: s.outline_variant,
radius: component_radius(Component::Shell),
fill_mode: rule::FillMode::Full,
snap: false,
}
}
}
pub fn scroll_style(tok: Tokens) -> impl Fn(&iced::Theme, scrollable::Status) -> scrollable::Style {
move |_theme, _status| {
let s = tok.scheme();
let rail = scrollable::Rail {
background: Some(Background::Color(s.surface_container_low)),
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(Component::Button),
},
scroller: scrollable::Scroller {
background: Background::Color(s.outline),
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: component_radius(Component::Button),
},
},
};
scrollable::Style {
container: fill(Color::TRANSPARENT, s.on_surface),
vertical_rail: rail,
horizontal_rail: rail,
gap: None,
auto_scroll: scrollable::AutoScroll {
background: Background::Color(s.surface_container),
border: Border {
color: s.outline,
width: 1.0,
radius: component_radius(Component::Field),
},
shadow: Shadow::default(),
icon: s.on_surface,
},
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::theme::named;
use crate::toast::ToastKind;
#[test]
fn filled_button_uses_m3_primary_roles() {
let tok = named("light").tokens;
let s = tok.scheme();
let theme = crate::theme::iced_theme("light", tok);
let f = button_style(tok, Variant::Primary);
let active = f(&theme, button::Status::Active);
assert_eq!(active.background, Some(Background::Color(s.primary)));
assert_eq!(active.text_color, s.on_primary);
let disabled = f(&theme, button::Status::Disabled);
assert_ne!(disabled.background, Some(Background::Color(s.primary)));
let tonal = button_style(tok, Variant::Quiet)(&theme, button::Status::Active);
assert_eq!(
tonal.background,
Some(Background::Color(s.secondary_container))
);
assert_eq!(tonal.text_color, s.on_secondary_container);
let ghost = button_style(tok, Variant::Ghost)(&theme, button::Status::Active);
assert_eq!(
ghost.background,
Some(Background::Color(Color::TRANSPARENT))
);
assert_eq!(ghost.text_color, s.primary);
}
#[test]
fn list_row_selected_is_secondary_container() {
let tok = named("dark").tokens;
let s = tok.scheme();
let row = list_row(tok, true);
assert_eq!(
row.background,
Some(Background::Color(s.secondary_container))
);
assert_eq!(row.text_color, Some(s.on_secondary_container));
let idle = list_row(tok, false);
assert_eq!(idle.background, Some(Background::Color(Color::TRANSPARENT)));
let _ = list_row_hover(tok, true);
let _ = list_row_hover(tok, false);
}
#[test]
fn table_cell_faces_separate_selection_from_zebra() {
let tok = named("dark").tokens;
let s = tok.scheme();
let focused_sel = table_cell(tok, true, true, true);
assert_eq!(
focused_sel.background,
Some(Background::Color(s.secondary_container))
);
assert_eq!(focused_sel.border.color, s.primary);
assert!(focused_sel.border.width >= 2.0);
let selected = table_cell(tok, true, false, true);
assert_eq!(
selected.background,
Some(Background::Color(s.secondary_container))
);
assert_eq!(selected.text_color, Some(s.on_secondary_container));
assert_eq!(selected.border.width, 0.0);
let zebra = table_cell(tok, false, false, true);
assert_eq!(
zebra.background,
Some(Background::Color(s.surface_container_high))
);
assert_ne!(zebra.background, selected.background);
let idle = table_cell(tok, false, false, false);
assert_eq!(idle.background, Some(Background::Color(Color::TRANSPARENT)));
let focus_only = table_cell(tok, false, true, false);
assert_eq!(
focus_only.background,
Some(Background::Color(s.primary_container))
);
}
#[test]
fn text_field_focus_uses_primary_outline() {
let tok = named("light").tokens;
let s = tok.scheme();
let theme = crate::theme::iced_theme("light", tok);
let st = search_style(tok);
let focused = st(&theme, text_input::Status::Focused { is_hovered: false });
assert_eq!(focused.border.color, s.primary);
assert!(focused.border.width >= 2.0);
let active = st(&theme, text_input::Status::Active);
assert_eq!(active.border.color, s.outline);
}
#[test]
fn dialog_tabs_and_app_bar_use_m3_surfaces() {
let tok = named("dark").tokens;
let s = tok.scheme();
let theme = crate::theme::iced_theme("dark", tok);
let sheet = dialog_sheet_face(tok);
assert_eq!(
sheet.background,
Some(Background::Color(Elevation::Level3.surface(s)))
);
assert!(sheet.shadow.blur_radius > 0.0);
let bar = app_bar(tok);
assert_eq!(bar.background, Some(Background::Color(s.surface_container)));
let rail = nav_rail(tok, true);
assert_eq!(
rail.background,
Some(Background::Color(s.secondary_container))
);
let rail_idle = nav_rail(tok, false);
assert_eq!(
rail_idle.background,
Some(Background::Color(Color::TRANSPARENT))
);
let active = tab_style(tok, true)(&theme, button::Status::Active);
assert_eq!(active.text_color, s.primary);
assert_eq!(active.border.width, 0.0);
assert_eq!(active.border.color, Color::TRANSPARENT);
let bar = tab_indicator(tok);
assert_eq!(bar.background, Some(Background::Color(s.primary)));
let idle = tab_style(tok, false)(&theme, button::Status::Hovered);
assert_eq!(idle.text_color, s.on_surface_variant);
assert!(idle.background.is_some());
let idle_active = tab_style(tok, false)(&theme, button::Status::Active);
assert_eq!(idle_active.border.width, 0.0);
let pressed = tab_style(tok, false)(&theme, button::Status::Pressed);
assert!(pressed.background.is_some());
let sk = skeleton(tok);
assert!(sk.background.is_some());
assert_eq!(
crate::m3::shape::Component::Button.shape(),
crate::m3::shape::Shape::None
);
assert_eq!(
crate::m3::shape::Component::Field.shape(),
crate::m3::shape::Shape::None
);
assert_eq!(
card(tok, false).border.radius,
component_radius(crate::m3::shape::Component::Card)
);
assert_eq!(card(tok, false).border.radius, 0.0.into());
}
#[test]
fn switch_on_thumb_uses_scheme_on_primary() {
let tok = named("gruvbox").tokens;
let s = tok.scheme();
let theme = crate::theme::iced_theme("gruvbox", tok);
let st = switch_style(tok)(&theme, toggler::Status::Active { is_toggled: true });
assert_eq!(st.background, Background::Color(s.primary));
assert_eq!(st.foreground, Background::Color(s.on_primary));
assert_ne!(s.on_primary, crate::m3::scheme_dark().on_primary);
}
#[test]
fn styles_cover_states_and_variants() {
let tok = named("dark").tokens;
let theme = crate::theme::iced_theme("dark", tok);
let _ = fill(tok.canvas, tok.text);
let _ = card(tok, true);
let _ = card(tok, false);
let _ = raised_card(tok);
let _ = outlined_card(tok);
let _ = shell(tok);
let _ = panel(tok);
let _ = footer(tok);
let _ = hairline(tok);
let _ = dim_backdrop(tok);
let _ = dialog_sheet_face(tok);
let _ = app_bar(tok);
let _ = nav_rail(tok, true);
let _ = nav_rail(tok, false);
let _ = list_row(tok, true);
let _ = list_row(tok, false);
for k in [
ToastKind::Info,
ToastKind::Success,
ToastKind::Warning,
ToastKind::Danger,
] {
let _ = callout(tok, k);
}
let _ = skeleton(tok);
for v in Variant::ALL {
let f = button_style(tok, v);
for st in [
button::Status::Active,
button::Status::Hovered,
button::Status::Pressed,
button::Status::Disabled,
] {
let _ = f(&theme, st);
}
}
let tab = tab_style(tok, true);
let tab2 = tab_style(tok, false);
let _ = tab(&theme, button::Status::Active);
let _ = tab2(&theme, button::Status::Hovered);
let _ = tab2(&theme, button::Status::Active);
let outlined = field_style(tok, true);
let _ = outlined(&theme, text_input::Status::Active);
let _ = outlined(&theme, text_input::Status::Hovered);
let _ = outlined(&theme, text_input::Status::Focused { is_hovered: true });
let _ = outlined(&theme, text_input::Status::Disabled);
let filled = field_style(tok, false);
let _ = filled(&theme, text_input::Status::Disabled);
let _ = filled(&theme, text_input::Status::Active);
let s = search_style(tok);
let _ = s(&theme, text_input::Status::Active);
let _ = s(&theme, text_input::Status::Hovered);
let _ = s(&theme, text_input::Status::Focused { is_hovered: false });
let _ = s(&theme, text_input::Status::Disabled);
let p = picker_style(tok);
let _ = p(&theme, pick_list::Status::Active);
let _ = p(&theme, pick_list::Status::Hovered);
let _ = p(&theme, pick_list::Status::Opened { is_hovered: true });
let _ = overlay_menu_style(tok)(&theme);
let c = checkbox_style(tok);
let _ = c(&theme, checkbox::Status::Active { is_checked: true });
let _ = c(&theme, checkbox::Status::Active { is_checked: false });
let _ = c(&theme, checkbox::Status::Hovered { is_checked: true });
let _ = c(&theme, checkbox::Status::Hovered { is_checked: false });
let _ = c(&theme, checkbox::Status::Disabled { is_checked: true });
let r = radio_style(tok);
let _ = r(&theme, radio::Status::Active { is_selected: true });
let _ = r(&theme, radio::Status::Hovered { is_selected: false });
let sw = switch_style(tok);
let _ = sw(&theme, toggler::Status::Active { is_toggled: true });
let _ = sw(&theme, toggler::Status::Active { is_toggled: false });
let _ = sw(&theme, toggler::Status::Hovered { is_toggled: true });
let _ = sw(&theme, toggler::Status::Hovered { is_toggled: false });
let _ = sw(&theme, toggler::Status::Disabled { is_toggled: true });
let _ = sw(&theme, toggler::Status::Disabled { is_toggled: false });
let sl = slider_style(tok);
let _ = sl(&theme, slider::Status::Active);
let _ = sl(&theme, slider::Status::Hovered);
let _ = sl(&theme, slider::Status::Dragged);
let _ = progress_style(tok)(&theme);
let _ = rule_style(tok)(&theme);
let sc = scroll_style(tok);
let _ = sc(
&theme,
scrollable::Status::Active {
is_horizontal_scrollbar_disabled: false,
is_vertical_scrollbar_disabled: false,
},
);
let _ = sc(
&theme,
scrollable::Status::Hovered {
is_horizontal_scrollbar_hovered: true,
is_vertical_scrollbar_hovered: false,
is_horizontal_scrollbar_disabled: false,
is_vertical_scrollbar_disabled: false,
},
);
let _ = sc(
&theme,
scrollable::Status::Dragged {
is_horizontal_scrollbar_dragged: true,
is_vertical_scrollbar_dragged: false,
is_horizontal_scrollbar_disabled: false,
is_vertical_scrollbar_disabled: true,
},
);
}
}