Skip to content

Commit 0048844

Browse files
authored
feat(button-group): improve button group theme (#15501)
1 parent 08c8533 commit 0048844

File tree

1 file changed

+113
-29
lines changed

1 file changed

+113
-29
lines changed

projects/igniteui-angular/src/lib/core/styles/components/button-group/_button-group-theme.scss

+113-29
Original file line numberDiff line numberDiff line change
@@ -120,44 +120,130 @@
120120
}
121121

122122
$theme: digest-schema($button-group-schema);
123-
$meta: map.get($theme, '_meta');
124123

125124
$border: rem(1px) solid map.get($theme, 'item-selected-border-color');
126125

126+
//background colors
127+
@if not($item-hover-background) and $item-background {
128+
$item-hover-background: hsl(from var(--item-background) h s calc(l * 0.9));
129+
}
130+
131+
@if not($item-selected-background) and $item-background {
132+
$item-selected-background: hsl(from var(--item-background) h s calc(l * 0.7));
133+
}
134+
135+
@if not($item-selected-hover-background) and $item-selected-background {
136+
$item-selected-hover-background: hsl(from var(--item-selected-background) h s calc(l * 1.1));
137+
}
138+
139+
@if not($item-selected-focus-background) and $item-selected-background {
140+
$item-selected-focus-background: var(--item-selected-background);
141+
}
142+
143+
@if not($item-selected-focus-hover-background) and $item-selected-hover-background {
144+
$item-selected-focus-hover-background: var(--item-selected-hover-background);
145+
}
146+
147+
@if not($item-focused-background) and $item-background {
148+
$item-focused-background: var(--item-hover-background);
149+
}
150+
151+
@if not($item-focused-hover-background) and $item-hover-background {
152+
$item-focused-hover-background: hsl(from var(--item-focused-background) h s calc(l * 0.9));
153+
}
154+
155+
@if not($disabled-background-color) and $item-background {
156+
$disabled-background-color: var(--item-background);
157+
}
158+
159+
@if not($disabled-selected-background) and $item-selected-background {
160+
$disabled-selected-background: rgba(gray, 0.3);
161+
}
162+
163+
//border colors
164+
@if not($item-border-color) and $item-background {
165+
$item-border-color: hsl(from var(--item-background) h s calc(l * 0.8));
166+
}
167+
168+
@if not($item-hover-border-color) and $item-border-color {
169+
$item-hover-border-color: var(--item-border-color);
170+
}
171+
172+
@if not($item-focused-border-color) and $item-border-color {
173+
$item-focused-border-color: var(--item-border-color);
174+
}
175+
176+
@if not($item-selected-border-color) and $item-border-color {
177+
$item-selected-border-color: var(--item-border-color);
178+
}
179+
180+
@if not($item-selected-hover-border-color) and $item-border-color {
181+
$item-selected-hover-border-color: var(--item-border-color);
182+
}
183+
184+
@if not($item-disabled-border) and $item-border-color {
185+
$item-disabled-border: var(--item-border-color);
186+
}
187+
188+
@if not($disabled-selected-border-color) and $item-border-color {
189+
$disabled-selected-border-color: var(--item-border-color);
190+
}
191+
192+
//text and icon colors
127193
@if not($item-text-color) and $item-background {
128-
@if meta.type-of($item-background) == 'color' {
129-
$item-text-color: text-contrast($item-background);
130-
}
194+
$item-text-color: adaptive-contrast(var(--item-background));
131195
}
132196

