checkbox-button.scss 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. @use 'sass:map';
  2. @use 'common/var' as *;
  3. @use 'mixins/mixins' as *;
  4. @use 'mixins/utils' as *;
  5. @use 'mixins/var' as *;
  6. @use 'mixins/button' as *;
  7. @include b(checkbox-button) {
  8. @include set-component-css-var('checkbox-button', $checkbox-button);
  9. }
  10. @include b(checkbox-button) {
  11. position: relative;
  12. display: inline-block;
  13. @include e(inner) {
  14. display: inline-block;
  15. line-height: 1;
  16. font-weight: getCssVar('checkbox-font-weight');
  17. white-space: nowrap;
  18. vertical-align: middle;
  19. cursor: pointer;
  20. background: var(
  21. #{getCssVarName('button-bg-color')},
  22. map.get($button, 'bg-color')
  23. );
  24. border: getCssVar('border');
  25. border-left-color: transparent;
  26. color: var(
  27. #{getCssVarName('button-text-color')},
  28. map.get($button, 'text-color')
  29. );
  30. -webkit-appearance: none;
  31. text-align: center;
  32. box-sizing: border-box;
  33. outline: none;
  34. margin: 0;
  35. position: relative;
  36. transition: getCssVar('transition-all');
  37. user-select: none;
  38. @include button-size(
  39. map.get($button-padding-vertical, 'default') - $button-border-width,
  40. map.get($button-padding-horizontal, 'default') - $button-border-width,
  41. map.get($button-font-size, 'default'),
  42. 0
  43. );
  44. &:hover {
  45. color: getCssVar('color-primary');
  46. }
  47. & [class*='#{$namespace}-icon-'] {
  48. line-height: 0.9;
  49. & + span {
  50. margin-left: 5px;
  51. }
  52. }
  53. }
  54. @include e(original) {
  55. opacity: 0;
  56. outline: none;
  57. position: absolute;
  58. margin: 0;
  59. z-index: -1;
  60. }
  61. &.is-checked {
  62. & .#{$namespace}-checkbox-button__inner {
  63. color: getCssVar('checkbox-button-checked-text-color');
  64. background-color: getCssVar('checkbox-button-checked-bg-color');
  65. border-color: getCssVar('checkbox-button-checked-border-color');
  66. box-shadow: -1px 0 0 0 getCssVar('color-primary-light-7');
  67. }
  68. &:first-child .#{$namespace}-checkbox-button__inner {
  69. border-left-color: getCssVar('checkbox-button-checked-border-color');
  70. }
  71. }
  72. &.is-disabled {
  73. & .#{$namespace}-checkbox-button__inner {
  74. color: getCssVar('disabled-text-color');
  75. cursor: not-allowed;
  76. background-image: none;
  77. background-color: var(
  78. #{getCssVarName('button-disabled-bg-color')},
  79. map.get($button, 'disabled-bg-color')
  80. );
  81. border-color: var(
  82. #{getCssVarName('button-disabled-border-color')},
  83. map.get($button, 'disabled-border-color')
  84. );
  85. box-shadow: none;
  86. }
  87. &:first-child .#{$namespace}-checkbox-button__inner {
  88. border-left-color: var(
  89. #{getCssVarName('button-disabled-border-color')},
  90. map.get($button, 'disabled-border-color')
  91. );
  92. }
  93. }
  94. &:first-child {
  95. .#{$namespace}-checkbox-button__inner {
  96. border-left: getCssVar('border');
  97. border-top-left-radius: getCssVar('border-radius-base');
  98. border-bottom-left-radius: getCssVar('border-radius-base');
  99. box-shadow: none !important;
  100. }
  101. }
  102. &.is-focus {
  103. & .#{$namespace}-checkbox-button__inner {
  104. border-color: getCssVar('checkbox-button-checked-border-color');
  105. }
  106. }
  107. &:last-child {
  108. .#{$namespace}-checkbox-button__inner {
  109. border-top-right-radius: getCssVar('border-radius-base');
  110. border-bottom-right-radius: getCssVar('border-radius-base');
  111. }
  112. }
  113. @each $size in (large, small) {
  114. @include m($size) {
  115. .#{$namespace}-checkbox-button__inner {
  116. @include button-size(
  117. map.get($button-padding-vertical, $size) - $button-border-width,
  118. map.get($button-padding-horizontal, $size) - $button-border-width,
  119. map.get($button-font-size, $size),
  120. 0
  121. );
  122. }
  123. }
  124. }
  125. }