Skip to content

Commit 8c4cb2e

Browse files
wash2mmstick
authored andcommitted
chore: theme color updates
1 parent b8eaad2 commit 8c4cb2e

File tree

8 files changed

+84
-56
lines changed

8 files changed

+84
-56
lines changed

cosmic-theme/src/model/theme.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ impl ThemeBuilder {
12771277
let mut component = Component::component(
12781278
Srgba::new(0.0, 0.0, 0.0, 0.0),
12791279
accent,
1280-
accent,
1280+
accent_text.unwrap_or(accent),
12811281
Srgba::new(0.0, 0.0, 0.0, 0.0),
12821282
Srgba::new(0.0, 0.0, 0.0, 0.0),
12831283
is_high_contrast,
@@ -1305,7 +1305,7 @@ impl ThemeBuilder {
13051305
text_button: Component::component(
13061306
Srgba::new(0.0, 0.0, 0.0, 0.0),
13071307
accent,
1308-
accent,
1308+
accent_text.unwrap_or(accent),
13091309
button_hovered_overlay,
13101310
button_pressed_overlay,
13111311
is_high_contrast,

src/theme/style/button.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn appearance(
9999

100100
Button::Image => {
101101
appearance.background = None;
102-
appearance.text_color = Some(cosmic.accent.base.into());
102+
appearance.text_color = Some(cosmic.accent_text_color().into());
103103
appearance.icon_color = Some(cosmic.accent.base.into());
104104

105105
corner_radii = &cosmic.corner_radii.radius_s;
@@ -119,7 +119,7 @@ pub fn appearance(
119119
Button::Link => {
120120
appearance.background = None;
121121
appearance.icon_color = Some(cosmic.accent.base.into());
122-
appearance.text_color = Some(cosmic.accent.base.into());
122+
appearance.text_color = Some(cosmic.accent_text_color().into());
123123
corner_radii = &cosmic.corner_radii.radius_0;
124124
}
125125

@@ -156,7 +156,7 @@ pub fn appearance(
156156
appearance.background =
157157
Some(Background::Color(cosmic.primary.component.hover.into()));
158158
appearance.icon_color = Some(cosmic.accent.base.into());
159-
appearance.text_color = Some(cosmic.accent.base.into());
159+
appearance.text_color = Some(cosmic.accent_text_color().into());
160160
} else {
161161
appearance.background = Some(Background::Color(background));
162162
appearance.icon_color = icon;
@@ -203,7 +203,7 @@ impl Catalog for crate::Theme {
203203
Button::Icon | Button::IconVertical | Button::HeaderBar
204204
) && selected
205205
{
206-
Some(self.cosmic().accent_color().into())
206+
Some(self.cosmic().accent_text_color().into())
207207
} else {
208208
Some(component.on.into())
209209
};
@@ -249,7 +249,7 @@ impl Catalog for crate::Theme {
249249
Button::Icon | Button::IconVertical | Button::HeaderBar
250250
) && selected
251251
{
252-
Some(self.cosmic().accent_color().into())
252+
Some(self.cosmic().accent_text_color().into())
253253
} else {
254254
Some(component.on.into())
255255
};
@@ -270,7 +270,7 @@ impl Catalog for crate::Theme {
270270
Button::Icon | Button::IconVertical | Button::HeaderBar
271271
) && selected
272272
{
273-
Some(self.cosmic().accent_color().into())
273+
Some(self.cosmic().accent_text_color().into())
274274
} else {
275275
Some(component.on.into())
276276
};

src/theme/style/dropdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl dropdown::menu::StyleSheet for Theme {
2121
hovered_text_color: cosmic.on_bg_color().into(),
2222
hovered_background: Background::Color(cosmic.primary.component.hover.into()),
2323

24-
selected_text_color: cosmic.accent.base.into(),
24+
selected_text_color: cosmic.accent_text_color().into(),
2525
selected_background: Background::Color(cosmic.primary.component.hover.into()),
2626

2727
description_color: cosmic.primary.component.on_disabled.into(),

src/theme/style/iced.rs

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ impl Button {
156156
Self::Positive => &cosmic.success_button,
157157
Self::Destructive => &cosmic.destructive_button,
158158
Self::Text => &cosmic.text_button,
159-
Self::Link => &cosmic.accent_button,
160-
Self::LinkActive => &cosmic.accent_button,
159+
Self::Link => &cosmic.link_button,
160+
Self::LinkActive => &cosmic.link_button,
161161
Self::Transparent => &TRANSPARENT_COMPONENT,
162162
Self::Deactivated => &theme.current_container().component,
163163
Self::Card => &theme.current_container().component,
@@ -190,6 +190,7 @@ impl iced_checkbox::Catalog for Theme {
190190
Checkbox::default()
191191
}
192192

193+
#[allow(clippy::too_many_lines)]
193194
fn style(
194195
&self,
195196
class: &Self::Class<'_>,
@@ -208,7 +209,7 @@ impl iced_checkbox::Catalog for Theme {
208209
background: Background::Color(if is_checked {
209210
cosmic.accent.base.into()
210211
} else {
211-
cosmic.button.base.into()
212+
cosmic.background.small_widget.into()
212213
}),
213214
icon_color: cosmic.accent.on.into(),
214215
border: Border {
@@ -217,7 +218,7 @@ impl iced_checkbox::Catalog for Theme {
217218
color: if is_checked {
218219
cosmic.accent.base
219220
} else {
220-
cosmic.button.border
221+
cosmic.palette.neutral_8
221222
}
222223
.into(),
223224
},
@@ -251,7 +252,7 @@ impl iced_checkbox::Catalog for Theme {
251252
color: if is_checked {
252253
cosmic.success.base
253254
} else {
254-
cosmic.button.border
255+
cosmic.palette.neutral_8
255256
}
256257
.into(),
257258
},
@@ -504,7 +505,7 @@ impl iced_container::Catalog for Theme {
504505
Container::HeaderBar { focused } => {
505506
let (icon_color, text_color) = if *focused {
506507
(
507-
Color::from(cosmic.accent.base),
508+
Color::from(cosmic.accent_text_color()),
508509
Color::from(cosmic.background.on),
509510
)
510511
} else {
@@ -667,9 +668,9 @@ impl slider::Catalog for Theme {
667668
(
668669
cosmic.accent_text_color(),
669670
if is_dark {
670-
cosmic.palette.neutral_6
671+
cosmic.palette.neutral_5
671672
} else {
672-
cosmic.palette.neutral_4
673+
cosmic.palette.neutral_3
673674
},
674675
)
675676
} else {
@@ -828,24 +829,22 @@ impl radio::Catalog for Theme {
828829
Color::from(theme.accent.base).into()
829830
} else {
830831
// TODO: this seems to be defined weirdly in FIGMA
831-
Color::from(theme.background.base).into()
832+
Color::from(theme.background.small_widget).into()
832833
},
833834
dot_color: theme.accent.on.into(),
834835
border_width: 1.0,
835836
border_color: if is_selected {
836837
Color::from(theme.accent.base)
837838
} else {
838-
// TODO: this seems to be defined weirdly in FIGMA
839-
Color::from(theme.palette.neutral_7)
839+
Color::from(theme.palette.neutral_8)
840840
},
841841
text_color: None,
842842
},
843843
radio::Status::Hovered { is_selected } => radio::Style {
844844
background: if is_selected {
845845
Color::from(theme.accent.base).into()
846846
} else {
847-
// TODO: this seems to be defined weirdly in FIGMA
848-
Color::from(theme.palette.neutral_10.with_alpha(0.1)).into()
847+
Color::from(theme.background.small_widget.with_alpha(0.2)).into()
849848
},
850849
dot_color: theme.accent.on.into(),
851850
border_width: 1.0,
@@ -878,7 +877,11 @@ impl toggler::Catalog for Theme {
878877
background: if matches!(status, toggler::Status::Active { is_toggled: true }) {
879878
cosmic.accent.base.into()
880879
} else {
881-
cosmic.palette.neutral_5.into()
880+
if cosmic.is_dark {
881+
cosmic.palette.neutral_6.into()
882+
} else {
883+
cosmic.palette.neutral_5.into()
884+
}
882885
},
883886
foreground: cosmic.palette.neutral_2.into(),
884887
border_radius: cosmic.radius_xl().into(),
@@ -900,7 +903,14 @@ impl toggler::Catalog for Theme {
900903
background: if is_active {
901904
over(neutral_10, cosmic.accent_color())
902905
} else {
903-
over(neutral_10, cosmic.palette.neutral_5)
906+
over(
907+
neutral_10,
908+
if cosmic.is_dark {
909+
cosmic.palette.neutral_6
910+
} else {
911+
cosmic.palette.neutral_5
912+
},
913+
)
904914
}
905915
.into(),
906916
..active
@@ -1092,7 +1102,8 @@ impl scrollable::Catalog for Theme {
10921102
match status {
10931103
scrollable::Status::Active => {
10941104
let cosmic = self.cosmic();
1095-
let neutral_5 = cosmic.palette.neutral_5.with_alpha(0.7);
1105+
let mut neutral_5 = cosmic.palette.neutral_5.with_alpha(0.7);
1106+
let mut neutral_6 = cosmic.palette.neutral_6.with_alpha(0.7);
10961107
let mut a = scrollable::Style {
10971108
container: iced_container::transparent(self),
10981109
vertical_rail: scrollable::Rail {
@@ -1102,7 +1113,11 @@ impl scrollable::Catalog for Theme {
11021113
},
11031114
background: None,
11041115
scroller: scrollable::Scroller {
1105-
color: neutral_5.into(),
1116+
color: if cosmic.is_dark {
1117+
neutral_6.into()
1118+
} else {
1119+
neutral_5.into()
1120+
},
11061121
border: Border {
11071122
radius: cosmic.corner_radii.radius_s.into(),
11081123
..Default::default()
@@ -1116,7 +1131,11 @@ impl scrollable::Catalog for Theme {
11161131
},
11171132
background: None,
11181133
scroller: scrollable::Scroller {
1119-
color: neutral_5.into(),
1134+
color: if cosmic.is_dark {
1135+
neutral_6.into()
1136+
} else {
1137+
neutral_5.into()
1138+
},
11201139
border: Border {
11211140
radius: cosmic.corner_radii.radius_s.into(),
11221141
..Default::default()
@@ -1137,9 +1156,9 @@ impl scrollable::Catalog for Theme {
11371156
// TODO handle vertical / horizontal
11381157
scrollable::Status::Hovered { .. } | scrollable::Status::Dragged { .. } => {
11391158
let cosmic = self.cosmic();
1140-
let neutral_5 = cosmic.palette.neutral_5.with_alpha(0.7);
1141-
1142-
// TODO hover
1159+
let mut neutral_5 = cosmic.palette.neutral_5.with_alpha(0.7);
1160+
let mut neutral_6 = cosmic.palette.neutral_6.with_alpha(0.7);
1161+
let mut neutral_3 = cosmic.palette.neutral_3;
11431162

11441163
// if is_mouse_over_scrollbar {
11451164
// let hover_overlay = cosmic.palette.neutral_0.with_alpha(0.2);
@@ -1154,7 +1173,11 @@ impl scrollable::Catalog for Theme {
11541173
},
11551174
background: None,
11561175
scroller: scrollable::Scroller {
1157-
color: neutral_5.into(),
1176+
color: if cosmic.is_dark {
1177+
neutral_6.into()
1178+
} else {
1179+
neutral_5.into()
1180+
},
11581181
border: Border {
11591182
radius: cosmic.corner_radii.radius_s.into(),
11601183
..Default::default()
@@ -1168,7 +1191,11 @@ impl scrollable::Catalog for Theme {
11681191
},
11691192
background: None,
11701193
scroller: scrollable::Scroller {
1171-
color: neutral_5.into(),
1194+
color: if cosmic.is_dark {
1195+
neutral_6.into()
1196+
} else {
1197+
neutral_5.into()
1198+
},
11721199
border: Border {
11731200
radius: cosmic.corner_radii.radius_s.into(),
11741201
..Default::default()
@@ -1179,9 +1206,13 @@ impl scrollable::Catalog for Theme {
11791206
};
11801207

11811208
if matches!(class, Scrollable::Permanent) {
1182-
let neutral_3 = cosmic.palette.neutral_3.with_alpha(0.7);
1183-
a.horizontal_rail.background = Some(Background::Color(neutral_3.into()));
1184-
a.vertical_rail.background = Some(Background::Color(neutral_3.into()));
1209+
let small_widget_container =
1210+
cosmic.background.small_widget.clone().with_alpha(0.7);
1211+
1212+
a.horizontal_rail.background =
1213+
Some(Background::Color(small_widget_container.into()));
1214+
a.vertical_rail.background =
1215+
Some(Background::Color(small_widget_container.into()));
11851216
}
11861217

11871218
a
@@ -1250,7 +1281,7 @@ impl iced_widget::text::Catalog for Theme {
12501281
fn style(&self, class: &Self::Class<'_>) -> iced_widget::text::Style {
12511282
match class {
12521283
Text::Accent => iced_widget::text::Style {
1253-
color: Some(self.cosmic().accent.base.into()),
1284+
color: Some(self.cosmic().accent_text_color().into()),
12541285
},
12551286
Text::Default => iced_widget::text::Style { color: None },
12561287
Text::Color(c) => iced_widget::text::Style { color: Some(*c) },
@@ -1278,7 +1309,7 @@ impl text_input::Catalog for Theme {
12781309

12791310
fn style(&self, class: &Self::Class<'_>, status: text_input::Status) -> text_input::Style {
12801311
let palette = self.cosmic();
1281-
let bg = palette.palette.neutral_7.with_alpha(0.25);
1312+
let mut bg = palette.background.small_widget.with_alpha(0.25);
12821313

12831314
let neutral_9 = palette.palette.neutral_9;
12841315
let value = neutral_9.into();
@@ -1314,7 +1345,7 @@ impl text_input::Catalog for Theme {
13141345
match status {
13151346
text_input::Status::Active => appearance,
13161347
text_input::Status::Hovered => {
1317-
let bg = palette.palette.neutral_7.with_alpha(0.25);
1348+
let mut bg = palette.background.small_widget.with_alpha(0.25);
13181349

13191350
match class {
13201351
TextInput::Default => text_input::Style {
@@ -1343,7 +1374,7 @@ impl text_input::Catalog for Theme {
13431374
}
13441375
}
13451376
text_input::Status::Focused => {
1346-
let bg = palette.palette.neutral_7.with_alpha(0.25);
1377+
let mut bg = palette.background.small_widget.with_alpha(0.25);
13471378

13481379
match class {
13491380
TextInput::Default => text_input::Style {

src/theme/style/segmented_button.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ mod horizontal {
192192
border_radius: Radius::from([rad_0[0], rad_m[1], rad_m[2], rad_0[3]]),
193193
..Default::default()
194194
},
195-
text_color: cosmic.accent.base.into(),
195+
text_color: cosmic.accent_text_color().into(),
196196
}
197197
}
198198

@@ -218,7 +218,7 @@ mod horizontal {
218218
border_bottom: Some((4.0, cosmic.accent.base.into())),
219219
..Default::default()
220220
},
221-
text_color: cosmic.accent.base.into(),
221+
text_color: cosmic.accent_text_color().into(),
222222
}
223223
}
224224
}
@@ -231,7 +231,7 @@ pub fn focus(
231231
let color = container.small_widget;
232232
ItemStatusAppearance {
233233
background: Some(Background::Color(color.into())),
234-
text_color: cosmic.accent.base.into(),
234+
text_color: cosmic.accent_text_color().into(),
235235
..*default
236236
}
237237
}
@@ -242,9 +242,7 @@ pub fn hover(
242242
default: &ItemStatusAppearance,
243243
) -> ItemStatusAppearance {
244244
ItemStatusAppearance {
245-
background: Some(Background::Color(
246-
cosmic.palette.neutral_8.with_alpha(0.2).into(),
247-
)),
245+
background: Some(Background::Color(component.hover.with_alpha(0.2).into())),
248246
text_color: cosmic.accent.base.into(),
249247
..*default
250248
}
@@ -279,7 +277,7 @@ mod vertical {
279277
border_radius: Radius::from([rad_0[0], rad_0[1], rad_m[2], rad_m[3]]),
280278
..Default::default()
281279
},
282-
text_color: cosmic.accent.base.into(),
280+
text_color: cosmic.accent_text_color().into(),
283281
}
284282
}
285283

@@ -300,7 +298,7 @@ mod vertical {
300298
border_radius: cosmic.corner_radii.radius_m.into(),
301299
..Default::default()
302300
},
303-
text_color: cosmic.accent.base.into(),
301+
text_color: cosmic.accent_text_color().into(),
304302
}
305303
}
306304
}

0 commit comments

Comments
 (0)