switch.scss 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. .vxe-switch {
  2. display: inline-block;
  3. color: var(--vxe-ui-font-color);
  4. vertical-align: middle;
  5. padding: 0.4em;
  6. user-select: none;
  7. text-align: center;
  8. &.is--animat {
  9. .vxe-switch--button {
  10. transition: border-color .3s, background-color .3s;
  11. }
  12. .vxe-switch--icon {
  13. transition: all 0.3s;
  14. }
  15. }
  16. &.is--on {
  17. .vxe-switch--button {
  18. padding-right: 1.7em;
  19. background-color: var(--vxe-ui-switch-open-background-color);
  20. }
  21. .vxe-switch--icon {
  22. left: 100%;
  23. transform: translateX(-1.4em);
  24. color: var(--vxe-primary-color);
  25. }
  26. }
  27. &.is--off {
  28. .vxe-switch--button {
  29. padding-left: 1.7em;
  30. background-color: var(--vxe-ui-switch-close-background-color);
  31. }
  32. .vxe-switch--icon {
  33. left: 0.2em;
  34. transform: translateX(0);
  35. color: var(--vxe-switch-close-background-color);
  36. }
  37. }
  38. &.is--on .vxe-switch--label-off,
  39. &.is--off .vxe-switch--label-on {
  40. height: 0;
  41. visibility: hidden;
  42. overflow: hidden;
  43. }
  44. &.is--on,
  45. &.is--off {
  46. .vxe-switch--label {
  47. opacity: 1;
  48. }
  49. }
  50. &:not(.is--disabled) {
  51. .vxe-switch--button {
  52. cursor: pointer;
  53. &:focus {
  54. box-shadow: 0 0 0.4em 0 var(--vxe-ui-font-primary-color);
  55. }
  56. }
  57. }
  58. &.is--disabled {
  59. .vxe-switch--button {
  60. cursor: no-drop;
  61. }
  62. &.is--on {
  63. .vxe-switch--button {
  64. background-color: var(--vxe-ui-font-primary-lighten-color);
  65. }
  66. .vxe-switch--icon {
  67. color: var(--vxe-primary-lighten-color);
  68. }
  69. }
  70. &.is--off {
  71. .vxe-switch--button {
  72. background-color: var(--vxe-ui-switch-disabled-background-color);
  73. }
  74. .vxe-switch--icon {
  75. color: var(--vxe-switch-disabled-background-color);
  76. }
  77. }
  78. }
  79. &.is--readonly {
  80. .vxe-switch--button {
  81. cursor: default;
  82. }
  83. }
  84. .vxe-switch--button {
  85. display: block;
  86. position: relative;
  87. height: 1.6em;
  88. line-height: 1;
  89. min-width: 3.2em;
  90. padding: 0 0.6em;
  91. border-radius: 1em;
  92. border: 0;
  93. outline: 0;
  94. }
  95. .vxe-switch--label {
  96. opacity: 0;
  97. display: block;
  98. color: var(--vxe-ui-switch-font-color);
  99. font-size: 0.8em;
  100. }
  101. .vxe-switch--icon {
  102. position: absolute;
  103. top: 0.2em;
  104. left: 0;
  105. width: 1.2em;
  106. height: 1.2em;
  107. line-height: 1.4em;
  108. text-align: center;
  109. border-radius: 50%;
  110. background-color: var(--vxe-ui-switch-icon-background-color);
  111. }
  112. .vxe-switch--label-icon {
  113. margin-right: 0.25em;
  114. }
  115. }
  116. .vxe-switch {
  117. font-size: var(--vxe-ui-font-size-default);
  118. &.size--medium {
  119. font-size: var(--vxe-ui-font-size-medium);
  120. }
  121. &.size--small {
  122. font-size: var(--vxe-ui-font-size-small);
  123. }
  124. &.size--mini {
  125. font-size: var(--vxe-ui-font-size-mini);
  126. }
  127. }