Add weakest and strongest to Background palette
... and tweak background shade generation logic.
This commit is contained in:
parent
f1ed99cb47
commit
954f49d4d7
8 changed files with 76 additions and 31 deletions
|
|
@ -591,12 +591,12 @@ impl Catalog for Theme {
|
|||
/// A primary button; denoting a main action.
|
||||
pub fn primary(theme: &Theme, status: Status) -> Style {
|
||||
let palette = theme.extended_palette();
|
||||
let base = styled(palette.primary.strong);
|
||||
let base = styled(palette.primary.base);
|
||||
|
||||
match status {
|
||||
Status::Active | Status::Pressed => base,
|
||||
Status::Hovered => Style {
|
||||
background: Some(Background::Color(palette.primary.base.color)),
|
||||
background: Some(Background::Color(palette.primary.strong.color)),
|
||||
..base
|
||||
},
|
||||
Status::Disabled => disabled(base),
|
||||
|
|
|
|||
|
|
@ -555,18 +555,21 @@ 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.strong,
|
||||
palette.primary.base,
|
||||
is_checked,
|
||||
),
|
||||
Status::Hovered { is_checked } => styled(
|
||||
palette.primary.strong.text,
|
||||
palette.background.strongest.color,
|
||||
palette.background.weak,
|
||||
palette.primary.base,
|
||||
palette.primary.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.primary.strong.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.background.strong,
|
||||
is_checked,
|
||||
|
|
@ -581,18 +584,21 @@ 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,
|
||||
is_checked,
|
||||
|
|
@ -607,18 +613,21 @@ 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.base,
|
||||
palette.success.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.success.base.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.success.weak,
|
||||
is_checked,
|
||||
|
|
@ -633,18 +642,21 @@ 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.base,
|
||||
palette.danger.strong,
|
||||
is_checked,
|
||||
),
|
||||
Status::Disabled { is_checked } => styled(
|
||||
palette.danger.base.text,
|
||||
palette.background.weak.color,
|
||||
palette.background.weak,
|
||||
palette.danger.weak,
|
||||
is_checked,
|
||||
|
|
@ -654,6 +666,7 @@ 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,
|
||||
|
|
@ -668,7 +681,11 @@ fn styled(
|
|||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: accent.color,
|
||||
color: if is_checked {
|
||||
accent.color
|
||||
} else {
|
||||
border_color
|
||||
},
|
||||
},
|
||||
text_color: None,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -703,10 +703,10 @@ pub fn bordered_box(theme: &Theme) -> Style {
|
|||
let palette = theme.extended_palette();
|
||||
|
||||
Style {
|
||||
background: Some(palette.background.weak.color.into()),
|
||||
background: Some(palette.background.weakest.color.into()),
|
||||
border: Border {
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
radius: 5.0.into(),
|
||||
color: palette.background.strong.color,
|
||||
},
|
||||
..Style::default()
|
||||
|
|
|
|||
|
|
@ -288,10 +288,7 @@ impl Catalog for Theme {
|
|||
pub fn primary(theme: &Theme) -> Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(
|
||||
palette.background.strong.color,
|
||||
palette.primary.strong.color,
|
||||
)
|
||||
styled(palette.background.strong.color, palette.primary.base.color)
|
||||
}
|
||||
|
||||
/// The secondary style of a [`ProgressBar`].
|
||||
|
|
|
|||
|
|
@ -670,14 +670,14 @@ pub fn default(theme: &Theme, status: Status) -> Style {
|
|||
let palette = theme.extended_palette();
|
||||
|
||||
let color = match status {
|
||||
Status::Active => palette.primary.strong.color,
|
||||
Status::Hovered => palette.primary.base.color,
|
||||
Status::Dragged => palette.primary.strong.color,
|
||||
Status::Active => palette.primary.base.color,
|
||||
Status::Hovered => palette.primary.strong.color,
|
||||
Status::Dragged => palette.primary.weak.color,
|
||||
};
|
||||
|
||||
Style {
|
||||
rail: Rail {
|
||||
backgrounds: (color.into(), palette.secondary.base.color.into()),
|
||||
backgrounds: (color.into(), palette.background.strong.color.into()),
|
||||
width: 4.0,
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
|
|
|
|||
|
|
@ -1802,10 +1802,10 @@ pub fn default(theme: &Theme, status: Status) -> Style {
|
|||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: palette.background.strong.color,
|
||||
color: palette.background.strongest.color,
|
||||
},
|
||||
icon: palette.background.weak.text,
|
||||
placeholder: palette.background.strong.color,
|
||||
placeholder: palette.background.strongest.color,
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.weak.color,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue