radio.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**Variable**/
  2. @import './helpers/mixin.scss';
  3. @import './base/common.scss';
  4. /*radio-group*/
  5. .vxe-radio-group {
  6. display: inline-block;
  7. vertical-align: middle;
  8. line-height: 1;
  9. font-size: 0;
  10. &+.vxe-radio-group {
  11. margin-left: 10px;
  12. }
  13. }
  14. /*radio*/
  15. .vxe-radio {
  16. display: inline-block;
  17. vertical-align: middle;
  18. white-space: nowrap;
  19. user-select: none;
  20. line-height: 1;
  21. cursor: pointer;
  22. > input {
  23. &[type="radio"] {
  24. position: absolute;
  25. width: 0;
  26. height: 0;
  27. border: 0;
  28. appearance: none;
  29. }
  30. &+.vxe-radio--icon {
  31. position: relative;
  32. display: inline-block;
  33. width: 1em;
  34. height: 1em;
  35. border: $vxe-radio-border-width solid $vxe-input-border-color;
  36. background-color: $vxe-radio-icon-background-color;
  37. vertical-align: middle;
  38. border-radius: 50%;
  39. }
  40. &:checked+.vxe-radio--icon {
  41. background-color: $vxe-primary-color;
  42. border-color: $vxe-primary-color;
  43. &:before {
  44. content: "";
  45. position: absolute;
  46. background-color: $vxe-radio-checked-icon-background-color;
  47. border-radius: 50%;
  48. height: 0.25em;
  49. width: 0.25em;
  50. top: 50%;
  51. left: 50%;
  52. transform: translate(-50%,-50%);
  53. }
  54. &+.vxe-radio--label {
  55. color: $vxe-primary-color;
  56. }
  57. }
  58. }
  59. &:not(.is--disabled) {
  60. & > input {
  61. &:focus {
  62. &+.vxe-radio--icon {
  63. border-color: $vxe-primary-color;
  64. box-shadow: 0 0 0.2em 0 $vxe-primary-color;
  65. }
  66. }
  67. }
  68. &:hover {
  69. > input {
  70. &+.vxe-radio--icon {
  71. border-color: $vxe-primary-color;
  72. }
  73. }
  74. }
  75. }
  76. &.is--disabled {
  77. cursor: not-allowed;
  78. > input {
  79. &+.vxe-radio--icon {
  80. border-color: $vxe-input-disabled-color;
  81. background-color: $vxe-input-disabled-background-color;
  82. &:before {
  83. border-color: $vxe-primary-disabled-color;
  84. background-color: $vxe-primary-disabled-color;
  85. }
  86. &+.vxe-radio--label {
  87. color: $vxe-disabled-color;
  88. }
  89. }
  90. }
  91. }
  92. .vxe-radio--label {
  93. padding-left: 0.5em;
  94. vertical-align: middle;
  95. display: inline-block;
  96. max-width: 50em;
  97. @extend %TextEllipsis;
  98. }
  99. &:not(.vxe-radio-button) {
  100. &+.vxe-radio {
  101. margin-left: 10px;
  102. }
  103. }
  104. }
  105. .vxe-radio-button {
  106. .vxe-radio--label {
  107. background-color: #fff;
  108. }
  109. &:first-child {
  110. .vxe-radio--label {
  111. border-left: 1px solid $vxe-input-border-color;
  112. border-radius: $vxe-border-radius 0 0 $vxe-border-radius;
  113. }
  114. }
  115. &:last-child {
  116. .vxe-radio--label {
  117. border-radius: 0 $vxe-border-radius $vxe-border-radius 0;
  118. }
  119. }
  120. > input {
  121. &:checked+.vxe-radio--label {
  122. color: #fff;
  123. background-color: $vxe-primary-color;
  124. border-color: $vxe-primary-color;
  125. }
  126. }
  127. .vxe-radio--label {
  128. padding: 0 1em;
  129. line-height: $vxe-button-height-default - 2;
  130. display: inline-block;
  131. border-style: solid;
  132. border-color: $vxe-input-border-color;
  133. border-width: 1px 1px 1px 0;
  134. max-width: 50em;
  135. @extend %TextEllipsis;
  136. }
  137. &.is--disabled {
  138. cursor: not-allowed;
  139. > input {
  140. &:not(:checked) {
  141. &+.vxe-radio--label {
  142. color: $vxe-input-disabled-color;
  143. }
  144. }
  145. &:checked {
  146. &+.vxe-radio--label {
  147. border-color: lighten($vxe-primary-color, 20%);
  148. background-color: lighten($vxe-primary-color, 20%);
  149. }
  150. }
  151. }
  152. }
  153. &:not(.is--disabled) {
  154. & > input {
  155. &:focus {
  156. &+.vxe-radio--label {
  157. border-color: $vxe-primary-color;
  158. box-shadow: 0 0 0.2em 0 $vxe-primary-color;
  159. }
  160. }
  161. }
  162. &:hover {
  163. > input {
  164. &:not(:checked) {
  165. &+.vxe-radio--label {
  166. color: $vxe-primary-color;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. &.size--medium {
  173. .vxe-radio--label {
  174. line-height: $vxe-button-height-medium - 2;
  175. }
  176. }
  177. &.size--small {
  178. .vxe-radio--label {
  179. line-height: $vxe-button-height-small - 2;
  180. }
  181. }
  182. &.size--mini {
  183. .vxe-radio--label {
  184. line-height: $vxe-button-height-mini - 2;
  185. }
  186. }
  187. }
  188. .vxe-radio {
  189. font-size: $vxe-font-size;
  190. .vxe-radio--icon {
  191. font-size: $vxe-radio-font-size-default;
  192. }
  193. &.size--medium {
  194. font-size: $vxe-font-size-medium;
  195. .vxe-radio--icon {
  196. font-size: $vxe-radio-font-size-medium;
  197. }
  198. }
  199. &.size--small {
  200. font-size: $vxe-font-size-small;
  201. .vxe-radio--icon {
  202. font-size: $vxe-radio-font-size-small;
  203. }
  204. }
  205. &.size--mini {
  206. font-size: $vxe-font-size-mini;
  207. .vxe-radio--icon {
  208. font-size: $vxe-radio-font-size-mini;
  209. }
  210. }
  211. }