checkbox.scss 12 KB

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