1
0

checkbox.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. //@import '../theme/variables.scss';
  2. // @import '../theme/mixin.scss';
  3. @import "./variables.scss";
  4. @import "./animation.scss";
  5. @import "./mixin.scss";
  6. $module: #{$prefix}-checkbox;
  7. .#{$module} {
  8. @include box-sizing;
  9. // box-sizing: border-box;
  10. position: relative;
  11. display: flex;
  12. align-items: center;
  13. flex-wrap: wrap;
  14. @include font-size-regular;
  15. cursor: pointer;
  16. transition: background-color $transition_duration-checkbox-bg $transition_function-checkbox-bg $transition_delay-checkbox-bg,
  17. border $transition_duration-checkbox-border $transition_function-checkbox-border $transition_delay-checkbox-border;
  18. transform: scale($transform_scale-checkbox);
  19. input[type="checkbox"] {
  20. position: absolute;
  21. left: 0;
  22. top: 0;
  23. width: 100%;
  24. height: 100%;
  25. margin: 0;
  26. opacity: 0;
  27. }
  28. &-addon {
  29. display: flex;
  30. flex: 1;
  31. align-items: center;
  32. padding-left: $spacing-checkbox_label-paddingLeft;
  33. color: $color-checkbox_label-text-default;
  34. line-height: $font-checkbox_label-lineHeight;
  35. user-select: none;
  36. }
  37. &:hover {
  38. .#{$module}-inner-display {
  39. background: $color-checkbox_default-bg-hover;
  40. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_default-border-hover;
  41. }
  42. .#{$module}-inner-checked {
  43. .#{$module}-inner-display {
  44. background: $color-checkbox_checked-bg-hover;
  45. box-shadow: none;
  46. }
  47. }
  48. }
  49. &:active {
  50. .#{$module}-inner-display {
  51. background: $color-checkbox_default-bg-active;
  52. }
  53. .#{$module}-inner-checked {
  54. .#{$module}-inner-display {
  55. background: $color-checkbox_checked-bg-active;
  56. box-shadow: none;
  57. }
  58. }
  59. }
  60. &.#{$module}-disabled:hover,
  61. &.#{$module}-disabled:active {
  62. .#{$module}-inner-display {
  63. background: $color-checkbox_disabled-bg-default;
  64. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_disabled-border-default;
  65. }
  66. .#{$module}-inner-checked {
  67. .#{$module}-inner-display {
  68. background: $color-checkbox_checked-bg-disabled;
  69. box-shadow: none;
  70. }
  71. }
  72. }
  73. &-inner {
  74. position: relative;
  75. display: flex;
  76. align-items: center;
  77. width: $width-checkbox_inner;
  78. height: $height-checkbox_inner;
  79. user-select: none; // prevent text under it will be selected when double click
  80. cursor: pointer;
  81. &-display {
  82. @include box-sizing;
  83. position: relative;
  84. width: $width-checkbox_inner;
  85. height: $width-checkbox_inner;
  86. margin: 0;
  87. background: $color-checkbox_default-bg-default;
  88. transition: background-color $transition_duration-checkbox-bg $transition_function-checkbox-bg $transition_delay-checkbox-bg,
  89. border $transition_duration-checkbox-border $transition_function-checkbox-border $transition_delay-checkbox-border;
  90. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_default-border-default;
  91. border-radius: $radius-checkbox_inner;
  92. .#{$prefix}-icon {
  93. font-size: 16px;
  94. }
  95. }
  96. }
  97. &-inner-checked {
  98. .#{$module}-inner-display {
  99. background: $color-checkbox_checked-bg-default;
  100. color: $color-checkbox_checked-icon-default;
  101. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_checked-border-default;
  102. border-radius: $radius-checkbox_inner;
  103. }
  104. &>.#{$module}-addon {
  105. color: $color-checkbox_label-text-default;
  106. }
  107. }
  108. &:hover {
  109. .#{$module}-inner-display {
  110. background: $color-checkbox_default-bg-hover;
  111. }
  112. &.#{$module}-indeterminate .#{$module}-inner-display {
  113. background: $color-checkbox_checked-bg-hover;
  114. box-shadow: none;
  115. color: $color-checkbox_checked-icon-hover;
  116. }
  117. .#{$module}-inner-checked {
  118. .#{$module}-inner-display {
  119. background: $color-checkbox_checked-bg-hover;
  120. border-color: $color-checkbox_checked-border-hover;
  121. color: $color-checkbox_checked-icon-hover;
  122. }
  123. }
  124. &.#{$module}-cardType.#{$module}-unChecked.#{$module}-cardType_unDisabled {
  125. .#{$module}-inner-display {
  126. background: $color-checkbox_cardType_inner-bg-hover;
  127. }
  128. }
  129. }
  130. &:active {
  131. .#{$module}-inner-display {
  132. background: $color-checkbox_default-bg-active;
  133. }
  134. &.#{$module}-indeterminate .#{$module}-inner-display {
  135. background: $color-checkbox_checked-bg-active;
  136. border-color: $color-checkbox_checked-border-active;
  137. color: $color-checkbox_checked-icon-active;
  138. box-shadow: none;
  139. }
  140. .#{$module}-inner-checked {
  141. .#{$module}-inner-display {
  142. background: $color-checkbox_checked-bg-active;
  143. border-color: $color-checkbox_checked-border-active;
  144. color: $color-checkbox_checked-icon-active;
  145. }
  146. }
  147. &.#{$module}-cardType.#{$module}-unChecked.#{$module}-cardType_unDisabled {
  148. .#{$module}-inner-display {
  149. background: $color-checkbox_cardType_inner-bg-active;
  150. }
  151. }
  152. }
  153. &-cardType {
  154. flex-wrap: nowrap;
  155. align-items: flex-start;
  156. border-radius: $radius-checkbox_cardType;
  157. padding: $spacing-checkbox_cardType-paddingY $spacing-checkbox_cardType-paddingX;
  158. background: transparent;
  159. border: $width-checkbox_cardType_checked-border solid transparent;
  160. .#{$module}-inner {
  161. position: relative;
  162. &-display {
  163. background: $color-checkbox_cardType_inner-bg-default;
  164. }
  165. margin-right: $spacing-checkbox_cardType_inner-marginRight;
  166. flex-shrink: 0;
  167. }
  168. .#{$module}-inner-pureCardType {
  169. // Reasons to use opacity:0 & width: 0 instead of display: none
  170. // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
  171. // input focus/blur cannot take effect when display: none
  172. opacity: 0;
  173. width: 0;
  174. margin-right: 0;
  175. }
  176. .#{$module}-addon {
  177. font-weight: $font-checkbox_cardType_addon-fontWeight;
  178. font-size: $font-checkbox_cardType_addon-size;
  179. line-height: $font-checkbox_cardType_addon-lineHeight;
  180. color: $color-checkbox_cardType_addon-text-default;
  181. margin-left: 0;
  182. padding-left: 0;
  183. }
  184. .#{$module}-extra {
  185. font-weight: $font-checkbox_cardType_extra-fontWeight;
  186. font-size: $font-checkbox_cardType_extra-size;
  187. line-height: $font-checkbox_cardType_extra-lineHeight;
  188. color: $color-checkbox_cardType_extra-text-default;
  189. padding-left: 0;
  190. &.#{$module}-cardType_extra_noChildren {
  191. margin-top: 0;
  192. }
  193. }
  194. &:hover {
  195. background: $color-checkbox_cardType-bg-hover;
  196. }
  197. &:active {
  198. background: $color-checkbox_cardType-bg-active;
  199. }
  200. &_checked {
  201. background: $color-checkbox_cardType_checked-bg;
  202. border: $width-checkbox_cardType_checked-border solid $color-checkbox_cardType_checked_border-default;
  203. &:hover {
  204. background: $color-checkbox_cardType_checked-bg;
  205. border-color: $color-checkbox_cardType_checked_border-hover;
  206. .#{$module}-inner-checked .#{$module}-inner-display {
  207. box-shadow: none;
  208. }
  209. }
  210. &:active {
  211. background: $color-checkbox_cardType_checked-bg;
  212. border-color: $color-checkbox_cardType_checked_border-active;
  213. }
  214. }
  215. &_disabled {
  216. &:active {
  217. background: transparent;
  218. }
  219. &:hover {
  220. background: transparent;
  221. }
  222. }
  223. &_checked_disabled.#{$module}-cardType {
  224. background: $color-checkbox_cardType_checked_disabled-bg;
  225. border: $width-checkbox_cardType_checked_disabled-border solid $color-checkbox_cardType_checked_disabled_border-default;
  226. &:hover {
  227. .#{$module}-inner-checked .#{$module}-inner-display {
  228. box-shadow: none;
  229. }
  230. }
  231. }
  232. }
  233. &-indeterminate,
  234. &-checked {
  235. .#{$module}-inner {
  236. &-display {
  237. background: $color-checkbox_checked-bg-default;
  238. color: $color-checkbox_checked-icon-default;
  239. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_checked-border-default;
  240. border-radius: $radius-checkbox_inner;
  241. &:hover {
  242. background: $color-checkbox_checked-bg-hover;
  243. border-color: $color-checkbox_checked-border-hover;
  244. color: $color-checkbox_checked-icon-hover;
  245. }
  246. &:active {
  247. background: $color-checkbox_checked-bg-active;
  248. border-color: $color-checkbox_checked-border-active;
  249. color: $color-checkbox_checked-icon-active;
  250. }
  251. }
  252. &-addon {
  253. color: $color-checkbox_label-text-default;
  254. }
  255. }
  256. }
  257. &-disabled {
  258. cursor: not-allowed;
  259. .#{$module}-inner {
  260. cursor: not-allowed;
  261. &-display {
  262. color: $color-checkbox_checked-icon-disabled;
  263. background: $color-checkbox_disabled-bg-default;
  264. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_disabled-border-default;
  265. &:hover {
  266. color: $color-checkbox_checked-icon-disabled;
  267. background: transparent;
  268. }
  269. }
  270. &-checked {
  271. color: $color-checkbox_checked-icon-disabled;
  272. .#{$module}-inner-display {
  273. opacity: 0.75;
  274. background: $color-checkbox_checked-bg-disabled;
  275. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_checked-bg-disabled;
  276. &:hover {
  277. color: $color-checkbox_checked-icon-disabled;
  278. background: $color-checkbox_checked-bg-disabled;
  279. }
  280. }
  281. }
  282. }
  283. .#{$module}-addon {
  284. color: $color-checkbox_label-text-disabled;
  285. }
  286. .#{$module}-extra {
  287. color: $color-checkbox_label-text-disabled;
  288. }
  289. }
  290. &.#{$module}-disabled.#{$module}-indeterminate .#{$module}-inner-display {
  291. opacity: 0.75;
  292. background: $color-checkbox_checked-bg-disabled;
  293. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_checked-bg-disabled;
  294. color: $color-checkbox_checked-icon-disabled;
  295. }
  296. &-extra {
  297. flex-shrink: 0;
  298. flex-grow: 1;
  299. flex-basis: 100%;
  300. box-sizing: border-box;
  301. padding-left: $spacing-checkbox_extra-paddingLeft;
  302. color: $color-checkbox_extra-text-default;
  303. margin-top: $spacing-checkbox_extra-marginTop;
  304. }
  305. &-focus {
  306. outline: $width-checkbox-outline solid $color-checkbox_primary-outline-focus;
  307. &-border {
  308. box-shadow: inset 0 0 0 $size-checkbox_inner-shadow $color-checkbox_default-border-hover;
  309. }
  310. }
  311. }
  312. .#{$module}Group {
  313. @include font-size-regular;
  314. // make sure group height 32px
  315. line-height: $font-size-regular;
  316. .#{$module} {
  317. &.#{$module}-vertical {
  318. margin-bottom: $spacing-checkbox_group_vertical-marginBottom;
  319. }
  320. }
  321. &-horizontal {
  322. .#{$module} {
  323. margin-right: $spacing-checkbox_group_horizontal-marginRight;
  324. display: inline-flex;
  325. &:last-of-type {
  326. margin-right: 0;
  327. }
  328. }
  329. }
  330. &-vertical {
  331. .#{$module} {
  332. margin-bottom: $spacing-checkbox_group_vertical_item-marginBottom;
  333. &:last-of-type {
  334. margin-bottom: 0;
  335. }
  336. }
  337. &-cardType {
  338. .#{$module} {
  339. margin-bottom: $spacing-checkbox_card_group_vertical-marginBottom;
  340. }
  341. }
  342. }
  343. }
  344. @import "./rtl.scss";