a920e657462d61708c55cd7c57685e09b8578411fae67804a252e4973d0a9c0dbab983e3c783bd2f33893e516e3f27767ff4942345f665976c9805223e9631 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'common/var' as *;
  4. $color-picker-size: () !default;
  5. $color-picker-size: map.merge($common-component-size, $color-picker-size);
  6. @mixin alpha-bg {
  7. background-image: linear-gradient(
  8. 45deg,
  9. getCssVar('color-picker', 'alpha-bg-a') 25%,
  10. getCssVar('color-picker', 'alpha-bg-b') 25%
  11. ),
  12. linear-gradient(
  13. 135deg,
  14. getCssVar('color-picker', 'alpha-bg-a') 25%,
  15. getCssVar('color-picker', 'alpha-bg-b') 25%
  16. ),
  17. linear-gradient(
  18. 45deg,
  19. getCssVar('color-picker', 'alpha-bg-b') 75%,
  20. getCssVar('color-picker', 'alpha-bg-a') 75%
  21. ),
  22. linear-gradient(
  23. 135deg,
  24. getCssVar('color-picker', 'alpha-bg-b') 75%,
  25. getCssVar('color-picker', 'alpha-bg-a') 75%
  26. );
  27. background-size: 12px 12px;
  28. background-position: 0 0, 6px 0, 6px -6px, 0 6px;
  29. }
  30. @include b(color-picker) {
  31. display: inline-block;
  32. position: relative;
  33. line-height: normal;
  34. outline: none;
  35. height: map.get($color-picker-size, 'default');
  36. width: map.get($color-picker-size, 'default');
  37. &:hover:not(.is-disabled, .is-focused) {
  38. .#{$namespace}-color-picker__trigger {
  39. border-color: getCssVar('border-color-hover');
  40. }
  41. }
  42. &:focus-visible:not(.is-disabled) {
  43. .#{$namespace}-color-picker__trigger {
  44. outline: 2px solid getCssVar('color-primary');
  45. outline-offset: 1px;
  46. }
  47. }
  48. @include when(focused) {
  49. .#{$namespace}-color-picker__trigger {
  50. border-color: getCssVar('color-primary');
  51. }
  52. }
  53. @include when(disabled) {
  54. .#{$namespace}-color-picker__trigger {
  55. cursor: not-allowed;
  56. background-color: getCssVar('fill-color', 'light');
  57. }
  58. @include e(color) {
  59. opacity: 0.3;
  60. }
  61. }
  62. @each $size in (large, small) {
  63. @include m($size) {
  64. height: map.get($color-picker-size, $size);
  65. width: map.get($color-picker-size, $size);
  66. }
  67. }
  68. @include m(small) {
  69. .#{$namespace}-color-picker__icon,
  70. .#{$namespace}-color-picker__empty {
  71. transform: scale(0.8);
  72. }
  73. }
  74. @include e(trigger) {
  75. display: inline-flex;
  76. justify-content: center;
  77. align-items: center;
  78. box-sizing: border-box;
  79. height: 100%;
  80. width: 100%;
  81. padding: 4px;
  82. border: 1px solid getCssVar('border-color');
  83. border-radius: 4px;
  84. font-size: 0;
  85. position: relative;
  86. cursor: pointer;
  87. }
  88. @include e(color) {
  89. position: relative;
  90. display: block;
  91. box-sizing: border-box;
  92. border: 1px solid getCssVar('text-color', 'secondary');
  93. border-radius: getCssVar('border-radius-small');
  94. width: 100%;
  95. height: 100%;
  96. text-align: center;
  97. @include when(alpha) {
  98. @include alpha-bg;
  99. // background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
  100. }
  101. }
  102. @include e(color-inner) {
  103. display: inline-flex;
  104. justify-content: center;
  105. align-items: center;
  106. width: 100%;
  107. height: 100%;
  108. }
  109. & .#{$namespace}-color-picker__empty {
  110. font-size: 12px;
  111. color: getCssVar('text-color', 'secondary');
  112. }
  113. & .#{$namespace}-color-picker__icon {
  114. display: inline-flex;
  115. justify-content: center;
  116. align-items: center;
  117. color: $color-white;
  118. font-size: 12px;
  119. }
  120. @include e(panel) {
  121. background-color: $color-white;
  122. border-radius: getCssVar('border-radius-base');
  123. box-shadow: map.get($dropdown, 'menu-box-shadow');
  124. &.#{$namespace}-popper {
  125. border: 1px solid getCssVar('border-color-lighter');
  126. }
  127. }
  128. }
  129. .#{bem('color-picker')},
  130. .#{bem('color-picker', 'panel')} {
  131. @include set-css-var-value(('color-picker', 'alpha-bg-a'), '#ccc');
  132. @include set-css-var-value(('color-picker', 'alpha-bg-b'), 'transparent');
  133. }
  134. .dark {
  135. .#{bem('color-picker')},
  136. .#{bem('color-picker', 'panel')} {
  137. @include set-css-var-value(('color-picker', 'alpha-bg-a'), '#333333');
  138. }
  139. }