|
31 | 31 | @return ($pixels / $context) * 1rem;
|
32 | 32 | }
|
33 | 33 |
|
| 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 | + |
34 | 46 | /// Calculates the luminance for a given color.
|
35 | 47 | /// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests.
|
36 | 48 | ///
|
|
403 | 415 | ///
|
404 | 416 | @function resolve-value($ctx, $extra: null) {
|
405 | 417 | $result: null;
|
| 418 | + |
406 | 419 | @each $fn, $args in $ctx {
|
407 | 420 | @if function-exists($fn) {
|
408 | 421 | @if $result == null and ($fn == 'igx-color' or $fn == 'igx-contrast-color') {
|
409 | 422 | $result: call(get-function($fn), $extra, $args...);
|
410 | 423 | } @else if $result != null {
|
411 |
| - $result: call(get-function($fn), $result, $args...) |
| 424 | + $result: call(get-function($fn), $result, $args...); |
412 | 425 | } @else {
|
413 |
| - $result: call(get-function($fn), $args...) |
| 426 | + $result: call(get-function($fn), $args); |
414 | 427 | }
|
415 | 428 | }
|
416 | 429 | }
|
| 430 | + |
417 | 431 | @return $result;
|
418 | 432 | }
|
419 | 433 |
|
|
423 | 437 | @return hsl(random(360), 100%, 50%);
|
424 | 438 | }
|
425 | 439 |
|
| 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 | + |
426 | 455 | /// Applies an `igx-palette` to a given theme schema.
|
427 | 456 | /// @access private
|
428 | 457 | /// @param {Map} $schema - A theme schema.
|
|
448 | 477 | } @else {
|
449 | 478 | $result: extend($result, (#{$key}: $value));
|
450 | 479 | }
|
| 480 | + |
| 481 | + @if $value == 'series' { |
| 482 | + $result: extend($result, ( |
| 483 | + #{$key}: #{igx-generate-series-colors($palette)} |
| 484 | + )); |
| 485 | + } |
451 | 486 | }
|
452 | 487 | @return $result;
|
453 | 488 | }
|
|
567 | 602 | @function if-rtl($if, $else: null) {
|
568 | 603 | @return if-ltr($else, $if);
|
569 | 604 | }
|
| 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 | + |
0 commit comments