1 | @import "../node_modules/tinper-bee-core/scss/minxin-variables";
|
2 | @import "../node_modules/tinper-bee-core/scss/minxin-mixins";
|
3 |
|
4 | .u-switch {
|
5 | position: relative;
|
6 | display: inline-block;
|
7 | box-sizing: border-box;
|
8 | width: map-get($switch-width, default);
|
9 | height: map-get($switch-height, default);
|
10 | line-height: map-get($switch-lineHeight, default);
|
11 | vertical-align: middle;
|
12 | border-radius: $switch-border-radius;
|
13 | border: 1px solid $switch-border-color;
|
14 | background-color: $switch-back-color;
|
15 | cursor: pointer;
|
16 | outline: 0;
|
17 | -webkit-transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
18 | transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
19 | -webkit-user-select: none;
|
20 | -moz-user-select: none;
|
21 | -ms-user-select: none;
|
22 | user-select: none;
|
23 | .u-switch-inner {
|
24 | color: #fff;
|
25 | position: absolute;
|
26 | font-size: map_get($switch-inner-fontSize, default);
|
27 | left: map_get($switch-inner-left, default);
|
28 | }
|
29 | &:active:after {
|
30 | width: map_get($switch-active-width, default);
|
31 | }
|
32 | &:focus {
|
33 | box-shadow: 0 0 0 2px rgba(16, 142, 233, 0.2);
|
34 | outline: 0;
|
35 | }
|
36 | &:after {
|
37 | position: absolute;
|
38 | width: $switch-after-widthHeight;
|
39 | height: $switch-after-widthHeight;
|
40 | top: $switch-after-top;
|
41 | left: $switch-after-left;
|
42 | border-radius: $switch-border-radius-after;
|
43 | background-color: #fff;
|
44 | content: " ";
|
45 | cursor: pointer;
|
46 | -webkit-transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
|
47 | width 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
48 | transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
|
49 | width 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
50 | }
|
51 | &.is-checked {
|
52 | border-color: $switch-checked-borColor;
|
53 | background-color: $switch-checked-backColor;
|
54 | .u-switch-inner {
|
55 | left: map_get($switch-checked-innerLeft, default);
|
56 | }
|
57 | &:after {
|
58 | left: map_get($switch-checked-afterLeft, default);
|
59 | }
|
60 | &:active:after {
|
61 | left: map_get($switch-checked-activeLeft, default);
|
62 | }
|
63 | }
|
64 | &.u-switch-disabled {
|
65 | cursor: no-drop;
|
66 | background: #ccc;
|
67 | border-color: #ccc;
|
68 |
|
69 | &:after {
|
70 | background: #9e9e9e;
|
71 | animation-name: none;
|
72 | cursor: no-drop;
|
73 | }
|
74 |
|
75 | &:hover:after {
|
76 | transform: scale(1);
|
77 | animation-name: none;
|
78 | }
|
79 | }
|
80 | }
|
81 |
|
82 | .u-switch.u-switch-sm {
|
83 | width: map-get($switch-width, small);
|
84 | height: map-get($switch-height, small);
|
85 | line-height: map-get($switch-lineHeight, small);
|
86 | .u-switch-inner {
|
87 | color: #fff;
|
88 | position: absolute;
|
89 | font-size: map_get($switch-inner-fontSize, small);
|
90 | left: map_get($switch-inner-left, small);
|
91 | }
|
92 | &:active:after {
|
93 | width: map_get($switch-active-width, small);
|
94 | }
|
95 |
|
96 | &:after {
|
97 | width: $switch-after-widthHeight-sm;
|
98 | height: $switch-after-widthHeight-sm;
|
99 | top: $switch-after-top-sm;
|
100 | left: $switch-after-left-sm;
|
101 | }
|
102 | &.is-checked {
|
103 | .u-switch-inner {
|
104 | left: map_get($switch-checked-innerLeft, small);
|
105 | }
|
106 | &:after {
|
107 | left: map_get($switch-checked-afterLeft, small);
|
108 | }
|
109 | &:active:after {
|
110 | left: map_get($switch-checked-activeLeft, small);
|
111 | }
|
112 | }
|
113 | }
|
114 |
|
115 | .u-switch.u-switch-lg {
|
116 | width: map-get($switch-width, large);
|
117 | height: map-get($switch-height, large);
|
118 | line-height: map-get($switch-lineHeight, large);
|
119 | .u-switch-inner {
|
120 | color: #fff;
|
121 | position: absolute;
|
122 | font-size: map_get($switch-inner-fontSize, large);
|
123 | left: map_get($switch-inner-left, large);
|
124 | top: $switch-inner-largeTop;
|
125 | }
|
126 | &:active:after {
|
127 | width: map_get($switch-active-width, large);
|
128 | }
|
129 | &:after {
|
130 | width: $switch-after-widthHeight-lg;
|
131 | height: $switch-after-widthHeight-lg;
|
132 | top: $switch-after-top-lg;
|
133 | left: $switch-after-left-lg;
|
134 | }
|
135 | &.is-checked {
|
136 | .u-switch-inner {
|
137 | left: map_get($switch-checked-innerLeft, large);
|
138 | }
|
139 | &:after {
|
140 | left: map_get($switch-checked-afterLeft, large);
|
141 | }
|
142 | &:active:after {
|
143 | left: map_get($switch-checked-activeLeft, large);
|
144 | }
|
145 | }
|
146 | }
|
147 |
|
148 | .u-switch-primary.is-checked {
|
149 | @include switch-styles-variant($switch-primary-bg);
|
150 | }
|
151 |
|
152 | .u-switch-info.is-checked {
|
153 | @include switch-styles-variant($switch-info-bg);
|
154 | }
|
155 |
|
156 | .is-checked.u-switch-danger {
|
157 | @include switch-styles-variant($switch-danger-bg);
|
158 | }
|
159 |
|
160 | .u-switch-warning.is-checked {
|
161 | @include switch-styles-variant($switch-warning-bg);
|
162 | }
|
163 |
|
164 | .u-switch-dark.is-checked {
|
165 | @include switch-styles-variant($switch-dark-bg);
|
166 | }
|
167 |
|
168 | .u-switch-success.is-checked {
|
169 | @include switch-styles-variant($switch-success-bg);
|
170 | }
|