_var.scss 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. @use 'sass:map';
  2. @use 'sass:color';
  3. @use 'config' as *;
  4. @use 'function' as *;
  5. // set css var value, because we need translate value to string
  6. // for example:
  7. // @include set-css-var-value(('color', 'primary'), red);
  8. // --uni-color-primary: red;
  9. @mixin set-css-var-value($name, $value) {
  10. #{joinVarName($name)}: #{$value};
  11. }
  12. // @include set-css-var-type('color', 'primary', $map);
  13. // --uni-color-primary: #{map.get($map, 'primary')};
  14. @mixin set-css-var-type($name, $type, $variables) {
  15. #{getCssVarName($name, $type)}: #{map.get($variables, $type)};
  16. }
  17. @mixin set-css-color-type($colors, $type) {
  18. @include set-css-var-value(('color', $type), map.get($colors, $type, 'base'));
  19. @each $i in (3, 5, 7, 8, 9) {
  20. @include set-css-var-value(
  21. ('color', $type, 'light', $i),
  22. map.get($colors, $type, 'light-#{$i}')
  23. );
  24. }
  25. @include set-css-var-value(('color', $type, 'dark-2'), map.get($colors, $type, 'dark-2'));
  26. }
  27. // set all css var for component by map
  28. @mixin set-component-css-var($name, $variables) {
  29. @each $attribute, $value in $variables {
  30. @if $attribute == 'default' {
  31. #{getCssVarName($name)}: #{$value};
  32. } @else {
  33. #{getCssVarName($name, $attribute)}: #{$value};
  34. }
  35. }
  36. }
  37. // .uni-primary / .uni-bg-primary
  38. @mixin set-css-color-class($colors, $type) {
  39. .#{$namespace}-#{$type} {
  40. color: map.get($colors, $type, 'base');
  41. }
  42. .#{$namespace}-bg-#{$type} {
  43. color: map.get($colors, $type, 'base');
  44. }
  45. }