checkbox.scss 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. @import "common/var";
  2. @import "mixins/mixins";
  3. @import "mixins/_button";
  4. @import "mixins/utils";
  5. @include b(checkbox) {
  6. color: $--checkbox-font-color;
  7. font-weight: $--checkbox-font-weight;
  8. font-size: $--font-size-base;
  9. position: relative;
  10. cursor: pointer;
  11. display: inline-block;
  12. white-space: nowrap;
  13. user-select: none;
  14. margin-right: 30px;
  15. @include when(bordered) {
  16. padding: $--checkbox-bordered-padding;
  17. border-radius: $--border-radius-base;
  18. border: $--border-base;
  19. box-sizing: border-box;
  20. line-height: normal;
  21. height: $--checkbox-bordered-height;
  22. &.is-checked {
  23. border-color: $--color-primary;
  24. }
  25. &.is-disabled {
  26. border-color: $--border-color-lighter;
  27. cursor: not-allowed;
  28. }
  29. & + .el-checkbox.is-bordered {
  30. margin-left: 10px;
  31. }
  32. &.el-checkbox--medium {
  33. padding: $--checkbox-bordered-medium-padding;
  34. border-radius: $--button-medium-border-radius;
  35. height: $--checkbox-bordered-medium-height;
  36. .el-checkbox__label {
  37. line-height: 17px;
  38. font-size: $--button-medium-font-size;
  39. }
  40. .el-checkbox__inner {
  41. height: $--checkbox-bordered-medium-input-height;
  42. width: $--checkbox-bordered-medium-input-width;
  43. }
  44. }
  45. &.el-checkbox--small {
  46. padding: $--checkbox-bordered-small-padding;
  47. border-radius: $--button-small-border-radius;
  48. height: $--checkbox-bordered-small-height;
  49. .el-checkbox__label {
  50. line-height: 15px;
  51. font-size: $--button-small-font-size;
  52. }
  53. .el-checkbox__inner {
  54. height: $--checkbox-bordered-small-input-height;
  55. width: $--checkbox-bordered-small-input-width;
  56. &::after {
  57. height: 6px;
  58. width: 2px;
  59. }
  60. }
  61. }
  62. &.el-checkbox--mini {
  63. padding: $--checkbox-bordered-mini-padding;
  64. border-radius: $--button-mini-border-radius;
  65. height: $--checkbox-bordered-mini-height;
  66. .el-checkbox__label {
  67. line-height: 12px;
  68. font-size: $--button-mini-font-size;
  69. }
  70. .el-checkbox__inner {
  71. height: $--checkbox-bordered-mini-input-height;
  72. width: $--checkbox-bordered-mini-input-width;
  73. &::after {
  74. height: 6px;
  75. width: 2px;
  76. }
  77. }
  78. }
  79. }
  80. @include e(input) {
  81. white-space: nowrap;
  82. cursor: pointer;
  83. outline: none;
  84. display: inline-block;
  85. line-height: 1;
  86. position: relative;
  87. vertical-align: middle;
  88. @include when(disabled) {
  89. .el-checkbox__inner {
  90. background-color: $--checkbox-disabled-input-fill;
  91. border-color: $--checkbox-disabled-border-color;
  92. cursor: not-allowed;
  93. &::after {
  94. cursor: not-allowed;
  95. border-color: $--checkbox-disabled-icon-color;
  96. }
  97. & + .el-checkbox__label {
  98. cursor: not-allowed;
  99. }
  100. }
  101. &.is-checked {
  102. .el-checkbox__inner {
  103. background-color: $--checkbox-disabled-checked-input-fill;
  104. border-color: $--checkbox-disabled-checked-input-border-color;
  105. &::after {
  106. border-color: $--checkbox-disabled-checked-icon-color;
  107. }
  108. }
  109. }
  110. &.is-indeterminate {
  111. .el-checkbox__inner {
  112. background-color: $--checkbox-disabled-checked-input-fill;
  113. border-color: $--checkbox-disabled-checked-input-border-color;
  114. &::before {
  115. background-color: $--checkbox-disabled-checked-icon-color;
  116. border-color: $--checkbox-disabled-checked-icon-color;
  117. }
  118. }
  119. }
  120. & + span.el-checkbox__label {
  121. color: $--disabled-color-base;
  122. cursor: not-allowed;
  123. }
  124. }
  125. @include when(checked) {
  126. .el-checkbox__inner {
  127. background-color: $--checkbox-checked-background-color;
  128. border-color: $--checkbox-checked-input-border-color;
  129. &::after {
  130. transform: rotate(45deg) scaleY(1);
  131. }
  132. }
  133. & + .el-checkbox__label {
  134. color: $--checkbox-checked-font-color;
  135. }
  136. }
  137. @include when(focus) { /*focus时 视觉上区分*/
  138. .el-checkbox__inner {
  139. border-color: $--checkbox-input-border-color-hover;
  140. }
  141. }
  142. @include when(indeterminate) {
  143. .el-checkbox__inner {
  144. background-color: $--checkbox-checked-background-color;
  145. border-color: $--checkbox-checked-input-border-color;
  146. &::before {
  147. content: '';
  148. position: absolute;
  149. display: block;
  150. background-color: $--checkbox-checked-icon-color;
  151. height: 2px;
  152. transform: scale(0.5);
  153. left: 0;
  154. right: 0;
  155. top: 5px;
  156. }
  157. &::after {
  158. display: none;
  159. }
  160. }
  161. }
  162. }
  163. @include e(inner) {
  164. display: inline-block;
  165. position: relative;
  166. border: $--checkbox-input-border;
  167. border-radius: $--checkbox-border-radius;
  168. box-sizing: border-box;
  169. width: $--checkbox-input-width;
  170. height: $--checkbox-input-height;
  171. background-color: $--checkbox-background-color;
  172. z-index: $--index-normal;
  173. transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),
  174. background-color .25s cubic-bezier(.71,-.46,.29,1.46);
  175. &:hover {
  176. border-color: $--checkbox-input-border-color-hover;
  177. }
  178. &::after {
  179. box-sizing: content-box;
  180. content: "";
  181. border: 1px solid $--checkbox-checked-icon-color;
  182. border-left: 0;
  183. border-top: 0;
  184. height: 7px;
  185. left: 4px;
  186. position: absolute;
  187. top: 1px;
  188. transform: rotate(45deg) scaleY(0);
  189. width: 3px;
  190. transition: transform .15s ease-in .05s;
  191. transform-origin: center;
  192. }
  193. }
  194. @include e(original) {
  195. opacity: 0;
  196. outline: none;
  197. position: absolute;
  198. margin: 0;
  199. width: 0;
  200. height: 0;
  201. z-index: -1;
  202. }
  203. @include e(label) {
  204. display: inline-block;
  205. padding-left: 10px;
  206. line-height: 19px;
  207. font-size: $--checkbox-font-size;
  208. }
  209. &:last-of-type {
  210. margin-right: 0;
  211. }
  212. }
  213. @include b(checkbox-button) {
  214. position: relative;
  215. display: inline-block;
  216. @include e(inner) {
  217. display: inline-block;
  218. line-height: 1;
  219. font-weight: $--checkbox-font-weight;
  220. white-space: nowrap;
  221. vertical-align: middle;
  222. cursor: pointer;
  223. background: $--button-default-background-color;
  224. border: $--border-base;
  225. border-left: 0;
  226. color: $--button-default-font-color;
  227. -webkit-appearance: none;
  228. text-align: center;
  229. box-sizing: border-box;
  230. outline: none;
  231. margin: 0;
  232. position: relative;
  233. transition: $--all-transition;
  234. @include utils-user-select(none);
  235. @include button-size($--button-padding-vertical, $--button-padding-horizontal, $--button-font-size, 0);
  236. &:hover {
  237. color: $--color-primary;
  238. }
  239. & [class*="el-icon-"] {
  240. line-height: 0.9;
  241. & + span {
  242. margin-left: 5px;
  243. }
  244. }
  245. }
  246. @include e(original) {
  247. opacity: 0;
  248. outline: none;
  249. position: absolute;
  250. margin: 0;
  251. z-index: -1;
  252. }
  253. &.is-checked {
  254. & .el-checkbox-button__inner {
  255. color: $--checkbox-button-checked-font-color;
  256. background-color: $--checkbox-button-checked-background-color;
  257. border-color: $--checkbox-button-checked-border-color;
  258. box-shadow: -1px 0 0 0 $--color-primary-light-4;
  259. }
  260. &:first-child .el-checkbox-button__inner {
  261. border-left-color: $--checkbox-button-checked-border-color;
  262. }
  263. }
  264. &.is-disabled {
  265. & .el-checkbox-button__inner {
  266. color: $--button-disabled-font-color;
  267. cursor: not-allowed;
  268. background-image: none;
  269. background-color: $--button-disabled-background-color;
  270. border-color: $--button-disabled-border-color;
  271. box-shadow: none;
  272. }
  273. &:first-child .el-checkbox-button__inner {
  274. border-left-color: $--button-disabled-border-color;
  275. }
  276. }
  277. &:first-child {
  278. .el-checkbox-button__inner {
  279. border-left: $--border-base;
  280. border-radius: $--border-radius-base 0 0 $--border-radius-base;
  281. box-shadow: none !important;
  282. }
  283. }
  284. &.is-focus {
  285. & .el-checkbox-button__inner {
  286. border-color: $--checkbox-button-checked-border-color;
  287. }
  288. }
  289. &:last-child {
  290. .el-checkbox-button__inner {
  291. border-radius: 0 $--border-radius-base $--border-radius-base 0;
  292. }
  293. }
  294. @include m(medium) {
  295. .el-checkbox-button__inner {
  296. @include button-size($--button-medium-padding-vertical, $--button-medium-padding-horizontal, $--button-medium-font-size, 0);
  297. }
  298. }
  299. @include m(small) {
  300. .el-checkbox-button__inner {
  301. @include button-size($--button-small-padding-vertical, $--button-small-padding-horizontal, $--button-small-font-size, 0);
  302. }
  303. }
  304. @include m(mini) {
  305. .el-checkbox-button__inner {
  306. @include button-size($--button-mini-padding-vertical, $--button-mini-padding-horizontal, $--button-mini-font-size, 0);
  307. }
  308. }
  309. }
  310. @include b(checkbox-group) {
  311. font-size: 0;
  312. }