133-
@if not($item-hover-text-color) and $item-hover-background {
134-
@if meta.type-of($item-hover-background) == 'color' {
135-
$item-hover-text-color: text-contrast($item-hover-background);
136-
}
197+
@if not($item-icon-color) and $item-text-color {
198+
$item-icon-color: var(--item-text-color);
137199
}
138200

139-
@if not($item-selected-background) and $item-background {
140-
@if meta.type-of($item-background) == 'color' {
141-
$item-selected-background: text-contrast($item-background);
142-
}
201+
@if not($item-hover-text-color) and $item-hover-background {
202+
$item-hover-text-color: adaptive-contrast(var(--item-hover-background));
143203
}
144204

145-
@if not($idle-shadow-color) and $selected-shadow-color {
146-
@if meta.type-of($selected-shadow-color) == 'color' {
147-
$idle-shadow-color: $selected-shadow-color;
148-
}
205+
@if not($item-hover-icon-color) and $item-hover-text-color {
206+
$item-hover-icon-color: var(--item-hover-text-color);
149207
}
150208

151-
@if not($selected-shadow-color) and $idle-shadow-color {
152-
@if meta.type-of($idle-shadow-color) == 'color' {
153-
$selected-shadow-color: $idle-shadow-color;
154-
}
209+
@if not($item-focused-text-color) and $item-focused-background {
210+
$item-focused-text-color: adaptive-contrast(var(--item-focused-background));
155211
}
156212

157213
@if not($item-selected-text-color) and $item-selected-background {
158-
@if meta.type-of($item-selected-background) == 'color' {
159-
$item-selected-text-color: text-contrast($item-selected-background);
160-
}
214+
$item-selected-text-color: adaptive-contrast(var(--item-selected-background));
215+
}
216+
217+
@if not($item-selected-icon-color) and $item-selected-text-color {
218+
$item-selected-icon-color: var(--item-selected-text-color);
219+
}
220+
221+
@if not($item-selected-hover-text-color) and $item-selected-hover-background {
222+
$item-selected-hover-text-color: adaptive-contrast(var(--item-selected-hover-background));
223+
}
224+
225+
@if not($item-selected-hover-icon-color) and $item-selected-hover-text-color {
226+
$item-selected-hover-icon-color: var(--item-selected-hover-text-color);
227+
}
228+
229+
@if not($disabled-text-color) and $disabled-background-color {
230+
$disabled-text-color: hsla(from adaptive-contrast(var(--disabled-background-color)) h s l / 0.4);
231+
}
232+
233+
@if not($disabled-selected-text-color) and $disabled-text-color {
234+
$disabled-selected-text-color: var(--disabled-text-color);
235+
}
236+
237+
@if not($idle-shadow-color) and $item-background {
238+
$idle-shadow-color: hsla(from var(--item-background) h s l / .5);
239+
}
240+
241+
@if not($idle-shadow-color) and $selected-shadow-color {
242+
$idle-shadow-color: var(--selected-shadow-color);
243+
}
244+
245+
@if not($selected-shadow-color) and $idle-shadow-color {
246+
$selected-shadow-color: var(--idle-shadow-color);
161247
}
162248

163249
@if map.get($button-group-schema, 'elevation') > 0 {
@@ -205,11 +291,7 @@
205291
border: $border,
206292
shadow: $shadow,
207293
idle-shadow-color: $idle-shadow-color,
208-
selected-shadow-color: $selected-shadow-color,
209-
theme: map.get($schema, '_meta', 'theme'),
210-
_meta: map.merge(if($meta, $meta, ()), (
211-
variant: map.get($schema, '_meta', 'theme')
212-
)),
294+
selected-shadow-color: $selected-shadow-color
213295
));
214296
}
215297

@@ -223,7 +305,7 @@
223305
$group-items-margin: rem(10px, 16px);
224306
$outline-btn-indent: rem(2px);
225307

226-
$variant: map.get($theme, '_meta', 'variant');
308+
$variant: map.get($theme, '_meta', 'theme');
227309
$bootstrap-theme: $variant == 'bootstrap';
228310
$indigo-theme: $variant == 'indigo';
229311
$group-item-min-width: map.get((
@@ -445,6 +527,7 @@
445527
@if $variant == 'bootstrap' {
446528
background: var-get($theme, 'item-background');
447529
z-index: 1;
530+
box-shadow: 0 0 0 rem(4px) var-get($theme, 'idle-shadow-color');
448531

449532
&:active {
450533
background: var-get($theme, 'item-hover-background');
@@ -691,6 +774,7 @@
691774
color: var-get($theme, 'item-selected-text-color');
692775
border-color: var-get($theme, 'item-selected-border-color');
693776
background: var-get($theme, 'item-selected-background');
777+
box-shadow: 0 0 0 rem(4px) var-get($theme, 'selected-shadow-color');
694778

695779
igx-icon {
696780
color: var-get($theme, 'item-selected-icon-color');

0 commit comments

Comments
 (0)