Tweak styling of Slider and improve contrast of Background
This commit is contained in:
parent
822a3cd04f
commit
5a39dad506
2 changed files with 16 additions and 18 deletions
|
|
@ -31,7 +31,7 @@ impl Theme {
|
||||||
|
|
||||||
impl Default for Theme {
|
impl Default for Theme {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Dark
|
Self::Light
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,10 +145,10 @@ impl slider::StyleSheet for Theme {
|
||||||
};
|
};
|
||||||
|
|
||||||
slider::Style {
|
slider::Style {
|
||||||
rail_colors: (palette.background.strong, palette.background.base),
|
rail_colors: (palette.primary.base, palette.background.base),
|
||||||
handle: slider::Handle {
|
handle: slider::Handle {
|
||||||
color: palette.background.base,
|
color: palette.background.base,
|
||||||
border_color: palette.border,
|
border_color: palette.primary.base,
|
||||||
..handle
|
..handle
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +160,7 @@ impl slider::StyleSheet for Theme {
|
||||||
|
|
||||||
slider::Style {
|
slider::Style {
|
||||||
handle: slider::Handle {
|
handle: slider::Handle {
|
||||||
color: palette.background.weak,
|
color: palette.primary.weak,
|
||||||
..active.handle
|
..active.handle
|
||||||
},
|
},
|
||||||
..active
|
..active
|
||||||
|
|
@ -173,7 +173,7 @@ impl slider::StyleSheet for Theme {
|
||||||
|
|
||||||
slider::Style {
|
slider::Style {
|
||||||
handle: slider::Handle {
|
handle: slider::Handle {
|
||||||
color: palette.background.strong,
|
color: palette.primary.base,
|
||||||
..active.handle
|
..active.handle
|
||||||
},
|
},
|
||||||
..active
|
..active
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ pub struct Extended {
|
||||||
pub primary: Group,
|
pub primary: Group,
|
||||||
pub success: Group,
|
pub success: Group,
|
||||||
pub danger: Group,
|
pub danger: Group,
|
||||||
pub border: Color,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
@ -91,7 +90,6 @@ impl Extended {
|
||||||
palette.background,
|
palette.background,
|
||||||
palette.text,
|
palette.text,
|
||||||
),
|
),
|
||||||
border: mix(palette.background, palette.text, 0.7),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,8 +105,8 @@ impl Background {
|
||||||
pub fn new(base: Color, text: Color) -> Self {
|
pub fn new(base: Color, text: Color) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base,
|
base,
|
||||||
weak: muted(base, 0.1),
|
weak: mix(base, text, 0.15),
|
||||||
strong: muted(base, 0.2),
|
strong: mix(base, text, 0.25),
|
||||||
text,
|
text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +140,7 @@ fn muted(color: Color, amount: f32) -> Color {
|
||||||
let mut hsl = to_hsl(color);
|
let mut hsl = to_hsl(color);
|
||||||
|
|
||||||
hsl.lightness = if is_dark(color) {
|
hsl.lightness = if is_dark(color) {
|
||||||
let delta = amount * (1.0 - hsl.lightness).powi(7);
|
let delta = amount * (1.0 - hsl.lightness).powi(5);
|
||||||
hsl.lightness + delta
|
hsl.lightness + delta
|
||||||
} else {
|
} else {
|
||||||
let delta = amount * hsl.lightness.powi(5);
|
let delta = amount * hsl.lightness.powi(5);
|
||||||
|
|
@ -164,14 +162,6 @@ fn darken(color: Color, amount: f32) -> Color {
|
||||||
from_hsl(hsl)
|
from_hsl(hsl)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mix(a: Color, b: Color, factor: f32) -> Color {
|
|
||||||
let a_lin = Srgb::from(a).into_linear();
|
|
||||||
let b_lin = Srgb::from(b).into_linear();
|
|
||||||
|
|
||||||
let mixed = a_lin.mix(&b_lin, factor);
|
|
||||||
Srgb::from_linear(mixed).into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lighten(color: Color, amount: f32) -> Color {
|
fn lighten(color: Color, amount: f32) -> Color {
|
||||||
let mut hsl = to_hsl(color);
|
let mut hsl = to_hsl(color);
|
||||||
|
|
||||||
|
|
@ -184,6 +174,14 @@ fn lighten(color: Color, amount: f32) -> Color {
|
||||||
from_hsl(hsl)
|
from_hsl(hsl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mix(a: Color, b: Color, factor: f32) -> Color {
|
||||||
|
let a_lin = Srgb::from(a).into_linear();
|
||||||
|
let b_lin = Srgb::from(b).into_linear();
|
||||||
|
|
||||||
|
let mixed = a_lin.mix(&b_lin, factor);
|
||||||
|
Srgb::from_linear(mixed).into()
|
||||||
|
}
|
||||||
|
|
||||||
fn readable(background: Color, text: Color) -> Color {
|
fn readable(background: Color, text: Color) -> Color {
|
||||||
if is_readable(background, text) {
|
if is_readable(background, text) {
|
||||||
text
|
text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue