Blame view

src/styles/components/switch.less 3.24 KB
07aa688e   梁灏   add Switch UI
1
2
3
4
  @switch-prefix-cls: ~"@{css-prefix}switch";
  
  .@{switch-prefix-cls} {
      display: inline-block;
ac2f8493   梁灏   update Switch style
5
6
7
8
      width: 44px;
      height: 22px;
      line-height: 20px;
      border-radius: 22px;
07aa688e   梁灏   add Switch UI
9
10
11
12
13
      vertical-align: middle;
      border: 1px solid #ccc;
      background-color: #ccc;
      position: relative;
      cursor: pointer;
e2645048   jingsam   :fire: remove tra...
14
15
      user-select: none;
      transition: all @transition-time @ease-in-out;
07aa688e   梁灏   add Switch UI
16
  
eb7f31db   梁灏   Switch add loadin...
17
18
19
20
      &-loading{
          opacity: .4;
      }
  
07aa688e   梁灏   add Switch UI
21
22
      &-inner {
          color: #fff;
3c01d81a   梁灏   fixed Modal bug,w...
23
          font-size: @font-size-small;
07aa688e   梁灏   add Switch UI
24
          position: absolute;
ac2f8493   梁灏   update Switch style
25
          left: 23px;
95436eeb   梁灏   add InputNumber UI
26
  
e2645048   jingsam   :fire: remove tra...
27
          i {
95436eeb   梁灏   add InputNumber UI
28
29
30
31
              width: 12px;
              height: 12px;
              text-align: center;
          }
07aa688e   梁灏   add Switch UI
32
33
34
35
      }
  
      &:after {
          content: '';
ac2f8493   梁灏   update Switch style
36
37
38
          width: 18px;
          height: 18px;
          border-radius: 18px;
07aa688e   梁灏   add Switch UI
39
40
          background-color: #fff;
          position: absolute;
2af5843d   梁灏   Switch add large ...
41
42
          left: 1px;
          top: 1px;
07aa688e   梁灏   add Switch UI
43
          cursor: pointer;
e2645048   jingsam   :fire: remove tra...
44
          transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out;
07aa688e   梁灏   add Switch UI
45
46
47
48
49
50
      }
  
      &:active:after {
          width: 26px;
      }
  
eb7f31db   梁灏   Switch add loadin...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
      &:before{
          content: '';
          display: none;
          width: 14px;
          height: 14px;
          border-radius: 50%;
          background-color: transparent;
          position: absolute;
          left: 3px;
          top: 3px;
          z-index: 1;
          border: 1px solid @primary-color;
          border-color: transparent transparent transparent @primary-color;
          animation: switch-loading 1s linear;
          animation-iteration-count: infinite;
      }
      &-loading:before{
          display: block;
      }
  
07aa688e   梁灏   add Switch UI
71
72
73
74
75
76
77
78
79
80
      &:focus {
          box-shadow: 0 0 0 2px fade(@primary-color, 20%);
          outline: 0;
      }
  
      &:focus:hover {
          box-shadow: none;
      }
  
      &-small {
ac2f8493   梁灏   update Switch style
81
82
83
          width: 28px;
          height: 16px;
          line-height: 14px;
07aa688e   梁灏   add Switch UI
84
          &:after {
ac2f8493   梁灏   update Switch style
85
86
              width: 12px;
              height: 12px;
07aa688e   梁灏   add Switch UI
87
88
          }
          &:active:after {
2af5843d   梁灏   Switch add large ...
89
              width: 14px;
07aa688e   梁灏   add Switch UI
90
          }
eb7f31db   梁灏   Switch add loadin...
91
92
93
94
95
96
          &:before{
              width: 10px;
              height: 10px;
              left: 2px;
              top: 2px;
          }
07aa688e   梁灏   add Switch UI
97
98
99
      }
  
      &-small&-checked:after {
ac2f8493   梁灏   update Switch style
100
          left: 13px;
07aa688e   梁灏   add Switch UI
101
      }
eb7f31db   梁灏   Switch add loadin...
102
103
104
      &-small&-checked:before {
          left: 14px;
      }
07aa688e   梁灏   add Switch UI
105
106
  
      &-small:active&-checked:after {
ac2f8493   梁灏   update Switch style
107
          left: 11px;
2af5843d   梁灏   Switch add large ...
108
109
110
      }
  
      &-large{
ac2f8493   梁灏   update Switch style
111
          width: 56px;
2af5843d   梁灏   Switch add large ...
112
113
114
115
116
117
          &:active:after {
              width: 26px;
          }
      }
  
      &-large:active:after {
ac2f8493   梁灏   update Switch style
118
          width: 30px;
2af5843d   梁灏   Switch add large ...
119
120
121
      }
  
      &-large&-checked:after {
ac2f8493   梁灏   update Switch style
122
          left: 35px;
2af5843d   梁灏   Switch add large ...
123
      }
eb7f31db   梁灏   Switch add loadin...
124
125
126
      &-large&-checked:before {
          left: 37px;
      }
2af5843d   梁灏   Switch add large ...
127
128
  
      &-large:active&-checked:after {
ac2f8493   梁灏   update Switch style
129
          left: 23px;
07aa688e   梁灏   add Switch UI
130
131
132
133
134
135
136
      }
  
      &-checked {
          border-color: @primary-color;
          background-color: @primary-color;
  
          .@{switch-prefix-cls}-inner {
ac2f8493   梁灏   update Switch style
137
              left: 7px;
07aa688e   梁灏   add Switch UI
138
139
140
          }
  
          &:after {
ac2f8493   梁灏   update Switch style
141
              left: 23px;
07aa688e   梁灏   add Switch UI
142
          }
eb7f31db   梁灏   Switch add loadin...
143
144
145
          &:before{
              left: 25px;
          }
07aa688e   梁灏   add Switch UI
146
147
  
          &:active:after {
ac2f8493   梁灏   update Switch style
148
              left: 15px;
07aa688e   梁灏   add Switch UI
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
          }
      }
  
      &-disabled {
          cursor: @cursor-disabled;
          background: #f3f3f3;
          border-color: #f3f3f3;
  
          &:after {
              background: #ccc;
              cursor: not-allowed;
          }
  
          .@{switch-prefix-cls}-inner {
              color: #ccc;
          }
      }
1a4a76e9   梁灏   update Page style
166
  
e2645048   jingsam   :fire: remove tra...
167
  }
eb7f31db   梁灏   Switch add loadin...
168
169
170
171
172
173
174
175
176
  
  @keyframes switch-loading {
      0% {
          transform: rotate(0);
      }
      100% {
          transform: rotate(360deg);
      }
  }