switch.scss 2.2 KB

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