Skip to content

Commit 673a2e2

Browse files
refactor(*): component themes accept any value (#9248)
* refactor(*): component themes accept any value Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent 2c850bc commit 673a2e2

File tree

9 files changed

+58
-37
lines changed

9 files changed

+58
-37
lines changed

projects/igniteui-angular/src/lib/core/styles/base/utilities/_functions.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,7 @@ $p-test: igx-palette(#fff, #000);
488488
}
489489
}
490490
} @else {
491-
@warn 'Expected color for $background/$foreground but got #{$background}/#{$foreground}. The contrast color can\'t be calculated automatically.';
492-
@return #fff;
491+
@return $background;
493492
}
494493
}
495494

@@ -824,7 +823,7 @@ $p-test: igx-palette(#fff, #000);
824823
@if type-of($value) == 'number' and unitless($value) {
825824

826825
@if $value < 0 or $value > 1 {
827-
@error 'Roundness factor should be between 0 and 1';
826+
@return $value;
828827
}
829828

830829
@return round(fraction-clamp($value, $min, $max));

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,31 +107,31 @@
107107
}
108108

109109
@if not($item-text-color) and $item-background {
110-
@if type_of($item-background) == 'color' {
110+
@if type-of($item-background) == 'color' {
111111
$item-text-color: text-contrast($item-background);
112112
}
113113
}
114114

115115
@if not($item-hover-text-color) and $item-hover-background {
116-
@if type_of($item-hover-background) == 'color' {
116+
@if type-of($item-hover-background) == 'color' {
117117
$item-hover-text-color: text-contrast($item-hover-background);
118118
}
119119
}
120120

121121
@if not($item-selected-background) and $item-background {
122-
@if type_of($item-background) == 'color' {
122+
@if type-of($item-background) == 'color' {
123123
$item-selected-text-color: text-contrast($item-background);
124124
}
125125
}
126126

127127
@if not($item-selected-text-color) and $item-selected-background {
128-
@if type_of($item-selected-background) == 'color' {
128+
@if type-of($item-selected-background) == 'color' {
129129
$item-selected-text-color: text-contrast($item-selected-background);
130130
}
131131
}
132132

133133
@if not($disabled-text-color) and $disabled-background-color {
134-
@if type_of($disabled-background-color) == 'color' {
134+
@if type-of($disabled-background-color) == 'color' {
135135
$disabled-text-color: rgba(text-contrast($item-background), .3);
136136
}
137137
}

projects/igniteui-angular/src/lib/core/styles/components/calendar/_calendar-theme.scss

+8-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@
261261
}
262262

263263
@if not($date-disabled-text-color) and $date-disabled-background {
264-
$date-disabled-color: rgba(text-contrast($date-disabled-background), .38);
264+
@if type-of($date-disabled-background) == 'color' {
265+
$date-disabled-color: rgba(text-contrast($date-disabled-background), .38);
266+
}
265267
}
266268

267269
@if not($week-number-color) and $week-number-background {
@@ -795,7 +797,11 @@
795797
%cal-value--selected--hover {
796798
%cal-value-content {
797799
::after {
798-
background: rgba($selected-hover-color, .18);
800+
@if type-of($selected-hover-color) == 'color' {
801+
background: rgba($selected-hover-color, .18);
802+
} @else {
803+
background: $selected-hover-color;
804+
}
799805
}
800806
}
801807
}

projects/igniteui-angular/src/lib/core/styles/components/carousel/_carousel-theme.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@
9090
}
9191

9292
@if not($button-disabled-arrow-color) and $button-disabled-background {
93-
$button-disabled-arrow-color: rgba(text-contrast($button-disabled-background), .3);
93+
@if type-of($button-disabled-background) == 'color' {
94+
$button-disabled-arrow-color: rgba(text-contrast($button-disabled-background), .3);
95+
}
9496
}
9597

9698
@return extend($theme, (

projects/igniteui-angular/src/lib/core/styles/components/grid-summary/_grid-summary-theme.scss

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@
6262
}
6363

6464
@if not($border-color) and $background-color {
65-
$border-color: rgba(text-contrast($background-color), .26);
65+
@if type-of($background-color) == 'color' {
66+
$border-color: rgba(text-contrast($background-color), .26);
67+
}
6668
}
6769

6870
@if not($pinned-border-color) and $background-color {
69-
$pinned-border-color: rgba(text-contrast($background-color), .26);
71+
@if type-of($background-color) == 'color' {
72+
$pinned-border-color: rgba(text-contrast($background-color), .26);
73+
}
7074
}
7175

7276
@return extend($theme, (

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

+7-3
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
$ghost-header-text-color: text-contrast($ghost-header-background);
261261
}
262262

263-
@if $header-background and type-of($header-background) == 'color' and alpha($header-background) < 1 {
263+
@if $header-background and type-of($header-background) == 'color' {
264264
$header-background: to-opaque($header-background, igx-color($palette, 'surface'));
265265
}
266266

@@ -391,11 +391,15 @@
391391
}
392392

393393
@if not($grouparea-color) and $grouparea-background {
394-
$grouparea-color: rgba(text-contrast($grouparea-background), .8)
394+
@if type-of($grouparea-background) == 'color' {
395+
$grouparea-color: rgba(text-contrast($grouparea-background), .8)
396+
}
395397
}
396398

397399
@if not($grouparea-color) and $header-background {
398-
$grouparea-color: rgba(text-contrast($header-background), .8)
400+
@if type-of($header-background) == 'color' {
401+
$grouparea-color: rgba(text-contrast($header-background), .8)
402+
}
399403
}
400404

401405
@if not($drop-area-background) and $grouparea-background {

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@
159159
$success-shadow-color: rgba(map-get($theme, 'success-secondary-color'), .5);
160160
$error-shadow-color: rgba(map-get($theme, 'error-secondary-color'), .5);
161161

162-
@if $focused-secondary-color {
162+
@if $focused-secondary-color and type-of($focused-secondary-color) == 'color' {
163163
$focused-shadow-color: rgba($focused-secondary-color, .5);
164164
}
165165

166-
@if $success-secondary-color {
166+
@if $success-secondary-color and type-of($success-secondary-color) == 'color' {
167167
$success-shadow-color: rgba($success-secondary-color, .5);
168168
}
169169

170-
@if $error-secondary-color {
170+
@if $error-secondary-color and type-of($error-secondary-color) == 'color' {
171171
$error-shadow-color: rgba($error-secondary-color, .5);
172172
}
173173

projects/igniteui-angular/src/lib/core/styles/components/list/_list-theme.scss

+9-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@
156156
}
157157

158158
@if not($item-subtitle-color) and $item-background {
159-
$item-subtitle-color: rgba(text-contrast($item-background), .74);
159+
@if type-of($item-background) == 'color' {
160+
$item-subtitle-color: rgba(text-contrast($item-background), .74);
161+
}
160162
}
161163

162164
@if not($item-subtitle-color) and $item-text-color {
@@ -180,7 +182,9 @@
180182
}
181183

182184
@if not($item-subtitle-color-hover) and $item-background-hover {
183-
$item-subtitle-color-hover: rgba(text-contrast($item-background-hover), .74);
185+
@if type-of($item-background-hover) == 'color' {
186+
$item-subtitle-color-hover: rgba(text-contrast($item-background-hover), .74);
187+
}
184188
}
185189

186190
@if not($item-subtitle-color-hover) and $item-text-color-hover {
@@ -204,7 +208,9 @@
204208
}
205209

206210
@if not($item-subtitle-color-active) and $item-background-active {
207-
$item-subtitle-color-active: rgba(text-contrast($item-background-active), .74);
211+
@if type-of($item-background-active) == 'color' {
212+
$item-subtitle-color-active: rgba(text-contrast($item-background-active), .74);
213+
}
208214
}
209215

210216
@if not($item-subtitle-color-active) and $item-text-color-active {

projects/igniteui-angular/src/lib/core/styles/components/splitter/_splitter-theme.scss

+15-15
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@
183183
&::before {
184184
@extend %igx-splitter-hitbox;
185185
top: calc(100% - #{map-get($theme, 'size')});
186-
left: calc(100% - #{map-get($theme, 'size') * 2});
187-
width: #{map-get($theme, 'size') * 4};
188-
height: #{map-get($theme, 'size') * 3};
186+
left: calc(100% - (#{map-get($theme, 'size')} * 2));
187+
width: calc(#{map-get($theme, 'size')} * 4);
188+
height: calc(#{map-get($theme, 'size')} * 3);
189189
}
190190
}
191191

@@ -195,10 +195,10 @@
195195

196196
&::before {
197197
@extend %igx-splitter-hitbox;
198-
top: calc(100% - #{map-get($theme, 'size') * 2});
199-
left: calc(100% - #{map-get($theme, 'size') * 2});
200-
width: #{map-get($theme, 'size') * 4};
201-
height: #{map-get($theme, 'size') * 3};
198+
top: calc(100% - (#{map-get($theme, 'size')} * 2));
199+
left: calc(100% - (#{map-get($theme, 'size')} * 2));
200+
width: calc(#{map-get($theme, 'size')} * 4);
201+
height: calc(#{map-get($theme, 'size')} * 3);
202202
}
203203
}
204204

@@ -210,10 +210,10 @@
210210

211211
&::before {
212212
@extend %igx-splitter-hitbox;
213-
top: calc(100% - #{map-get($theme, 'size') * 2});
214-
left: calc(100% - #{map-get($theme, 'size')});
215-
width: #{map-get($theme, 'size') * 3};
216-
height: #{map-get($theme, 'size') * 4};
213+
top: calc(100% - (#{map-get($theme, 'size')} * 2));
214+
left: calc(100% - (#{map-get($theme, 'size')} * 2));
215+
width: calc(#{map-get($theme, 'size')} * 3);
216+
height: calc(#{map-get($theme, 'size')} * 4);
217217
}
218218
}
219219

@@ -225,10 +225,10 @@
225225

226226
&::before {
227227
@extend %igx-splitter-hitbox;
228-
left: calc(100% - #{map-get($theme, 'size') * 2});
229-
top: calc(100% - #{map-get($theme, 'size') * 2});
230-
height: #{map-get($theme, 'size') * 4};
231-
width: #{map-get($theme, 'size') * 3};
228+
left: calc(100% - (#{map-get($theme, 'size')} * 2));
229+
top: calc(100% - (#{map-get($theme, 'size')} * 2));
230+
height: calc(#{map-get($theme, 'size')} * 4);
231+
width: calc(#{map-get($theme, 'size')} * 3);
232232
}
233233
}
234234
}

0 commit comments

Comments
 (0)