786b65a2129a7b3d5f5f18964b73ea3fe57cb63d7786f7fd676ffc26164415288575b5f8510ff2fba790dc60dbafa7e3dac1ed83b297279397e57f24963eea 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. @use 'mixins/mixins' as *;
  2. @use 'common/var' as *;
  3. @mixin disable {
  4. cursor: not-allowed;
  5. opacity: 0.3;
  6. }
  7. @mixin alpha-bg {
  8. background-image: linear-gradient(
  9. 45deg,
  10. getCssVar('color-picker', 'alpha-bg-a') 25%,
  11. getCssVar('color-picker', 'alpha-bg-b') 25%
  12. ),
  13. linear-gradient(
  14. 135deg,
  15. getCssVar('color-picker', 'alpha-bg-a') 25%,
  16. getCssVar('color-picker', 'alpha-bg-b') 25%
  17. ),
  18. linear-gradient(
  19. 45deg,
  20. getCssVar('color-picker', 'alpha-bg-b') 75%,
  21. getCssVar('color-picker', 'alpha-bg-a') 75%
  22. ),
  23. linear-gradient(
  24. 135deg,
  25. getCssVar('color-picker', 'alpha-bg-b') 75%,
  26. getCssVar('color-picker', 'alpha-bg-a') 75%
  27. );
  28. background-size: 12px 12px;
  29. background-position: 0 0, 6px 0, 6px -6px, 0 6px;
  30. }
  31. @mixin color-picker-thumb {
  32. position: absolute;
  33. cursor: pointer;
  34. box-sizing: border-box;
  35. left: 0;
  36. top: 0;
  37. width: 4px;
  38. height: 100%;
  39. border-radius: 1px;
  40. background: #fff;
  41. border: 1px solid getCssVar('border-color', 'lighter');
  42. box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  43. z-index: 1;
  44. &:focus-visible {
  45. outline: 2px solid getCssVar('color-primary');
  46. outline-offset: 1px;
  47. }
  48. }
  49. @mixin bar-background($side: right) {
  50. background: linear-gradient(
  51. to $side,
  52. #f00 0%,
  53. #ff0 17%,
  54. #0f0 33%,
  55. #0ff 50%,
  56. #00f 67%,
  57. #f0f 83%,
  58. #f00 100%
  59. );
  60. }
  61. @include b(color-picker-panel) {
  62. width: 300px;
  63. padding: 12px;
  64. box-sizing: content-box;
  65. background: getCssVar('bg-color', 'overlay');
  66. @include when(border) {
  67. border: solid 1px getCssVar('border-color-lighter');
  68. border-radius: 4px;
  69. }
  70. @include e(wrapper) {
  71. margin-bottom: 6px;
  72. @include e(footer) {
  73. display: flex;
  74. justify-content: space-between;
  75. margin-top: 12px;
  76. text-align: right;
  77. @include b(input) {
  78. line-height: 26px;
  79. font-size: 12px;
  80. color: $color-black;
  81. width: 160px;
  82. }
  83. }
  84. }
  85. @include when(disabled) {
  86. @include b(color-svpanel) {
  87. @include disable;
  88. }
  89. @include b(color-hue-slider) {
  90. @include disable;
  91. }
  92. @include e(thumb) {
  93. cursor: not-allowed;
  94. }
  95. @include b(color-alpha-slider) {
  96. @include disable;
  97. }
  98. @include b(color-predefine) {
  99. @include e(color-selector) {
  100. @include disable;
  101. }
  102. }
  103. }
  104. }
  105. @include b(color-predefine) {
  106. display: flex;
  107. font-size: 12px;
  108. margin-top: 8px;
  109. width: 280px;
  110. @include e(colors) {
  111. display: flex;
  112. gap: 8px;
  113. flex: 1;
  114. flex-wrap: wrap;
  115. }
  116. @include e(color-selector) {
  117. width: 20px;
  118. height: 20px;
  119. border-radius: 4px;
  120. cursor: pointer;
  121. &.selected {
  122. box-shadow: 0 0 3px 2px getCssVar('color-primary');
  123. }
  124. > div {
  125. display: flex;
  126. height: 100%;
  127. border-radius: 3px;
  128. }
  129. @include when(alpha) {
  130. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
  131. }
  132. }
  133. }
  134. @include b(color-hue-slider) {
  135. position: relative;
  136. box-sizing: border-box;
  137. width: 280px;
  138. height: 12px;
  139. background-color: #f00;
  140. padding: 0 2px;
  141. float: right;
  142. @include e(bar) {
  143. position: relative;
  144. @include bar-background;
  145. height: 100%;
  146. }
  147. @include e(thumb) {
  148. @include color-picker-thumb;
  149. }
  150. @include when(vertical) {
  151. width: 12px;
  152. height: 180px;
  153. padding: 2px 0;
  154. .#{$namespace}-color-hue-slider__bar {
  155. @include bar-background(bottom);
  156. }
  157. .#{$namespace}-color-hue-slider__thumb {
  158. left: 0;
  159. top: 0;
  160. width: 100%;
  161. height: 4px;
  162. }
  163. }
  164. }
  165. @include b(color-svpanel) {
  166. position: relative;
  167. width: 280px;
  168. height: 180px;
  169. @include e(('white', 'black')) {
  170. position: absolute;
  171. top: 0;
  172. left: 0;
  173. right: 0;
  174. bottom: 0;
  175. }
  176. @include e('white') {
  177. background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
  178. }
  179. @include e('black') {
  180. background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
  181. }
  182. @include e(cursor) {
  183. position: absolute;
  184. > div {
  185. cursor: head;
  186. width: 4px;
  187. height: 4px;
  188. box-shadow: 0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0, 0, 0, 0.3),
  189. 0 0 1px 2px rgba(0, 0, 0, 0.4);
  190. border-radius: 50%;
  191. transform: translate(-2px, -2px);
  192. }
  193. }
  194. }
  195. @include b(color-alpha-slider) {
  196. position: relative;
  197. box-sizing: border-box;
  198. width: 280px;
  199. height: 12px;
  200. @include alpha-bg;
  201. @include when(disabled) {
  202. @include e(thumb) {
  203. cursor: not-allowed;
  204. }
  205. }
  206. @include e(bar) {
  207. position: relative;
  208. background: linear-gradient(
  209. to right,
  210. rgba(255, 255, 255, 0) 0%,
  211. getCssVar('bg-color') 100%
  212. );
  213. height: 100%;
  214. }
  215. @include e(thumb) {
  216. @include color-picker-thumb;
  217. }
  218. @include when(vertical) {
  219. width: 20px;
  220. height: 180px;
  221. .#{$namespace}-color-alpha-slider__bar {
  222. background: linear-gradient(
  223. to bottom,
  224. rgba(255, 255, 255, 0) 0%,
  225. rgba(255, 255, 255, 1) 100%
  226. );
  227. }
  228. .#{$namespace}-color-alpha-slider__thumb {
  229. left: 0;
  230. top: 0;
  231. width: 100%;
  232. height: 4px;
  233. }
  234. }
  235. }
  236. .#{bem('color-picker-panel')} {
  237. @include set-css-var-value(('color-picker', 'alpha-bg-a'), '#ccc');
  238. @include set-css-var-value(('color-picker', 'alpha-bg-b'), 'transparent');
  239. }
  240. .dark {
  241. .#{bem('color-picker-panel')} {
  242. @include set-css-var-value(('color-picker', 'alpha-bg-a'), '#333333');
  243. }
  244. }