Skip to content

Commit 0ea13f7

Browse files
authored
Merge branch 'master' into mpopov/fix-scrollbar-gap
2 parents 23a475c + f042a71 commit 0ea13f7

40 files changed

+3407
-82
lines changed

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

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
@return ($pixels / $context) * 1rem;
3232
}
3333

34+
/// Relative value(em/rem) to pixel.
35+
/// @access public
36+
/// @param {number|string} $num - The relative value to be converted.
37+
/// @param {number|string} $context [$browser-context] - The base context to convert against.
38+
@function px($num, $context: $browser-context) {
39+
@if type-of $num == 'number' {
40+
@return ($num / ($num * 0 + 1)) * 16px;
41+
}
42+
43+
@return $num;
44+
}
45+
3446
/// Calculates the luminance for a given color.
3547
/// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests.
3648
///
@@ -276,12 +288,12 @@
276288
/// @param {Color} $color - The base color used to generate the palette.
277289
/// @param {Map} $shades - A map of variations as keys and opacities as values.
278290
/// Based on the Material color system.
279-
/// @returns {Map} - A map consisting of 10 grayscale color variations and 10
291+
/// @returns {Map} - A map consisting of 10 color variations and 10
280292
/// text contrast colors for each variation.
281293
@function grayscale-palette($color, $shades) {
282294
$result: ();
283295
@each $saturation, $opacity in $shades {
284-
$shade: rgba(grayscale($color), $opacity);
296+
$shade: rgba($color, $opacity);
285297
$result: map-merge($result, ($saturation: $shade));
286298
}
287299
@return $result;
@@ -297,7 +309,7 @@
297309
/// @param {Color} $success [#4eb862] - The success color used throughout the application.
298310
/// @param {Color} $warn [#fbb13c] - The warning color used throughout the application.
299311
/// @param {Color} $error [#ff134a] - The error color used throughout the application.
300-
/// @param {Color} $grays [#000 | $igx-foreground-color] - The color used for generating the grayscale palette.
312+
/// @param {Color} $grays [#000 | $igx-foreground-color] - The color used for generating the grays palette.
301313
/// @param {Color} $surface [#fff] - The color used as a background in components, such as cards, sheets, and menus.
302314
/// @returns {Map} - A map consisting of 74 color variations, including the `primary`, `secondary`, `grays`,
303315
/// `info`, `success`, `warn`, and `error` colors.
@@ -403,17 +415,19 @@
403415
///
404416
@function resolve-value($ctx, $extra: null) {
405417
$result: null;
418+
406419
@each $fn, $args in $ctx {
407420
@if function-exists($fn) {
408421
@if $result == null and ($fn == 'igx-color' or $fn == 'igx-contrast-color') {
409422
$result: call(get-function($fn), $extra, $args...);
410423
} @else if $result != null {
411-
$result: call(get-function($fn), $result, $args...)
424+
$result: call(get-function($fn), $result, $args...);
412425
} @else {
413-
$result: call(get-function($fn), $args...)
426+
$result: call(get-function($fn), $args);
414427
}
415428
}
416429
}
430+
417431
@return $result;
418432
}
419433

@@ -423,6 +437,21 @@
423437
@return hsl(random(360), 100%, 50%);
424438
}
425439

440+
@function igx-generate-series-colors($palette) {
441+
@return (
442+
igx-color($palette, 'primary'),
443+
igx-color($palette, 'secondary'),
444+
rgb(249, 98, 50),
445+
rgb(60, 189, 201),
446+
rgb(220, 63, 118),
447+
rgb(255, 152, 0),
448+
rgb(78, 98, 207),
449+
rgb(84, 194, 90),
450+
rgb(121, 85, 72),
451+
rgb(154, 154, 154)
452+
);
453+
}
454+
426455
/// Applies an `igx-palette` to a given theme schema.
427456
/// @access private
428457
/// @param {Map} $schema - A theme schema.
@@ -448,6 +477,12 @@
448477
} @else {
449478
$result: extend($result, (#{$key}: $value));
450479
}
480+
481+
@if $value == 'series' {
482+
$result: extend($result, (
483+
#{$key}: #{igx-generate-series-colors($palette)}
484+
));
485+
}
451486
}
452487
@return $result;
453488
}
@@ -567,3 +602,47 @@
567602
@function if-rtl($if, $else: null) {
568603
@return if-ltr($else, $if);
569604
}
605+
606+
@function expand-shorthand($list) {
607+
$len: length($list);
608+
609+
$margins: (
610+
'margin-top': null,
611+
'margin-right': null,
612+
'margin-bottom': null,
613+
'margin-left': null,
614+
);
615+
616+
@for $i from 1 through 4 {
617+
$n: $i % $len;
618+
$n: if($n != 0, $n, $len);
619+
620+
@if $len == 3 and $i == 4 {
621+
$n: 2;
622+
}
623+
624+
$key: nth(map-keys($margins), $i);
625+
$value: nth($list, $n);
626+
627+
$margins: map-merge($margins, ($key: $value));
628+
}
629+
630+
@return $margins;
631+
}
632+
633+
@function map-keys-prefix($map, $prefix, $separator: '-') {
634+
$keys: map-keys($map);
635+
$len: length($keys);
636+
$result: ();
637+
638+
@for $i from 1 through $len {
639+
$key: nth($keys, $i);
640+
641+
$result: map-merge($result, (
642+
'#{$prefix}#{$separator}#{$key}': map-get($map, $key))
643+
);
644+
}
645+
646+
@return $result;
647+
}
648+

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,14 @@
238238
/// :root {
239239
/// @include css-vars-from-theme($my-theme);
240240
/// }
241-
@mixin css-vars-from-theme($theme) {
242-
$prefix: map-get($theme, 'name');
243-
241+
@mixin css-vars-from-theme($theme, $prefix: null) {
244242
@each $key, $value in $theme {
245243
@if $key != 'name' and $key != 'palette' and type-of($value) != 'map' {
246-
--#{$prefix}-#{$key}: #{$value};
244+
@if $prefix {
245+
--#{$prefix}-#{$key}: #{$value};
246+
} @else {
247+
--#{$key}: #{$value};
248+
}
247249
}
248250
}
249251
}
@@ -269,9 +271,10 @@
269271
/// @requires {mixin} css-vars-from-theme
270272
@mixin igx-css-vars($theme) {
271273
$scope: if(is-root(), ':root', '&');
274+
$prefix: map-get($theme, 'name');
272275

273276
#{$scope} {
274-
@include css-vars-from-theme($theme);
277+
@include css-vars-from-theme($theme, $prefix);
275278
}
276279
}
277280

0 commit comments

Comments
 (0)