1 | import {
|
2 | component_styles_default
|
3 | } from "./chunk.7IGWJVQF.js";
|
4 | import {
|
5 | r
|
6 | } from "./chunk.WWAD5WF4.js";
|
7 |
|
8 |
|
9 | var switch_styles_default = r`
|
10 | ${component_styles_default}
|
11 |
|
12 | :host {
|
13 | --height: var(--sl-toggle-size);
|
14 | --thumb-size: calc(var(--sl-toggle-size) + 4px);
|
15 | --width: calc(var(--height) * 2);
|
16 |
|
17 | display: inline-block;
|
18 | }
|
19 |
|
20 | .switch {
|
21 | display: inline-flex;
|
22 | align-items: center;
|
23 | font-family: var(--sl-input-font-family);
|
24 | font-size: var(--sl-input-font-size-medium);
|
25 | font-weight: var(--sl-input-font-weight);
|
26 | color: var(--sl-input-color);
|
27 | vertical-align: middle;
|
28 | cursor: pointer;
|
29 | }
|
30 |
|
31 | .switch__control {
|
32 | flex: 0 0 auto;
|
33 | position: relative;
|
34 | display: inline-flex;
|
35 | align-items: center;
|
36 | justify-content: center;
|
37 | width: var(--width);
|
38 | height: var(--height);
|
39 | background-color: var(--sl-color-neutral-400);
|
40 | border: solid var(--sl-input-border-width) var(--sl-color-neutral-400);
|
41 | border-radius: var(--height);
|
42 | transition: var(--sl-transition-fast) border-color, var(--sl-transition-fast) background-color;
|
43 | }
|
44 |
|
45 | .switch__control .switch__thumb {
|
46 | width: var(--thumb-size);
|
47 | height: var(--thumb-size);
|
48 | background-color: var(--sl-color-neutral-0);
|
49 | border-radius: 50%;
|
50 | border: solid var(--sl-input-border-width) var(--sl-color-neutral-400);
|
51 | transform: translateX(calc((var(--width) - var(--height)) / -2));
|
52 | transition: var(--sl-transition-fast) transform ease, var(--sl-transition-fast) background-color,
|
53 | var(--sl-transition-fast) border-color, var(--sl-transition-fast) box-shadow;
|
54 | }
|
55 |
|
56 | .switch__input {
|
57 | position: absolute;
|
58 | opacity: 0;
|
59 | padding: 0;
|
60 | margin: 0;
|
61 | pointer-events: none;
|
62 | }
|
63 |
|
64 | /* Hover */
|
65 | .switch:not(.switch--checked):not(.switch--disabled) .switch__control:hover {
|
66 | background-color: var(--sl-color-neutral-400);
|
67 | border-color: var(--sl-color-neutral-400);
|
68 | }
|
69 |
|
70 | .switch:not(.switch--checked):not(.switch--disabled) .switch__control:hover .switch__thumb {
|
71 | background-color: var(--sl-color-neutral-0);
|
72 | border-color: var(--sl-color-neutral-400);
|
73 | }
|
74 |
|
75 | /* Focus */
|
76 | .switch:not(.switch--checked):not(.switch--disabled) .switch__input:focus-visible ~ .switch__control {
|
77 | background-color: var(--sl-color-neutral-400);
|
78 | border-color: var(--sl-color-neutral-400);
|
79 | }
|
80 |
|
81 | .switch:not(.switch--checked):not(.switch--disabled) .switch__input:focus-visible ~ .switch__control .switch__thumb {
|
82 | background-color: var(--sl-color-neutral-0);
|
83 | border-color: var(--sl-color-primary-600);
|
84 | outline: var(--sl-focus-ring);
|
85 | outline-offset: var(--sl-focus-ring-offset);
|
86 | }
|
87 |
|
88 | /* Checked */
|
89 | .switch--checked .switch__control {
|
90 | background-color: var(--sl-color-primary-600);
|
91 | border-color: var(--sl-color-primary-600);
|
92 | }
|
93 |
|
94 | .switch--checked .switch__control .switch__thumb {
|
95 | background-color: var(--sl-color-neutral-0);
|
96 | border-color: var(--sl-color-primary-600);
|
97 | transform: translateX(calc((var(--width) - var(--height)) / 2));
|
98 | }
|
99 |
|
100 | /* Checked + hover */
|
101 | .switch.switch--checked:not(.switch--disabled) .switch__control:hover {
|
102 | background-color: var(--sl-color-primary-600);
|
103 | border-color: var(--sl-color-primary-600);
|
104 | }
|
105 |
|
106 | .switch.switch--checked:not(.switch--disabled) .switch__control:hover .switch__thumb {
|
107 | background-color: var(--sl-color-neutral-0);
|
108 | border-color: var(--sl-color-primary-600);
|
109 | }
|
110 |
|
111 | /* Checked + focus */
|
112 | .switch.switch--checked:not(.switch--disabled) .switch__input:focus-visible ~ .switch__control {
|
113 | background-color: var(--sl-color-primary-600);
|
114 | border-color: var(--sl-color-primary-600);
|
115 | }
|
116 |
|
117 | .switch.switch--checked:not(.switch--disabled) .switch__input:focus-visible ~ .switch__control .switch__thumb {
|
118 | background-color: var(--sl-color-neutral-0);
|
119 | border-color: var(--sl-color-primary-600);
|
120 | outline: var(--sl-focus-ring);
|
121 | outline-offset: var(--sl-focus-ring-offset);
|
122 | }
|
123 |
|
124 | /* Disabled */
|
125 | .switch--disabled {
|
126 | opacity: 0.5;
|
127 | cursor: not-allowed;
|
128 | }
|
129 |
|
130 | .switch__label {
|
131 | line-height: var(--height);
|
132 | margin-inline-start: 0.5em;
|
133 | user-select: none;
|
134 | }
|
135 |
|
136 | :host([required]) .switch__label::after {
|
137 | content: var(--sl-input-required-content);
|
138 | margin-inline-start: var(--sl-input-required-content-offset);
|
139 | }
|
140 | `;
|
141 |
|
142 | export {
|
143 | switch_styles_default
|
144 | };
|