index.scss 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. @import '../common/abstracts/variable';
  2. @import '../common/abstracts/mixin';
  3. @include b(switch) {
  4. display: inline-block;
  5. position: relative;
  6. width: $-switch-width;
  7. height: $-switch-height;
  8. border-radius: $-switch-circle-size;
  9. background: $-switch-inactive-color;
  10. font-size: $-switch-size;
  11. transition: all .3s;
  12. @include e(checkbox) {
  13. position: absolute;
  14. width: 0;
  15. height: 0;
  16. opacity: 0;
  17. margin: 0;
  18. }
  19. @include e(circle) {
  20. box-sizing: border-box;
  21. position: absolute;
  22. display: inline-block;
  23. width: $-switch-circle-size;
  24. height: $-switch-circle-size;
  25. top: 2px;
  26. left: 2px;
  27. background: #fff;
  28. border-radius: 50%;
  29. transition: left .3s ease-out;
  30. box-shadow: 0 2px 4px 0 $-switch-inactive-shadow-color;
  31. &::after {
  32. position: absolute;
  33. content: '';
  34. width: calc(200% - 2px);
  35. height: calc(200% - 2px);
  36. top: 50%;
  37. left: 50%;
  38. transform: translate(-50%, -50%) scale(0.5);
  39. border: 1px solid $-switch-border-color;
  40. border-radius: 50%;
  41. }
  42. }
  43. @include when(checked) {
  44. background: $-switch-active-color;
  45. border-color: $-switch-active-color;
  46. .wd-switch__circle {
  47. left: calc($-switch-width - $-switch-circle-size - 2px);
  48. box-shadow: 0 2px 4px 0 $-switch-active-shadow-color
  49. }
  50. }
  51. @include when(disabled) {
  52. opacity: 0.5;
  53. }
  54. }