radio-button.scss 4.4 KB

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