radio-button.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'mixins/button' as *;
  5. @use 'common/var' as *;
  6. @include b(radio-button) {
  7. @include set-component-css-var('radio-button', $radio-button);
  8. }
  9. @include b(radio-button) {
  10. position: relative;
  11. display: inline-block;
  12. outline: none;
  13. @include e(inner) {
  14. display: inline-block;
  15. line-height: 1;
  16. white-space: nowrap;
  17. vertical-align: middle;
  18. background: var(
  19. #{getCssVarName('button-bg-color')},
  20. map.get($button, 'bg-color')
  21. );
  22. outline: getCssVar('border');
  23. font-weight: var(
  24. #{getCssVarName('button-font-weight')},
  25. map.get($button, 'font-weight')
  26. );
  27. color: var(
  28. #{getCssVarName('button-text-color')},
  29. map.get($button, 'text-color')
  30. );
  31. -webkit-appearance: none;
  32. text-align: center;
  33. box-sizing: border-box;
  34. margin: 0;
  35. position: relative;
  36. cursor: pointer;
  37. transition: getCssVar('transition-all');
  38. user-select: none;
  39. @include button-size(
  40. map.get($button-padding-vertical, 'default') - $button-border-width,
  41. map.get($button-padding-horizontal, 'default') - $button-border-width,
  42. map.get($button-font-size, 'default'),
  43. 0
  44. );
  45. &:hover {
  46. color: getCssVar('color-primary');
  47. }
  48. & [class*='#{$namespace}-icon-'] {
  49. line-height: 0.9;
  50. & + span {
  51. margin-left: 5px;
  52. }
  53. }
  54. }
  55. &:first-child {
  56. .#{$namespace}-radio-button__inner {
  57. border-radius: getCssVar('border-radius-base') 0 0
  58. getCssVar('border-radius-base');
  59. box-shadow: none !important;
  60. }
  61. }
  62. @include when(active) {
  63. @include e(original-radio) {
  64. &:not(:disabled) {
  65. & + .#{$namespace}-radio-button__inner {
  66. color: getCssVarWithDefault(
  67. ('radio-button', 'checked-text-color'),
  68. map.get($radio-button, 'checked-text-color')
  69. );
  70. background-color: getCssVarWithDefault(
  71. 'radio-button-checked-bg-color',
  72. map.get($radio-button, 'checked-bg-color')
  73. );
  74. border-color: getCssVarWithDefault(
  75. 'radio-button-checked-border-color',
  76. map.get($radio-button, 'checked-border-color')
  77. );
  78. box-shadow: -1px 0 0 0
  79. getCssVarWithDefault(
  80. 'radio-button-checked-border-color',
  81. map.get($radio-button, 'checked-border-color')
  82. );
  83. }
  84. }
  85. }
  86. }
  87. @include e(original-radio) {
  88. opacity: 0;
  89. outline: none;
  90. position: absolute;
  91. z-index: -1;
  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. }