option.scss 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'common/var' as *;
  4. $checked-icon: "data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E";
  5. @mixin checked-icon {
  6. content: '';
  7. position: absolute;
  8. top: 50%;
  9. right: 20px;
  10. border-top: none;
  11. border-right: none;
  12. background-repeat: no-repeat;
  13. background-position: center;
  14. background-color: map.get($select-option, 'selected-text-color');
  15. mask: url('#{$checked-icon}') no-repeat;
  16. mask-size: 100% 100%;
  17. -webkit-mask: url('#{$checked-icon}') no-repeat;
  18. -webkit-mask-size: 100% 100%;
  19. transform: translateY(-50%);
  20. width: 12px;
  21. height: 12px;
  22. }
  23. @include b(select-dropdown) {
  24. @include e(item) {
  25. font-size: map.get($select, 'font-size');
  26. // 20 as the padding of option item, 12 as the size of ✓ icon size
  27. padding: 0 #{20 + 12}px 0 20px;
  28. position: relative;
  29. white-space: nowrap;
  30. overflow: hidden;
  31. text-overflow: ellipsis;
  32. color: map.get($select-option, 'text-color');
  33. height: map.get($select-option, 'height');
  34. line-height: map.get($select-option, 'height');
  35. box-sizing: border-box;
  36. cursor: pointer;
  37. @include when(hovering) {
  38. background-color: map.get($select-option, 'hover-background');
  39. }
  40. @include when(selected) {
  41. color: map.get($select-option, 'selected-text-color');
  42. font-weight: bold;
  43. }
  44. @include when(disabled) {
  45. color: map.get($select-option, 'disabled-color');
  46. cursor: not-allowed;
  47. background-color: unset;
  48. }
  49. }
  50. @include when(multiple) {
  51. .#{$namespace}-select-dropdown__item.is-selected {
  52. &::after {
  53. @include checked-icon;
  54. }
  55. }
  56. .#{$namespace}-select-dropdown__item.is-disabled {
  57. &::after {
  58. background-color: map.get($select-option, 'disabled-color');
  59. }
  60. }
  61. }
  62. }