codecheck
99 строк · 2.2 Кб
1@use 'sass:math';
2
3// core
4.p-inputswitch {
5display: inline-block;
6}
7
8.p-inputswitch-input {
9cursor: pointer;
10}
11
12.p-inputswitch-slider {
13position: absolute;
14cursor: pointer;
15top: 0;
16left: 0;
17right: 0;
18bottom: 0;
19border: 1px solid transparent;
20}
21
22.p-inputswitch-slider:before {
23position: absolute;
24content: '';
25top: 50%;
26}
27
28// theme
29.p-inputswitch {
30width: $inputSwitchWidth;
31height: $inputSwitchHeight;
32
33.p-inputswitch-input {
34appearance: none;
35position: absolute;
36top: 0;
37left: 0;
38width: 100%;
39height: 100%;
40padding: 0;
41margin: 0;
42opacity: 0;
43z-index: 1;
44outline: 0 none;
45border-radius: $inputSwitchBorderRadius;
46}
47
48.p-inputswitch-slider {
49background: $inputSwitchSliderOffBg;
50transition: $formElementTransition;
51border-radius: $inputSwitchBorderRadius;
52outline-color: transparent;
53
54&:before {
55background: $inputSwitchHandleOffBg;
56width: $inputSwitchHandleWidth;
57height: $inputSwitchHandleHeight;
58left: $inputSwitchSliderPadding;
59margin-top: math.div(-1 * $inputSwitchHandleHeight, 2);
60border-radius: $inputSwitchHandleBorderRadius;
61transition-duration: $transitionDuration;
62}
63}
64
65&.p-highlight {
66.p-inputswitch-slider {
67background: $inputSwitchSliderOnBg;
68
69&:before {
70background: $inputSwitchHandleOnBg;
71transform: translateX($inputSwitchHandleWidth);
72}
73}
74}
75
76&:not(.p-disabled) {
77&:has(.p-inputswitch-input:hover) {
78.p-inputswitch-slider {
79background: $inputSwitchSliderOffHoverBg;
80}
81
82&.p-highlight {
83.p-inputswitch-slider {
84background: $inputSwitchSliderOnHoverBg;
85}
86}
87}
88
89&:has(.p-inputswitch-input:focus-visible) {
90.p-inputswitch-slider {
91@include focused();
92}
93}
94}
95
96&.p-invalid > .p-inputswitch-slider {
97@include invalid-input();
98}
99}