index.less 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. @import (reference) './variable.less';
  2. @switchPrefix: ant-switch;
  3. @keyframes loading-rotate {
  4. 100% {
  5. transform: rotate(1turn);
  6. }
  7. }
  8. .@{switchPrefix} {
  9. display: inline-block;
  10. vertical-align: middle;
  11. box-sizing: border-box;
  12. position: relative;
  13. align-self: center;
  14. min-width: @switch-width;
  15. height: @switch-height;
  16. border: @switch-border solid @COLOR_BORDER;
  17. border-radius: @switch-height * 0.5;
  18. background: @COLOR_WHITE;
  19. overflow: hidden;
  20. line-height: @switch-height;
  21. &-checked {
  22. background: @switch-fill;
  23. border-color: @switch-fill;
  24. .@{switchPrefix}-handle {
  25. left: calc(100% - (@switch-height - 2 * @switch-border));
  26. }
  27. .@{switchPrefix}-inner {
  28. color: @COLOR_WHITE;
  29. justify-content: flex-start;
  30. }
  31. }
  32. &-disabled {
  33. opacity: 0.4;
  34. pointer-events: none;
  35. }
  36. &-loading {
  37. pointer-events: none;
  38. }
  39. &-loading-icon {
  40. font-size: 20 * @rpx;
  41. animation: loading-rotate 1s linear infinite;
  42. color: @COLOR_BRAND1;
  43. }
  44. &-handle {
  45. display: flex;
  46. justify-content: center;
  47. align-items: center;
  48. width: @switch-height - 2 * @switch-border;
  49. height: @switch-height - 2 * @switch-border;
  50. border-radius: 50%;
  51. background: @COLOR_WHITE;
  52. position: absolute;
  53. top: 0;
  54. left: 0;
  55. transition: all 200ms;
  56. box-shadow: 0 0 2px 0 fade(@COLOR_WHITE_CHANGE_DARK, 20%),
  57. 0 2px 11.5px 0 fade(@COLOR_WHITE_CHANGE_DARK, 8%),
  58. -1px 2px 2px 0 fade(@COLOR_WHITE_CHANGE_DARK, 10%);
  59. }
  60. &-inner {
  61. position: relative;
  62. display: flex;
  63. justify-content: flex-end;
  64. align-items: center;
  65. height: 100%;
  66. color: @COLOR_TEXT_ASSIST;
  67. transition: margin 200ms;
  68. font-size: 30 * @rpx;
  69. padding: 0 14 * @rpx;
  70. min-width: 108 * @rpx;
  71. box-sizing: border-box;
  72. &:empty {
  73. display: none;
  74. }
  75. }
  76. &-small {
  77. min-width: @switch-width-small;
  78. height: @switch-height-small;
  79. border-radius: @switch-height-small * 0.5;
  80. .@{switchPrefix}-handle {
  81. width: @switch-height-small - 2 * @switch-border;
  82. height: @switch-height-small - 2 * @switch-border;
  83. }
  84. .@{switchPrefix}-inner {
  85. font-size: 16 * @rpx;
  86. padding: 0 10 * @rpx;
  87. min-width: 72 * @rpx;
  88. }
  89. }
  90. &-small&-checked {
  91. .@{switchPrefix}-handle {
  92. left: calc(100% - (@switch-height-small - 2 * @switch-border));
  93. }
  94. }
  95. &-x-small {
  96. min-width: @switch-width-x-small;
  97. height: @switch-height-x-small;
  98. border-radius: @switch-height-x-small * 0.5;
  99. .@{switchPrefix}-handle {
  100. width: @switch-height-x-small - 2 * @switch-border;
  101. height: @switch-height-x-small - 2 * @switch-border;
  102. }
  103. .@{switchPrefix}-inner {
  104. font-size: 10 * @rpx;
  105. padding: 0 6 * @rpx;
  106. min-width: 56 * @rpx;
  107. }
  108. }
  109. &-x-small&-checked {
  110. .@{switchPrefix}-handle {
  111. left: calc(100% - (@switch-height-x-small - 2 * @switch-border));
  112. }
  113. }
  114. }