e9f965f04e7781fbca8ee98898c70335cac08175d274e5554646e816c207218cf90386f68c9b8cb88bbb27a3b109acdcb537b64c6ccffefb248baabfcf2f51 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. @import "mixins/mixins";
  2. @import "common/var";
  3. @include b(switch) {
  4. display: inline-flex;
  5. align-items: center;
  6. position: relative;
  7. font-size: $--switch-font-size;
  8. line-height: $--switch-height;
  9. height: $--switch-height;
  10. vertical-align: middle;
  11. @include when(disabled) {
  12. & .el-switch__core,
  13. & .el-switch__label {
  14. cursor: not-allowed;
  15. }
  16. }
  17. @include e(label) {
  18. transition: .2s;
  19. height: $--switch-height;
  20. display: inline-block;
  21. font-size: $--switch-font-size;
  22. font-weight: 500;
  23. cursor: pointer;
  24. vertical-align: middle;
  25. color: $--color-text-primary;
  26. @include when(active) {
  27. color: $--color-primary;
  28. }
  29. @include m(left) {
  30. margin-right: 10px;
  31. }
  32. @include m(right) {
  33. margin-left: 10px;
  34. }
  35. & * {
  36. line-height: 1;
  37. font-size: $--switch-font-size;
  38. display: inline-block;
  39. }
  40. }
  41. @include e(input) {
  42. position: absolute;
  43. width: 0;
  44. height: 0;
  45. opacity: 0;
  46. margin: 0;
  47. }
  48. @include e(core) {
  49. margin: 0;
  50. display: inline-block;
  51. position: relative;
  52. width: $--switch-width;
  53. height: $--switch-height;
  54. border: 1px solid $--switch-off-color;
  55. outline: none;
  56. border-radius: $--switch-core-border-radius;
  57. box-sizing: border-box;
  58. background: $--switch-off-color;
  59. cursor: pointer;
  60. transition: border-color .3s, background-color .3s;
  61. vertical-align: middle;
  62. &:after {
  63. content: "";
  64. position: absolute;
  65. top: 1px;
  66. left: 1px;
  67. border-radius: $--border-radius-circle;
  68. transition: all .3s;
  69. width: $--switch-button-size;
  70. height: $--switch-button-size;
  71. background-color: $--color-white;
  72. }
  73. }
  74. @include when(checked) {
  75. .el-switch__core {
  76. border-color: $--switch-on-color;
  77. background-color: $--switch-on-color;
  78. &::after {
  79. left: 100%;
  80. margin-left: -$--switch-button-size - 1px;
  81. }
  82. }
  83. }
  84. @include when(disabled) {
  85. opacity: 0.6;
  86. }
  87. @include m(wide) {
  88. .el-switch__label {
  89. &.el-switch__label--left {
  90. span {
  91. left: 10px;
  92. }
  93. }
  94. &.el-switch__label--right {
  95. span {
  96. right: 10px;
  97. }
  98. }
  99. }
  100. }
  101. & .label-fade-enter,
  102. & .label-fade-leave-active {
  103. opacity: 0;
  104. }
  105. }