index-pure.less 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @radio-prefix-cls: ~'@{ant-prefix}-radio';
  4. @radio-group-prefix-cls: ~'@{radio-prefix-cls}-group';
  5. @radio-inner-prefix-cls: ~'@{radio-prefix-cls}-inner';
  6. @radio-duration: 0.3s;
  7. @radio-focus-shadow: 0 0 0 3px @primary-1;
  8. @radio-button-focus-shadow: @radio-focus-shadow;
  9. .@{radio-group-prefix-cls} {
  10. .reset-component();
  11. display: inline-block;
  12. font-size: 0;
  13. .@{ant-prefix}-badge-count {
  14. z-index: 1;
  15. }
  16. > .@{ant-prefix}-badge:not(:first-child) > .@{radio-prefix-cls}-button-wrapper {
  17. border-left: none;
  18. }
  19. }
  20. // 一般状态
  21. .@{radio-prefix-cls}-wrapper {
  22. .reset-component();
  23. position: relative;
  24. display: inline-flex;
  25. align-items: baseline;
  26. margin-right: @radio-wrapper-margin-right;
  27. cursor: pointer;
  28. &-disabled {
  29. cursor: not-allowed;
  30. }
  31. &::after {
  32. display: inline-block;
  33. width: 0;
  34. overflow: hidden;
  35. content: '\a0';
  36. }
  37. }
  38. .@{radio-prefix-cls} {
  39. .reset-component();
  40. position: relative;
  41. top: @radio-top;
  42. display: inline-block;
  43. outline: none;
  44. cursor: pointer;
  45. .@{radio-prefix-cls}-wrapper:hover &,
  46. &:hover .@{radio-inner-prefix-cls},
  47. &-input:focus + .@{radio-inner-prefix-cls} {
  48. border-color: @radio-dot-color;
  49. }
  50. &-input:focus + .@{radio-inner-prefix-cls} {
  51. box-shadow: @radio-focus-shadow;
  52. }
  53. &-checked::after {
  54. position: absolute;
  55. top: 0;
  56. left: 0;
  57. width: 100%;
  58. height: 100%;
  59. border: 1px solid @radio-dot-color;
  60. border-radius: 50%;
  61. visibility: hidden;
  62. animation: antRadioEffect 0.36s ease-in-out;
  63. animation-fill-mode: both;
  64. content: '';
  65. }
  66. &:hover::after,
  67. .@{radio-prefix-cls}-wrapper:hover &::after {
  68. visibility: visible;
  69. }
  70. &-inner {
  71. &::after {
  72. position: absolute;
  73. top: 50%;
  74. left: 50%;
  75. display: block;
  76. width: @radio-size;
  77. height: @radio-size;
  78. margin-top: -(@radio-size / 2);
  79. margin-left: -(@radio-size / 2);
  80. background-color: @radio-dot-color;
  81. border-top: 0;
  82. border-left: 0;
  83. border-radius: @radio-size;
  84. transform: scale(0);
  85. opacity: 0;
  86. transition: all @radio-duration @ease-in-out-circ;
  87. content: ' ';
  88. }
  89. position: relative;
  90. top: 0;
  91. left: 0;
  92. display: block;
  93. width: @radio-size;
  94. height: @radio-size;
  95. background-color: @radio-button-bg;
  96. border-color: @border-color-base;
  97. border-style: solid;
  98. border-width: @radio-border-width;
  99. border-radius: 50%;
  100. transition: all @radio-duration;
  101. }
  102. &-input {
  103. position: absolute;
  104. top: 0;
  105. right: 0;
  106. bottom: 0;
  107. left: 0;
  108. z-index: 1;
  109. cursor: pointer;
  110. opacity: 0;
  111. }
  112. }
  113. // 选中状态
  114. .@{radio-prefix-cls}-checked {
  115. .@{radio-inner-prefix-cls} {
  116. border-color: @radio-dot-color;
  117. &::after {
  118. transform: scale((unit(@radio-dot-size) / unit(@radio-size)));
  119. opacity: 1;
  120. transition: all @radio-duration @ease-in-out-circ;
  121. }
  122. }
  123. }
  124. .@{radio-prefix-cls}-disabled {
  125. cursor: not-allowed;
  126. .@{radio-inner-prefix-cls} {
  127. background-color: @input-disabled-bg;
  128. border-color: @border-color-base !important;
  129. cursor: not-allowed;
  130. &::after {
  131. background-color: @radio-dot-disabled-color;
  132. }
  133. }
  134. .@{radio-prefix-cls}-input {
  135. cursor: not-allowed;
  136. }
  137. & + span {
  138. color: @disabled-color;
  139. cursor: not-allowed;
  140. }
  141. }
  142. span.@{radio-prefix-cls} + * {
  143. padding-right: 8px;
  144. padding-left: 8px;
  145. }
  146. .@{radio-prefix-cls}-button-wrapper {
  147. position: relative;
  148. display: inline-block;
  149. height: @btn-height-base;
  150. margin: 0;
  151. padding: 0 @radio-button-padding-horizontal;
  152. color: @radio-button-color;
  153. font-size: @font-size-base;
  154. line-height: @btn-height-base - 2px;
  155. background: @radio-button-bg;
  156. border: @border-width-base @border-style-base @border-color-base;
  157. // strange align fix for chrome but works
  158. // https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
  159. border-top-width: @border-width-base + 0.02px;
  160. border-left-width: 0;
  161. cursor: pointer;
  162. transition: color 0.3s, background 0.3s, border-color 0.3s, box-shadow 0.3s;
  163. a {
  164. color: @radio-button-color;
  165. }
  166. > .@{radio-prefix-cls}-button {
  167. position: absolute;
  168. top: 0;
  169. left: 0;
  170. z-index: -1;
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .@{radio-group-prefix-cls}-large & {
  175. height: @input-height-lg;
  176. font-size: @font-size-lg;
  177. line-height: @input-height-lg - 2px;
  178. }
  179. .@{radio-group-prefix-cls}-small & {
  180. height: @input-height-sm;
  181. padding: 0 @control-padding-horizontal-sm - 1px;
  182. line-height: @input-height-sm - 2px;
  183. }
  184. &:not(:first-child) {
  185. &::before {
  186. position: absolute;
  187. top: @border-width-base * -1;
  188. left: -1px;
  189. display: block;
  190. box-sizing: content-box;
  191. width: 1px;
  192. height: 100%;
  193. padding: @border-width-base 0;
  194. background-color: @border-color-base;
  195. transition: background-color 0.3s;
  196. content: '';
  197. }
  198. }
  199. &:first-child {
  200. border-left: @border-width-base @border-style-base @border-color-base;
  201. border-radius: @border-radius-base 0 0 @border-radius-base;
  202. }
  203. &:last-child {
  204. border-radius: 0 @border-radius-base @border-radius-base 0;
  205. }
  206. &:first-child:last-child {
  207. border-radius: @border-radius-base;
  208. }
  209. &:hover {
  210. position: relative;
  211. color: @radio-dot-color;
  212. }
  213. &:focus-within {
  214. box-shadow: @radio-button-focus-shadow;
  215. }
  216. .@{radio-prefix-cls}-inner,
  217. input[type='checkbox'],
  218. input[type='radio'] {
  219. width: 0;
  220. height: 0;
  221. opacity: 0;
  222. pointer-events: none;
  223. }
  224. &-checked:not(&-disabled) {
  225. z-index: 1;
  226. color: @radio-dot-color;
  227. background: @radio-button-checked-bg;
  228. border-color: @radio-dot-color;
  229. &::before {
  230. background-color: @radio-dot-color;
  231. }
  232. &:first-child {
  233. border-color: @radio-dot-color;
  234. }
  235. &:hover {
  236. color: @radio-button-hover-color;
  237. border-color: @radio-button-hover-color;
  238. &::before {
  239. background-color: @radio-button-hover-color;
  240. }
  241. }
  242. &:active {
  243. color: @radio-button-active-color;
  244. border-color: @radio-button-active-color;
  245. &::before {
  246. background-color: @radio-button-active-color;
  247. }
  248. }
  249. &:focus-within {
  250. box-shadow: @radio-button-focus-shadow;
  251. }
  252. }
  253. .@{radio-group-prefix-cls}-solid &-checked:not(&-disabled) {
  254. color: @radio-solid-checked-color;
  255. background: @radio-dot-color;
  256. border-color: @radio-dot-color;
  257. &:hover {
  258. color: @radio-solid-checked-color;
  259. background: @radio-button-hover-color;
  260. border-color: @radio-button-hover-color;
  261. }
  262. &:active {
  263. color: @radio-solid-checked-color;
  264. background: @radio-button-active-color;
  265. border-color: @radio-button-active-color;
  266. }
  267. &:focus-within {
  268. box-shadow: @radio-button-focus-shadow;
  269. }
  270. }
  271. &-disabled {
  272. color: @disabled-color;
  273. background-color: @input-disabled-bg;
  274. border-color: @border-color-base;
  275. cursor: not-allowed;
  276. &:first-child,
  277. &:hover {
  278. color: @disabled-color;
  279. background-color: @input-disabled-bg;
  280. border-color: @border-color-base;
  281. }
  282. &:first-child {
  283. border-left-color: @border-color-base;
  284. }
  285. }
  286. &-disabled&-checked {
  287. color: @radio-disabled-button-checked-color;
  288. background-color: @radio-disabled-button-checked-bg;
  289. border-color: @border-color-base;
  290. box-shadow: none;
  291. }
  292. }
  293. @keyframes antRadioEffect {
  294. 0% {
  295. transform: scale(1);
  296. opacity: 0.5;
  297. }
  298. 100% {
  299. transform: scale(1.6);
  300. opacity: 0;
  301. }
  302. }
  303. @import './rtl';