Skip to content

Commit 378c362

Browse files
committed
Styling checkboxes in app-notice
I applied a custom theme and palette for the checkboxes for fill-dark and fill-light. The palette is generated, based off the colorDark of the notice type. It works well for these modes, which have a lighter background. The other modes seem to handle both light and dark themes well. I also tested most of the available types. There's no "is dark" detection logic needed, since the background color is the same between light and dark. I also made the palettes public, so that they can be referenced in other files.
1 parent ba943e8 commit 378c362

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/shared/notice/notice.component.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@use 'sass:color';
22
@use 'sass:list';
3+
@use 'sass:map';
4+
@use '@angular/material' as mat;
35
@use 'src/variables' as sfColors;
6+
@use 'src/themes/default' as default;
47

58
// prettier-ignore
69
$colors: (
@@ -19,6 +22,27 @@ $colors: (
1922
@return color.scale($color, $lightness: $lightness);
2023
}
2124

25+
@function create-dark-palette($base-color) {
26+
@return (
27+
0: scaleLightness($base-color, -95%),
28+
10: scaleLightness($base-color, -90%),
29+
20: scaleLightness($base-color, -80%),
30+
25: scaleLightness($base-color, -75%),
31+
30: scaleLightness($base-color, -70%),
32+
35: scaleLightness($base-color, -65%),
33+
40: scaleLightness($base-color, -60%),
34+
50: scaleLightness($base-color, -50%),
35+
60: scaleLightness($base-color, -40%),
36+
70: scaleLightness($base-color, -30%),
37+
80: scaleLightness($base-color, -25%),
38+
90: scaleLightness($base-color, -10%),
39+
95: scaleLightness($base-color, -5%),
40+
98: scaleLightness($base-color, -2%),
41+
99: scaleLightness($base-color, -1%),
42+
100: $base-color
43+
);
44+
}
45+
2246
:host {
2347
display: flex;
2448
align-items: center;
@@ -59,6 +83,20 @@ $colors: (
5983
--notice-color-button-bg-alt: #{scaleLightness($colorLight, 20%)};
6084
--notice-color-button-hover-bg-alt: #{scaleLightness($colorLight, 80%)};
6185
--notice-color-button-text-alt: #{scaleLightness($colorLight, -60%)};
86+
87+
// prettier-ignore
88+
&.mode-fill-dark,
89+
&.mode-fill-light {
90+
$_notice_theme: mat.define-theme(
91+
(
92+
color: (
93+
primary: map.merge(create-dark-palette($colorLight), default.$rest)
94+
)
95+
)
96+
);
97+
98+
@include mat.checkbox-color($_notice_theme);
99+
}
62100
}
63101
}
64102

src/SIL.XForge.Scripture/ClientApp/src/themes/_default.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Styles for angular material components. Refer to https://material.angular.io/guide/theming
66
// Note: Color palettes are generated from primary: #BECC63, secondary: #9BA26D, tertiary: #F3D479
7-
$_palettes: (
7+
$palettes: (
88
primary: (
99
0: #000000,
1010
10: #2b0053,
@@ -124,14 +124,14 @@ $_palettes: (
124124
100: #ffffff
125125
)
126126
);
127-
$_rest: (
128-
secondary: map.get($_palettes, secondary),
129-
neutral: map.get($_palettes, neutral),
130-
neutral-variant: map.get($_palettes, neutral-variant),
131-
error: map.get($_palettes, error)
127+
$rest: (
128+
secondary: map.get($palettes, secondary),
129+
neutral: map.get($palettes, neutral),
130+
neutral-variant: map.get($palettes, neutral-variant),
131+
error: map.get($palettes, error)
132132
);
133-
$_primary: map.merge(map.get($_palettes, primary), $_rest);
134-
$_tertiary: map.merge(map.get($_palettes, tertiary), $_rest);
133+
$_primary: map.merge(map.get($palettes, primary), $rest);
134+
$_tertiary: map.merge(map.get($palettes, tertiary), $rest);
135135

136136
$default-theme: mat.define-theme(
137137
(

0 commit comments

Comments
 (0)