Fix inconsistent styling for toggler and checkbox
This commit is contained in:
parent
ff27f24781
commit
d897ccd49e
2 changed files with 13 additions and 28 deletions
|
|
@ -556,21 +556,18 @@ pub fn primary(theme: &Theme, status: Status) -> Style {
|
|||
|
||||
match status {
|
||||
Status::Active { is_checked } => styled(
|
||||
palette.primary.strong.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.base,
|
||||
palette.primary.base,
|
||||
is_checked,
|
||||
),
|
||||
Status::Hovered { is_checked } => styled(
|
||||
palette.primary.strong.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.weak,
|
||||
palette.primary.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.primary.strong.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.background.strong,
|
||||
|
|
@ -585,21 +582,18 @@ pub fn secondary(theme: &Theme, status: Status) -> Style {
|
|||
|
||||
match status {
|
||||
Status::Active { is_checked } => styled(
|
||||
palette.background.base.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.base,
|
||||
palette.background.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Hovered { is_checked } => styled(
|
||||
palette.background.base.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.weak,
|
||||
palette.background.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.background.strong.color,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.background.weak,
|
||||
|
|
@ -614,21 +608,18 @@ pub fn success(theme: &Theme, status: Status) -> Style {
|
|||
|
||||
match status {
|
||||
Status::Active { is_checked } => styled(
|
||||
palette.success.base.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.base,
|
||||
palette.success.base,
|
||||
is_checked,
|
||||
),
|
||||
Status::Hovered { is_checked } => styled(
|
||||
palette.success.base.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.weak,
|
||||
palette.success.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.success.base.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.success.weak,
|
||||
|
|
@ -643,21 +634,18 @@ pub fn danger(theme: &Theme, status: Status) -> Style {
|
|||
|
||||
match status {
|
||||
Status::Active { is_checked } => styled(
|
||||
palette.danger.base.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.base,
|
||||
palette.danger.base,
|
||||
is_checked,
|
||||
),
|
||||
Status::Hovered { is_checked } => styled(
|
||||
palette.danger.base.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.weak,
|
||||
palette.danger.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.danger.base.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.danger.weak,
|
||||
|
|
@ -667,27 +655,24 @@ pub fn danger(theme: &Theme, status: Status) -> Style {
|
|||
}
|
||||
|
||||
fn styled(
|
||||
icon_color: Color,
|
||||
border_color: Color,
|
||||
base: palette::Pair,
|
||||
accent: palette::Pair,
|
||||
is_checked: bool,
|
||||
) -> Style {
|
||||
let (background, border) = if is_checked {
|
||||
(accent, accent.color)
|
||||
} else {
|
||||
(base, border_color)
|
||||
};
|
||||
|
||||
Style {
|
||||
background: Background::Color(if is_checked {
|
||||
accent.color
|
||||
} else {
|
||||
base.color
|
||||
}),
|
||||
icon_color,
|
||||
background: Background::Color(background.color),
|
||||
icon_color: background.text,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: if is_checked {
|
||||
accent.color
|
||||
} else {
|
||||
border_color
|
||||
},
|
||||
color: border,
|
||||
},
|
||||
text_color: None,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -557,9 +557,9 @@ pub fn default(theme: &Theme, status: Status) -> Style {
|
|||
let background = match status {
|
||||
Status::Active { is_toggled } | Status::Hovered { is_toggled } => {
|
||||
if is_toggled {
|
||||
palette.primary.strong.color
|
||||
palette.primary.base.color
|
||||
} else {
|
||||
palette.background.strong.color
|
||||
palette.background.strongest.color
|
||||
}
|
||||
}
|
||||
Status::Disabled => palette.background.weak.color,
|
||||
|
|
@ -568,7 +568,7 @@ pub fn default(theme: &Theme, status: Status) -> Style {
|
|||
let foreground = match status {
|
||||
Status::Active { is_toggled } => {
|
||||
if is_toggled {
|
||||
palette.primary.strong.text
|
||||
palette.primary.base.text
|
||||
} else {
|
||||
palette.background.base.color
|
||||
}
|
||||
|
|
@ -577,7 +577,7 @@ pub fn default(theme: &Theme, status: Status) -> Style {
|
|||
if is_toggled {
|
||||
Color {
|
||||
a: 0.5,
|
||||
..palette.primary.strong.text
|
||||
..palette.primary.base.text
|
||||
}
|
||||
} else {
|
||||
palette.background.weak.color
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue