|
| 1 | +$switchPrefixCls: rc-switch; |
| 2 | + |
| 3 | +$duration: 0.3s; |
| 4 | + |
| 5 | +.rc-switch { |
| 6 | + position: relative; |
| 7 | + display: inline-block; |
| 8 | + box-sizing: border-box; |
| 9 | + width: 44px; |
| 10 | + height: 22px; |
| 11 | + line-height: 20px; |
| 12 | + padding: 0; |
| 13 | + vertical-align: middle; |
| 14 | + border-radius: 20px 20px; |
| 15 | + border: 1px solid #ccc; |
| 16 | + background-color: #ccc; |
| 17 | + cursor: pointer; |
| 18 | + transition: all $duration cubic-bezier(0.35, 0, 0.25, 1); |
| 19 | + |
| 20 | + &-inner { |
| 21 | + color: #fff; |
| 22 | + font-size: 12px; |
| 23 | + position: absolute; |
| 24 | + left: 24px; |
| 25 | + top: 0; |
| 26 | + } |
| 27 | + |
| 28 | + &:after { |
| 29 | + position: absolute; |
| 30 | + width: 18px; |
| 31 | + height: 18px; |
| 32 | + left: 2px; |
| 33 | + top: 1px; |
| 34 | + border-radius: 50% 50%; |
| 35 | + background-color: #fff; |
| 36 | + content: ' '; |
| 37 | + cursor: pointer; |
| 38 | + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26); |
| 39 | + transform: scale(1); |
| 40 | + transition: left $duration cubic-bezier(0.35, 0, 0.25, 1); |
| 41 | + animation-timing-function: cubic-bezier(0.35, 0, 0.25, 1); |
| 42 | + animation-duration: $duration; |
| 43 | + animation-name: rcSwitchOff; |
| 44 | + } |
| 45 | + |
| 46 | + &:hover:after { |
| 47 | + transform: scale(1.1); |
| 48 | + animation-name: rcSwitchOn; |
| 49 | + } |
| 50 | + |
| 51 | + &:focus { |
| 52 | + box-shadow: 0 0 0 2px tint(#2db7f5, 80%); |
| 53 | + outline: none; |
| 54 | + } |
| 55 | + |
| 56 | + &-checked { |
| 57 | + border: 1px solid #87d068; |
| 58 | + background-color: #87d068; |
| 59 | + |
| 60 | + .rc-switch-inner { |
| 61 | + left: 6px; |
| 62 | + } |
| 63 | + |
| 64 | + &:after { |
| 65 | + left: 22px; |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + &-disabled { |
| 70 | + cursor: no-drop; |
| 71 | + background: #ccc; |
| 72 | + border-color: #ccc; |
| 73 | + |
| 74 | + &:after { |
| 75 | + background: #9e9e9e; |
| 76 | + animation-name: none; |
| 77 | + cursor: no-drop; |
| 78 | + } |
| 79 | + |
| 80 | + &:hover:after { |
| 81 | + transform: scale(1); |
| 82 | + animation-name: none; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + &-label { |
| 87 | + display: inline-block; |
| 88 | + line-height: 20px; |
| 89 | + font-size: 14px; |
| 90 | + padding-left: 10px; |
| 91 | + vertical-align: middle; |
| 92 | + white-space: normal; |
| 93 | + pointer-events: none; |
| 94 | + user-select: text; |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | +@keyframes rcSwitchOn { |
| 99 | + 0% { |
| 100 | + transform: scale(1); |
| 101 | + } |
| 102 | + 50% { |
| 103 | + transform: scale(1.25); |
| 104 | + } |
| 105 | + 100% { |
| 106 | + transform: scale(1.1); |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +@keyframes rcSwitchOff { |
| 111 | + 0% { |
| 112 | + transform: scale(1.1); |
| 113 | + } |
| 114 | + 100% { |
| 115 | + transform: scale(1); |
| 116 | + } |
| 117 | +} |
0 commit comments