Skip to content

Commit 7fcee0e

Browse files
authored
improve checkbox theme and add missing properties (#15533)
1 parent 0faaa6f commit 7fcee0e

File tree

2 files changed

+64
-12
lines changed

2 files changed

+64
-12
lines changed

projects/igniteui-angular/src/lib/core/styles/components/checkbox/_checkbox-component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
@extend %igx-checkbox--focused-bootstrap !optional;
164164

165165
&:hover {
166-
@extend %igx-checkbox--focused-hovered !optional;
166+
@extend %igx-checkbox--focused-hovered-bootstrap !optional;
167167
}
168168
}
169169

projects/igniteui-angular/src/lib/core/styles/components/checkbox/_checkbox-theme.scss

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
/// @param {List} $border-radius [null] - The border radius used for checkbox component.
3030
/// @param {List} $border-radius-ripple [null] - The border radius used for checkbox ripple.
3131
/// @param {Color} $focus-outline-color [null] - The focus outlined color.
32+
/// @param {Color} $focus-outline-color-focused [null] - The focus outlined color for focused state.
33+
/// @param {Color} $focus-border-color [null] - The focus border color.
3234
/// @param {Color} $error-color [null] - The border and fill colors in invalid state.
3335
/// @param {Color} $error-color-hover [null] - The border and fill colors in invalid state on hover.
36+
/// @param {Color} $focus-outline-color-error [null] - The focus outline error color.
3437
/// Set to light when the surrounding area is dark.
3538
///
3639
/// @requires $light-material-schema
@@ -58,8 +61,11 @@
5861
$disabled-color-label: null,
5962
$border-radius-ripple: null,
6063
$focus-outline-color: null,
64+
$focus-outline-color-focused: null,
65+
$focus-border-color: null,
6166
$error-color: null,
6267
$error-color-hover: null,
68+
$focus-outline-color-error: null,
6369
) {
6470
$name: 'igx-checkbox';
6571
$checkbox-schema: ();
@@ -71,7 +77,55 @@
7177
}
7278

7379
$theme: digest-schema($checkbox-schema);
74-
$meta: map.get($theme, '_meta');
80+
$variant: map.get($theme, '_meta', 'theme');
81+
82+
@if not($empty-color-hover) and $empty-color {
83+
$empty-color-hover: hsl(from var(--empty-color) h s calc(l * 0.9));
84+
}
85+
86+
@if not($fill-color-hover) and $fill-color {
87+
$fill-color-hover: hsl(from var(--fill-color) h s calc(l * 0.9));
88+
}
89+
90+
@if not($tick-color) and $fill-color {
91+
$tick-color: adaptive-contrast(var(--fill-color));
92+
}
93+
94+
@if not($label-color-hover) and $label-color {
95+
$label-color-hover: hsl(from var(--label-color) h s calc(l * 0.9));
96+
}
97+
98+
@if not($focus-border-color) and $fill-color {
99+
$focus-border-color: var(--fill-color);
100+
}
101+
102+
@if not($disabled-indeterminate-color) and $fill-color {
103+
$disabled-indeterminate-color: hsla(from var(--fill-color) h s l / 0.5);
104+
}
105+
106+
@if not($error-color-hover) and $error-color {
107+
$error-color-hover: hsl(from var(--error-color) h s calc(l * 0.9));
108+
}
109+
110+
@if not($focus-outline-color-error) and $error-color {
111+
$focus-outline-color-error: hsla(from var(--error-color) h s l / .5);
112+
}
113+
114+
@if $variant == 'bootstrap' {
115+
@if not($focus-outline-color) and $fill-color {
116+
$focus-outline-color: hsla(from var(--fill-color) h s l / .5);
117+
}
118+
}
119+
120+
@if $variant == 'indigo' {
121+
@if not($focus-outline-color) and $empty-color {
122+
$focus-outline-color: hsla(from var(--empty-color) h s l / .5);
123+
}
124+
125+
@if not($focus-outline-color-focused) and $fill-color {
126+
$focus-outline-color-focused: hsla(from var(--fill-color) h s l / .5);
127+
}
128+
}
75129

76130
@return extend($theme, (
77131
name: $name,
@@ -91,13 +145,11 @@
91145
border-radius: $border-radius,
92146
border-radius-ripple: $border-radius-ripple,
93147
focus-outline-color: $focus-outline-color,
148+
focus-outline-color-focused: $focus-outline-color-focused,
149+
focus-border-color: $focus-border-color,
94150
error-color: $error-color,
95151
error-color-hover: $error-color-hover,
96-
theme: map.get($schema, '_meta', 'theme'),
97-
_meta: map.merge(if($meta, $meta, ()), (
98-
variant: map.get($schema, '_meta', 'theme'),
99-
theme-variant: map.get($schema, '_meta', 'variant')
100-
)),
152+
focus-outline-color-error: $focus-outline-color-error
101153
));
102154
}
103155

@@ -106,8 +158,8 @@
106158
/// @param {Map} $theme - The theme used to style the component.
107159
@mixin checkbox($theme) {
108160
@include css-vars($theme);
109-
$theme-variant: map.get($theme, '_meta', 'theme-variant');
110-
$variant: map.get($theme, '_meta', 'variant');
161+
$theme-variant: map.get($theme, '_meta', 'variant');
162+
$variant: map.get($theme, '_meta', 'theme');
111163
$material-theme: $variant == 'material';
112164
$bootstrap-theme: $variant == 'bootstrap';
113165

@@ -591,14 +643,14 @@
591643
%igx-checkbox--focused-bootstrap {
592644
%cbx-composite {
593645
border-radius: var-get($theme, 'border-radius');
594-
border-color: color($color: 'primary', $variant: 200);
646+
border-color: var-get($theme, 'focus-border-color');
595647
box-shadow: 0 0 0 rem(4px) var-get($theme, 'focus-outline-color');
596648
}
597649
}
598650

599-
%igx-checkbox--focused-hovered {
651+
%igx-checkbox--focused-hovered-bootstrap {
600652
%cbx-composite {
601-
border-color: color($color: 'primary', $variant: 300);
653+
border-color: hsl(from var-get($theme, 'focus-border-color') h calc(s * 1.12) calc(l * 0.82));
602654
}
603655
}
604656

0 commit comments

Comments
 (0)