fb928da3a7577bc2c3a79b445368147e8be3b4e6b81bb6552e7df1ab8bb15758d73af95d927628f36977ef53573ad471c8186876829d25b4cfc2c8f68aee83 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'common/var' as *;
  5. @include b(tag) {
  6. @include set-component-css-var('tag', $tag);
  7. }
  8. $tag-border-width: 1px;
  9. $tag-icon-span-gap: () !default;
  10. $tag-icon-span-gap: map.merge(
  11. (
  12. 'large': 8px,
  13. 'default': 6px,
  14. 'small': 4px,
  15. ),
  16. $tag-icon-span-gap
  17. );
  18. @function returnVarList($var, $type: 'primary') {
  19. $list: ('fill-color', 'blank');
  20. @if $var !=false {
  21. $list: ('color', $type, $var);
  22. }
  23. @return $list;
  24. }
  25. // false mean --el-color-white
  26. @mixin genTheme($backgroundColorWeight, $borderColorWeight, $hoverColorWeight) {
  27. @include css-var-from-global(
  28. ('tag', 'bg-color'),
  29. returnVarList($backgroundColorWeight)
  30. );
  31. @include css-var-from-global(
  32. ('tag', 'border-color'),
  33. returnVarList($borderColorWeight)
  34. );
  35. @include css-var-from-global(
  36. ('tag', 'hover-color'),
  37. returnVarList($hoverColorWeight)
  38. );
  39. @each $type in $types {
  40. &.#{bem('tag', '', $type)} {
  41. @include css-var-from-global(
  42. ('tag', 'bg-color'),
  43. returnVarList($backgroundColorWeight, $type)
  44. );
  45. @include css-var-from-global(
  46. ('tag', 'border-color'),
  47. returnVarList($borderColorWeight, $type)
  48. );
  49. @include css-var-from-global(
  50. ('tag', 'hover-color'),
  51. returnVarList($hoverColorWeight, $type)
  52. );
  53. }
  54. }
  55. }
  56. @include b(tag) {
  57. background-color: getCssVar('tag-bg-color');
  58. border-color: getCssVar('tag-border-color');
  59. color: getCssVar('tag-text-color');
  60. display: inline-flex;
  61. justify-content: center;
  62. align-items: center;
  63. vertical-align: middle;
  64. height: map.get($tag-height, 'default');
  65. padding: 0 map.get($tag-padding, 'default') - $border-width;
  66. font-size: getCssVar('tag-font-size');
  67. line-height: 1;
  68. border-width: $tag-border-width;
  69. border-style: solid;
  70. border-radius: getCssVar('tag-border-radius');
  71. box-sizing: border-box;
  72. white-space: nowrap;
  73. @include set-css-var-value('icon-size', 14px);
  74. @include genTheme('light-9', 'light-8', '');
  75. @include when(hit) {
  76. border-color: getCssVar('color', 'primary');
  77. }
  78. @include when(round) {
  79. border-radius: getCssVar('tag', 'border-radius-rounded');
  80. }
  81. .#{$namespace}-tag__close {
  82. flex-shrink: 0;
  83. color: getCssVar('tag', 'text-color');
  84. &:hover {
  85. color: getCssVar('color-white');
  86. background-color: getCssVar('tag-hover-color');
  87. }
  88. }
  89. @each $type in $types {
  90. &.#{bem('tag', '', $type)} {
  91. @include css-var-from-global(('tag', 'text-color'), ('color', $type));
  92. }
  93. }
  94. $svg-margin-size: 1px;
  95. .#{$namespace}-icon {
  96. border-radius: 50%;
  97. cursor: pointer;
  98. font-size: calc(#{getCssVar('icon-size')} - #{$svg-margin-size * 2});
  99. height: getCssVar('icon-size');
  100. width: getCssVar('icon-size');
  101. }
  102. .#{$namespace}-tag__close {
  103. margin-left: map.get($tag-icon-span-gap, 'default');
  104. }
  105. @include m(dark) {
  106. @include css-var-from-global(('tag', 'text-color'), ('color', 'white'));
  107. @include genTheme('', '', 'light-3');
  108. @each $type in $types {
  109. &.#{bem('tag', '', $type)} {
  110. @include css-var-from-global(('tag', 'text-color'), ('color', 'white'));
  111. }
  112. }
  113. }
  114. @include m(plain) {
  115. @include css-var-from-global(('tag', 'bg-color'), ('fill-color', 'blank'));
  116. @include genTheme(false, 'light-5', '');
  117. }
  118. &.is-closable {
  119. padding-right: map.get($tag-icon-span-gap, 'default') - $border-width;
  120. }
  121. @each $size in (large, small) {
  122. @include m($size) {
  123. padding: 0 map.get($tag-padding, $size) - $tag-border-width;
  124. height: map.get($tag-height, $size);
  125. @include set-css-var-value(
  126. 'icon-size',
  127. #{map.get($tag-icon-size, $size)}
  128. );
  129. .#{$namespace}-tag__close {
  130. margin-left: map.get($tag-icon-span-gap, $size);
  131. }
  132. &.is-closable {
  133. padding-right: map.get($tag-icon-span-gap, $size) - $border-width;
  134. }
  135. }
  136. }
  137. @include m(small) {
  138. .#{$namespace}-icon-close {
  139. transform: scale(0.8);
  140. }
  141. }
  142. @each $type in $types {
  143. &.#{bem('tag', '', $type)} {
  144. @include when(hit) {
  145. border-color: getCssVar('color', $type);
  146. }
  147. }
  148. }
  149. }