radio-button.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 e(original-radio) {
  67. opacity: 0;
  68. outline: none;
  69. position: absolute;
  70. z-index: -1;
  71. &:checked {
  72. & + .#{$namespace}-radio-button__inner {
  73. color: getCssVarWithDefault(
  74. ('radio-button', 'checked-text-color'),
  75. map.get($radio-button, 'checked-text-color')
  76. );
  77. background-color: getCssVarWithDefault(
  78. 'radio-button-checked-bg-color',
  79. map.get($radio-button, 'checked-bg-color')
  80. );
  81. border-color: getCssVarWithDefault(
  82. 'radio-button-checked-border-color',
  83. map.get($radio-button, 'checked-border-color')
  84. );
  85. box-shadow: -1px 0 0 0
  86. getCssVarWithDefault(
  87. 'radio-button-checked-border-color',
  88. map.get($radio-button, 'checked-border-color')
  89. );
  90. }
  91. }
  92. &:focus-visible {
  93. & + .#{$namespace}-radio-button__inner {
  94. border-left: getCssVar('border');
  95. border-left-color: getCssVarWithDefault(
  96. 'radio-button-checked-border-color',
  97. map.get($radio-button, 'checked-border-color')
  98. );
  99. outline: 2px solid getCssVar('radio-button-checked-border-color');
  100. outline-offset: 1px;
  101. z-index: 2;
  102. border-radius: getCssVar('border-radius-base');
  103. box-shadow: none;
  104. }
  105. }
  106. &:disabled {
  107. & + .#{$namespace}-radio-button__inner {
  108. color: getCssVar('disabled-text-color');
  109. cursor: not-allowed;
  110. background-image: none;
  111. background-color: getCssVarWithDefault(
  112. 'button-disabled-bg-color',
  113. map.get($button, 'disabled-bg-color')
  114. );
  115. border-color: getCssVarWithDefault(
  116. 'button-disabled-border-color',
  117. map.get($button, 'disabled-border-color')
  118. );
  119. box-shadow: none;
  120. }
  121. &:checked + .#{$namespace}-radio-button__inner {
  122. background-color: getCssVar('radio-button-disabled-checked-fill');
  123. }
  124. }
  125. }
  126. &:last-child {
  127. .#{$namespace}-radio-button__inner {
  128. border-radius: 0 getCssVar('border-radius-base')
  129. getCssVar('border-radius-base') 0;
  130. }
  131. }
  132. &:first-child:last-child {
  133. .#{$namespace}-radio-button__inner {
  134. border-radius: getCssVar('border-radius-base');
  135. }
  136. }
  137. @each $size in (large, small) {
  138. @include m($size) {
  139. & .#{$namespace}-radio-button__inner {
  140. @include button-size(
  141. map.get($button-padding-vertical, $size) - $button-border-width,
  142. map.get($button-padding-horizontal, $size) - $button-border-width,
  143. map.get($button-font-size, $size),
  144. 0
  145. );
  146. }
  147. }
  148. }
  149. }