Blame view

styles/components/switch.less 1.94 KB
07aa688e   梁灏   add Switch UI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  @switch-prefix-cls: ~"@{css-prefix}switch";
  
  .@{switch-prefix-cls} {
      display: inline-block;
      width: 44px;
      height: 24px;
      line-height: 22px;
      border-radius: 22px;
      vertical-align: middle;
      border: 1px solid #ccc;
      background-color: #ccc;
      position: relative;
      cursor: pointer;
      user-select: none;
      .transition(all @transition-time @ease-in-out);
  
      &-inner {
          color: #fff;
          font-size: 12px;
          position: absolute;
          left: 24px;
      }
  
      &:after {
          content: '';
          width: 22px;
          height: 22px;
          border-radius: 50%;
          background-color: #fff;
          position: absolute;
          left: 0;
          top: 0;
          cursor: pointer;
          .transition2(left @transition-time @ease-in-out, width @transition-time @ease-in-out);
      }
  
      &:active:after {
          width: 26px;
      }
  
      &:focus {
          box-shadow: 0 0 0 2px fade(@primary-color, 20%);
          outline: 0;
      }
  
      &:focus:hover {
          box-shadow: none;
      }
  
      &-small {
          height: 14px;
          line-height: 12px;
          width: 28px;
          &:after {
              width: 12px;
              height: 12px;
              top: 0;
              left: 0;
          }
          &:active:after {
              width: 16px;
          }
      }
  
      &-small&-checked:after {
          left: 14px;
      }
  
      &-small:active&-checked:after {
          left: 10px;
      }
  
      &-checked {
          border-color: @primary-color;
          background-color: @primary-color;
  
          .@{switch-prefix-cls}-inner {
              left: 6px;
          }
  
          &:after {
              left: 20px;
          }
  
          &:active:after {
              left: 16px;
          }
      }
  
      &-disabled {
          cursor: @cursor-disabled;
          background: #f3f3f3;
          border-color: #f3f3f3;
  
          &:after {
              background: #ccc;
              cursor: not-allowed;
          }
  
          .@{switch-prefix-cls}-inner {
              color: #ccc;
          }
      }
  }