@m3e/switch 1.0.0-rc.1 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/custom-elements.json +3213 -152
- package/dist/html-custom-data.json +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +4 -4
- package/cem.config.mjs +0 -16
- package/demo/index.html +0 -65
- package/dist/src/SwitchElement.d.ts +0 -147
- package/dist/src/SwitchElement.d.ts.map +0 -1
- package/dist/src/SwitchIcons.d.ts +0 -3
- package/dist/src/SwitchIcons.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/styles/SwitchHandleStyle.d.ts +0 -6
- package/dist/src/styles/SwitchHandleStyle.d.ts.map +0 -1
- package/dist/src/styles/SwitchIconStyle.d.ts +0 -6
- package/dist/src/styles/SwitchIconStyle.d.ts.map +0 -1
- package/dist/src/styles/SwitchStateLayerStyle.d.ts +0 -6
- package/dist/src/styles/SwitchStateLayerStyle.d.ts.map +0 -1
- package/dist/src/styles/SwitchStyle.d.ts +0 -6
- package/dist/src/styles/SwitchStyle.d.ts.map +0 -1
- package/dist/src/styles/SwitchToken.d.ts +0 -76
- package/dist/src/styles/SwitchToken.d.ts.map +0 -1
- package/dist/src/styles/SwitchTrackStyle.d.ts +0 -6
- package/dist/src/styles/SwitchTrackStyle.d.ts.map +0 -1
- package/dist/src/styles/index.d.ts +0 -6
- package/dist/src/styles/index.d.ts.map +0 -1
- package/eslint.config.mjs +0 -13
- package/rollup.config.js +0 -32
- package/src/SwitchElement.ts +0 -268
- package/src/SwitchIcons.ts +0 -2
- package/src/index.ts +0 -2
- package/src/styles/SwitchHandleStyle.ts +0 -140
- package/src/styles/SwitchIconStyle.ts +0 -89
- package/src/styles/SwitchStateLayerStyle.ts +0 -43
- package/src/styles/SwitchStyle.ts +0 -30
- package/src/styles/SwitchToken.ts +0 -145
- package/src/styles/SwitchTrackStyle.ts +0 -104
- package/src/styles/index.ts +0 -5
- package/tsconfig.json +0 -9
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { css, unsafeCSS } from "lit";
|
|
2
|
-
import { DesignToken } from "@m3e/core";
|
|
3
|
-
|
|
4
|
-
import { SwitchToken } from "./SwitchToken";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Handle styles for `M3eSwitchElement`.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const SwitchHandleStyle = css`
|
|
11
|
-
.handle {
|
|
12
|
-
position: relative;
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
pointer-events: none;
|
|
17
|
-
transform-origin: center center;
|
|
18
|
-
border-radius: ${SwitchToken.handleShape};
|
|
19
|
-
transition: ${unsafeCSS(
|
|
20
|
-
`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard},
|
|
21
|
-
transform var(--_switch-handle-effect),
|
|
22
|
-
width ${DesignToken.motion.spring.fastEffects},
|
|
23
|
-
height ${DesignToken.motion.spring.fastEffects}`
|
|
24
|
-
)};
|
|
25
|
-
}
|
|
26
|
-
.track:not(.pressed) .handle {
|
|
27
|
-
--_switch-handle-effect: ${DesignToken.motion.spring.fastSpatial};
|
|
28
|
-
}
|
|
29
|
-
.track.pressed .handle {
|
|
30
|
-
--_switch-handle-effect: ${DesignToken.motion.spring.fastEffects};
|
|
31
|
-
}
|
|
32
|
-
:host(:not([aria-disabled="true"]):not([checked])[icons="both"]) .track:not(.pressed) .handle {
|
|
33
|
-
width: ${SwitchToken.withIconHandleWidth};
|
|
34
|
-
height: ${SwitchToken.withIconHandleHeight};
|
|
35
|
-
}
|
|
36
|
-
:host(:not([checked]):not([icons="both"])) .track:not(.pressed) .handle,
|
|
37
|
-
:host([aria-disabled="true"]:not([checked])) .handle {
|
|
38
|
-
width: ${SwitchToken.unselectedHandleWidth};
|
|
39
|
-
height: ${SwitchToken.unselectedHandleHeight};
|
|
40
|
-
}
|
|
41
|
-
:host([checked]) .track:not(.pressed) .handle {
|
|
42
|
-
width: ${SwitchToken.selectedHandleWidth};
|
|
43
|
-
height: ${SwitchToken.selectedHandleHeight};
|
|
44
|
-
}
|
|
45
|
-
.track.pressed .handle {
|
|
46
|
-
width: ${SwitchToken.pressedHandleWidth};
|
|
47
|
-
height: ${SwitchToken.pressedHandleHeight};
|
|
48
|
-
}
|
|
49
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed) .handle {
|
|
50
|
-
background-color: ${SwitchToken.unselectedHandleColor};
|
|
51
|
-
}
|
|
52
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed) .handle {
|
|
53
|
-
background-color: ${SwitchToken.unselectedHoverHandleColor};
|
|
54
|
-
}
|
|
55
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed) .handle {
|
|
56
|
-
background-color: ${SwitchToken.unselectedFocusHandleColor};
|
|
57
|
-
}
|
|
58
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed .handle {
|
|
59
|
-
background-color: ${SwitchToken.unselectedPressedHandleColor};
|
|
60
|
-
}
|
|
61
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed) .handle {
|
|
62
|
-
background-color: ${SwitchToken.selectedHandleColor};
|
|
63
|
-
}
|
|
64
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed) .handle {
|
|
65
|
-
background-color: ${SwitchToken.selectedHoverHandleColor};
|
|
66
|
-
}
|
|
67
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed) .handle {
|
|
68
|
-
background-color: ${SwitchToken.selectedFocusHandleColor};
|
|
69
|
-
}
|
|
70
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed .handle {
|
|
71
|
-
background-color: ${SwitchToken.selectedPressedHandleColor};
|
|
72
|
-
}
|
|
73
|
-
:host([aria-disabled="true"]:not([checked])) .handle {
|
|
74
|
-
background-color: color-mix(
|
|
75
|
-
in srgb,
|
|
76
|
-
${SwitchToken.disabledUnselectedHandleColor} ${SwitchToken.disabledUnselectedHandleOpacity},
|
|
77
|
-
transparent
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
:host([aria-disabled="true"][checked]) .handle {
|
|
81
|
-
background-color: color-mix(
|
|
82
|
-
in srgb,
|
|
83
|
-
${SwitchToken.disabledSelectedHandleColor} ${SwitchToken.disabledSelectedHandleOpacity},
|
|
84
|
-
transparent
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
:host([checked]) .track:not(.pressed) .handle {
|
|
88
|
-
transform: translateX(
|
|
89
|
-
calc(${SwitchToken.trackWidth} - ${SwitchToken.selectedHandleWidth} - ${SwitchToken.trackOutlineWidth})
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
:host([checked]) .track.pressed .handle {
|
|
93
|
-
transform: translateX(
|
|
94
|
-
calc(${SwitchToken.trackWidth} - ${SwitchToken.pressedHandleWidth} - ${SwitchToken.trackOutlineWidth})
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
:host(:not([checked]):not([icons="both"])) .track:not(.pressed) .handle,
|
|
98
|
-
:host([aria-disabled="true"]:not([checked])) .handle {
|
|
99
|
-
transform: translateX(
|
|
100
|
-
calc(
|
|
101
|
-
${SwitchToken.trackOutlineWidth} + calc(${SwitchToken.pressedHandleWidth} - ${SwitchToken.withIconHandleWidth})
|
|
102
|
-
)
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
:host(:not([aria-disabled="true"]):not([checked])[icons="both"]) .track:not(.pressed) .handle {
|
|
106
|
-
transform: translateX(${SwitchToken.trackOutlineWidth});
|
|
107
|
-
}
|
|
108
|
-
@media (forced-colors: active) {
|
|
109
|
-
.handle {
|
|
110
|
-
transition: ${unsafeCSS(
|
|
111
|
-
`transform var(--_switch-handle-effect),
|
|
112
|
-
width ${DesignToken.motion.spring.fastEffects},
|
|
113
|
-
height ${DesignToken.motion.spring.fastEffects}`
|
|
114
|
-
)};
|
|
115
|
-
}
|
|
116
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed) .handle,
|
|
117
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed) .handle,
|
|
118
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed) .handle,
|
|
119
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed .handle {
|
|
120
|
-
background-color: ButtonText;
|
|
121
|
-
}
|
|
122
|
-
:host([aria-disabled="true"]:not([checked])) .handle {
|
|
123
|
-
background-color: GrayText;
|
|
124
|
-
}
|
|
125
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed) .handle,
|
|
126
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed) .handle,
|
|
127
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed) .handle,
|
|
128
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed .handle {
|
|
129
|
-
background-color: Canvas;
|
|
130
|
-
}
|
|
131
|
-
:host([aria-disabled="true"][checked]) .handle {
|
|
132
|
-
background-color: Canvas;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
@media (prefers-reduced-motion) {
|
|
136
|
-
.handle {
|
|
137
|
-
transition: none;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
`;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { css, unsafeCSS } from "lit";
|
|
2
|
-
import { DesignToken } from "@m3e/core";
|
|
3
|
-
|
|
4
|
-
import { SwitchToken } from "./SwitchToken";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Icon styles for `M3eSwitchElement`.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const SwitchIconStyle = css`
|
|
11
|
-
:host([icons="none"]) .icon,
|
|
12
|
-
:host([icons="selected"]:not([checked])) .icon,
|
|
13
|
-
:host([aria-disabled="true"]:not([checked])) .icon {
|
|
14
|
-
display: none;
|
|
15
|
-
}
|
|
16
|
-
.icon {
|
|
17
|
-
width: 1em;
|
|
18
|
-
transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
19
|
-
}
|
|
20
|
-
:host(:not([checked])) .icon {
|
|
21
|
-
font-size: ${SwitchToken.unselectedIconSize};
|
|
22
|
-
}
|
|
23
|
-
:host([checked]) .icon {
|
|
24
|
-
font-size: ${SwitchToken.selectedIconSize};
|
|
25
|
-
}
|
|
26
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed) .icon {
|
|
27
|
-
color: ${SwitchToken.unselectedIconColor};
|
|
28
|
-
}
|
|
29
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed) .icon {
|
|
30
|
-
color: ${SwitchToken.unselectedHoverIconColor};
|
|
31
|
-
}
|
|
32
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed) .icon {
|
|
33
|
-
color: ${SwitchToken.unselectedFocusIconColor};
|
|
34
|
-
}
|
|
35
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed .icon {
|
|
36
|
-
color: ${SwitchToken.unselectedPressedIconColor};
|
|
37
|
-
}
|
|
38
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed) .icon {
|
|
39
|
-
color: ${SwitchToken.selectedIconColor};
|
|
40
|
-
}
|
|
41
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed) .icon {
|
|
42
|
-
color: ${SwitchToken.selectedHoverIconColor};
|
|
43
|
-
}
|
|
44
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed) .icon {
|
|
45
|
-
color: ${SwitchToken.selectedFocusIconColor};
|
|
46
|
-
}
|
|
47
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed .icon {
|
|
48
|
-
color: ${SwitchToken.selectedPressedIconColor};
|
|
49
|
-
}
|
|
50
|
-
:host([aria-disabled="true"]:not([checked])) .icon {
|
|
51
|
-
color: color-mix(
|
|
52
|
-
in srgb,
|
|
53
|
-
${SwitchToken.disabledUnselectedIconColor} ${SwitchToken.disabledUnselectedIconOpacity},
|
|
54
|
-
transparent
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
:host([aria-disabled="true"][checked]) .icon {
|
|
58
|
-
color: color-mix(
|
|
59
|
-
in srgb,
|
|
60
|
-
${SwitchToken.disabledSelectedIconColor} ${SwitchToken.disabledSelectedIconOpacity},
|
|
61
|
-
transparent
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
@media (forced-colors: active) {
|
|
65
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed) .icon,
|
|
66
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed) .icon,
|
|
67
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed) .icon,
|
|
68
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed .icon {
|
|
69
|
-
color: Canvas;
|
|
70
|
-
}
|
|
71
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed) .icon,
|
|
72
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed) .icon,
|
|
73
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed) .icon,
|
|
74
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed .icon {
|
|
75
|
-
color: CanvasText;
|
|
76
|
-
}
|
|
77
|
-
:host([aria-disabled="true"]:not([checked])) .icon {
|
|
78
|
-
color: Canvas;
|
|
79
|
-
}
|
|
80
|
-
:host([aria-disabled="true"][checked]) .icon {
|
|
81
|
-
color: GrayText;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
@media (prefers-reduced-motion) {
|
|
85
|
-
.icon {
|
|
86
|
-
transition: none;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
import { SwitchToken } from "./SwitchToken";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* State layer styles for `M3eSwitchElement`.
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export const SwitchStateLayerStyle = css`
|
|
10
|
-
.state-layer {
|
|
11
|
-
width: ${SwitchToken.stateLayerSize};
|
|
12
|
-
height: ${SwitchToken.stateLayerSize};
|
|
13
|
-
border-radius: ${SwitchToken.stateLayerShape};
|
|
14
|
-
}
|
|
15
|
-
:host(:not([checked])[icons="both"]) .track:not(.pressed) .state-layer {
|
|
16
|
-
left: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.withIconHandleWidth}) / 2));
|
|
17
|
-
top: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.withIconHandleHeight}) / 2));
|
|
18
|
-
}
|
|
19
|
-
:host(:not([checked]):not([icons="both"])) .track:not(.pressed) .state-layer {
|
|
20
|
-
left: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.unselectedHandleWidth}) / 2));
|
|
21
|
-
top: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.unselectedHandleHeight}) / 2));
|
|
22
|
-
}
|
|
23
|
-
:host([checked]) .track:not(.pressed) .state-layer {
|
|
24
|
-
left: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.selectedHandleWidth}) / 2));
|
|
25
|
-
top: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.selectedHandleHeight}) / 2));
|
|
26
|
-
}
|
|
27
|
-
.track.pressed .state-layer {
|
|
28
|
-
left: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.pressedHandleWidth}) / 2));
|
|
29
|
-
top: calc(0px - calc(calc(${SwitchToken.stateLayerSize} - ${SwitchToken.pressedHandleWidth}) / 2));
|
|
30
|
-
}
|
|
31
|
-
:host(:not([checked])) .state-layer {
|
|
32
|
-
--m3e-state-layer-hover-color: ${SwitchToken.unselectedHoverStateLayerColor};
|
|
33
|
-
--m3e-state-layer-hover-opacity: ${SwitchToken.unselectedHoverStateLayerOpacity};
|
|
34
|
-
--m3e-state-layer-focus-color: ${SwitchToken.unselectedFocusStateLayerColor};
|
|
35
|
-
--m3e-state-layer-focus-opacity: ${SwitchToken.unselectedFocusStateLayerOpacity};
|
|
36
|
-
}
|
|
37
|
-
:host([checked]) .state-layer {
|
|
38
|
-
--m3e-state-layer-hover-color: ${SwitchToken.selectedHoverStateLayerColor};
|
|
39
|
-
--m3e-state-layer-hover-opacity: ${SwitchToken.selectedHoverStateLayerOpacity};
|
|
40
|
-
--m3e-state-layer-focus-color: ${SwitchToken.selectedFocusStateLayerColor};
|
|
41
|
-
--m3e-state-layer-focus-opacity: ${SwitchToken.selectedFocusStateLayerOpacity};
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
import { SwitchToken } from "./SwitchToken";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Baseline styles for `M3eSwitchElement`.
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export const SwitchStyle = css`
|
|
9
|
-
:host {
|
|
10
|
-
display: inline-block;
|
|
11
|
-
position: relative;
|
|
12
|
-
outline: none;
|
|
13
|
-
height: fit-content;
|
|
14
|
-
width: fit-content;
|
|
15
|
-
}
|
|
16
|
-
.focus-ring {
|
|
17
|
-
border-radius: ${SwitchToken.trackShape};
|
|
18
|
-
}
|
|
19
|
-
.touch {
|
|
20
|
-
position: absolute;
|
|
21
|
-
height: 3rem;
|
|
22
|
-
left: 0;
|
|
23
|
-
right: 0;
|
|
24
|
-
}
|
|
25
|
-
.base {
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { unsafeCSS } from "lit";
|
|
2
|
-
|
|
3
|
-
import { DesignToken } from "@m3e/core";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Component design tokens that control `M3eSwitchElement`.
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export const SwitchToken = {
|
|
10
|
-
selectedIconColor: unsafeCSS(`var(--m3e-switch-selected-icon-color, ${DesignToken.color.onPrimaryContainer})`),
|
|
11
|
-
selectedIconSize: unsafeCSS("var(--m3e-switch-selected-icon-size, 1rem)"),
|
|
12
|
-
unselectedIconColor: unsafeCSS(
|
|
13
|
-
`var(--m3e-switch-unselected-icon-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
14
|
-
),
|
|
15
|
-
unselectedIconSize: unsafeCSS("var(--m3e-switch-unselected-icon-size, 1rem)"),
|
|
16
|
-
trackHeight: unsafeCSS("var(--m3e-switch-track-height, 2rem)"),
|
|
17
|
-
trackWidth: unsafeCSS("var(--m3e-switch-track-width, 3.25rem)"),
|
|
18
|
-
trackOutlineColor: unsafeCSS(`var(--m3e-switch-track-outline-color, ${DesignToken.color.outline})`),
|
|
19
|
-
trackOutlineWidth: unsafeCSS("var(--m3e-switch-track-outline-width, 0.125rem)"),
|
|
20
|
-
trackShape: unsafeCSS(`var(--m3e-switch-track-shape, ${DesignToken.shape.corner.full})`),
|
|
21
|
-
selectedTrackColor: unsafeCSS(`var(--m3e-switch-selected-track-color, ${DesignToken.color.primary})`),
|
|
22
|
-
unselectedTrackColor: unsafeCSS(
|
|
23
|
-
`var(--m3e-switch-unselected-track-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
24
|
-
),
|
|
25
|
-
unselectedHandleHeight: unsafeCSS("var(--m3e-switch-unselected-handle-height, 1rem)"),
|
|
26
|
-
unselectedHandleWidth: unsafeCSS("var(--m3e-switch-unselected-handle-width, 1rem)"),
|
|
27
|
-
withIconHandleHeight: unsafeCSS("var(--m3e-switch-with-icon-handle-height, 1.5rem)"),
|
|
28
|
-
withIconHandleWidth: unsafeCSS("var(--m3e-switch-with-icon-handle-width, 1.5rem)"),
|
|
29
|
-
selectedHandleHeight: unsafeCSS("var(--m3e-switch-selected-handle-height, 1.5rem)"),
|
|
30
|
-
selectedHandleWidth: unsafeCSS("var(--m3e-switch-selected-handle-width, 1.5rem)"),
|
|
31
|
-
pressedHandleHeight: unsafeCSS("var(--m3e-switch-pressed-handle-height, 1.75rem)"),
|
|
32
|
-
pressedHandleWidth: unsafeCSS("var(--m3e-switch-pressed-handle-width, 1.75rem)"),
|
|
33
|
-
handleShape: unsafeCSS(`var(--m3e-switch-handle-shape, ${DesignToken.shape.corner.full})`),
|
|
34
|
-
selectedHandleColor: unsafeCSS(`var(--m3e-switch-selected-handle-color, ${DesignToken.color.onPrimary})`),
|
|
35
|
-
unselectedHandleColor: unsafeCSS(`var(--m3e-switch-unselected-handle-color, ${DesignToken.color.outline})`),
|
|
36
|
-
stateLayerSize: unsafeCSS("var(--m3e-switch-state-layer-size, 2.5rem)"),
|
|
37
|
-
stateLayerShape: unsafeCSS(`var(--m3e-switch-state-layer-shape, ${DesignToken.shape.corner.full})`),
|
|
38
|
-
disabledSelectedIconColor: unsafeCSS(
|
|
39
|
-
`var(--m3e-switch-disabled-selected-icon-color, ${DesignToken.color.onSurface})`
|
|
40
|
-
),
|
|
41
|
-
disabledSelectedIconOpacity: unsafeCSS("var(--m3e-switch-disabled-selected-icon-opacity, 38%)"),
|
|
42
|
-
disabledUnselectedIconColor: unsafeCSS(
|
|
43
|
-
`var(--m3e-switch-disabled-unselected-icon-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
44
|
-
),
|
|
45
|
-
disabledUnselectedIconOpacity: unsafeCSS("var(--m3e-switch-disabled-unselected-icon-opacity, 38%)"),
|
|
46
|
-
disabledTrackOpacity: unsafeCSS("var(--m3e-switch-disabled-track-opacity, 12%)"),
|
|
47
|
-
disabledSelectedTrackColor: unsafeCSS(
|
|
48
|
-
`var(--m3e-switch-disabled-selected-track-color, ${DesignToken.color.onSurface})`
|
|
49
|
-
),
|
|
50
|
-
disabledUnselectedTrackColor: unsafeCSS(
|
|
51
|
-
`var(--m3e-switch-disabled-unselected-track-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
52
|
-
),
|
|
53
|
-
disabledUnselectedTrackOutlineColor: unsafeCSS(
|
|
54
|
-
`var(--m3e-switch-disabled-unselected-track-outline-color, ${DesignToken.color.onSurface})`
|
|
55
|
-
),
|
|
56
|
-
disabledUnselectedHandleOpacity: unsafeCSS("var(--m3e-switch-disabled-unselected-handle-opacity, 38%)"),
|
|
57
|
-
disabledSelectedHandleOpacity: unsafeCSS("var(--m3e-switch-disabled-selected-handle-opacity, 100%)"),
|
|
58
|
-
disabledSelectedHandleColor: unsafeCSS(
|
|
59
|
-
`var(--m3e-switch-disabled-selected-handle-color, ${DesignToken.color.surface})`
|
|
60
|
-
),
|
|
61
|
-
disabledUnselectedHandleColor: unsafeCSS(
|
|
62
|
-
`var(--m3e-switch-disabled-unselected-handle-color, ${DesignToken.color.onSurface})`
|
|
63
|
-
),
|
|
64
|
-
selectedHoverIconColor: unsafeCSS(
|
|
65
|
-
`var(--m3e-switch-selected-hover-icon-color, ${DesignToken.color.onPrimaryContainer})`
|
|
66
|
-
),
|
|
67
|
-
unselectedHoverIconColor: unsafeCSS(
|
|
68
|
-
`var(--m3e-switch-unselected-hover-icon-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
69
|
-
),
|
|
70
|
-
selectedHoverTrackColor: unsafeCSS(`var(--m3e-switch-selected-hover-track-color, ${DesignToken.color.primary})`),
|
|
71
|
-
selectedHoverStateLayerColor: unsafeCSS(
|
|
72
|
-
`var(--m3e-switch-selected-hover-state-layer-color, ${DesignToken.color.primary})`
|
|
73
|
-
),
|
|
74
|
-
selectedHoverStateLayerOpacity: unsafeCSS("var(--m3e-switch-selected-hover-state-layer-opacity, 8%)"),
|
|
75
|
-
unselectedHoverTrackColor: unsafeCSS(
|
|
76
|
-
`var(--m3e-switch-unselected-hover-track-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
77
|
-
),
|
|
78
|
-
unselectedHoverTrackOutlineColor: unsafeCSS(
|
|
79
|
-
`var(--m3e-switch-unselected-hover-track-outline-color, ${DesignToken.color.outline})`
|
|
80
|
-
),
|
|
81
|
-
unselectedHoverStateLayerColor: unsafeCSS(
|
|
82
|
-
`var(--m3e-switch-unselected-hover-state-layer-color, ${DesignToken.color.onSurface})`
|
|
83
|
-
),
|
|
84
|
-
unselectedHoverStateLayerOpacity: unsafeCSS("var(--m3e-switch-unselected-hover-state-layer-opacity, 8%)"),
|
|
85
|
-
selectedHoverHandleColor: unsafeCSS(
|
|
86
|
-
`var(--m3e-switch-selected-hover-handle-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
87
|
-
),
|
|
88
|
-
unselectedHoverHandleColor: unsafeCSS(
|
|
89
|
-
`var(--m3e-switch-unselected-hover-handle-color, ${DesignToken.color.onSurfaceVariant})`
|
|
90
|
-
),
|
|
91
|
-
selectedFocusIconColor: unsafeCSS(
|
|
92
|
-
`var(--m3e-switch-selected-focus-icon-color, ${DesignToken.color.onPrimaryContainer})`
|
|
93
|
-
),
|
|
94
|
-
unselectedFocusIconColor: unsafeCSS(
|
|
95
|
-
`var(--m3e-switch-unselected-focus-icon-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
96
|
-
),
|
|
97
|
-
selectedFocusTrackColor: unsafeCSS(`var(--m3e-switch-selected-focus-track-color, ${DesignToken.color.primary})`),
|
|
98
|
-
selectedFocusStateLayerColor: unsafeCSS(
|
|
99
|
-
`var(--m3e-switch-selected-focus-state-layer-color, ${DesignToken.color.primary})`
|
|
100
|
-
),
|
|
101
|
-
selectedFocusStateLayerOpacity: unsafeCSS("var(--m3e-switch-selected-focus-state-layer-opacity, 10%)"),
|
|
102
|
-
unselectedFocusTrackColor: unsafeCSS(
|
|
103
|
-
`var(--m3e-switch-unselected-focus-track-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
104
|
-
),
|
|
105
|
-
unselectedFocusTrackOutlineColor: unsafeCSS(
|
|
106
|
-
`var(--m3e-switch-unselected-focus-track-outline-color, ${DesignToken.color.outline})`
|
|
107
|
-
),
|
|
108
|
-
unselectedFocusStateLayerColor: unsafeCSS(
|
|
109
|
-
`var(--m3e-switch-unselected-focus-state-layer-color, ${DesignToken.color.onSurface})`
|
|
110
|
-
),
|
|
111
|
-
unselectedFocusStateLayerOpacity: unsafeCSS("var(--m3e-switch-unselected-focus-state-layer-opacity, 10%)"),
|
|
112
|
-
selectedFocusHandleColor: unsafeCSS(
|
|
113
|
-
`var(--m3e-switch-selected-focus-handle-color, ${DesignToken.color.primaryContainer})`
|
|
114
|
-
),
|
|
115
|
-
unselectedFocusHandleColor: unsafeCSS(
|
|
116
|
-
`var(--m3e-switch-unselected-focus-handle-color, ${DesignToken.color.onSurfaceVariant})`
|
|
117
|
-
),
|
|
118
|
-
selectedPressedIconColor: unsafeCSS(
|
|
119
|
-
`var(--m3e-switch-selected-pressed-icon-color, ${DesignToken.color.onPrimaryContainer})`
|
|
120
|
-
),
|
|
121
|
-
unselectedPressedIconColor: unsafeCSS(
|
|
122
|
-
`var(--m3e-switch-unselected-pressed-icon-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
123
|
-
),
|
|
124
|
-
selectedPressedTrackColor: unsafeCSS(`var(--m3e-switch-selected-pressed-track-color, ${DesignToken.color.primary})`),
|
|
125
|
-
selectedPressedStateLayerColor: unsafeCSS(
|
|
126
|
-
`var(--m3e-switch-selected-pressed-state-layer-color, ${DesignToken.color.primary})`
|
|
127
|
-
),
|
|
128
|
-
selectedPressedStateLayerOpacity: unsafeCSS("var(--m3e-switch-selected-pressed-state-layer-opacity, 10%)"),
|
|
129
|
-
unselectedPressedTrackColor: unsafeCSS(
|
|
130
|
-
`var(--m3e-switch-unselected-pressed-track-color, ${DesignToken.color.surfaceContainerHighest})`
|
|
131
|
-
),
|
|
132
|
-
unselectedPressedTrackOutlineColor: unsafeCSS(
|
|
133
|
-
`var(--m3e-switch-unselected-pressed-track-outline-color, ${DesignToken.color.outline})`
|
|
134
|
-
),
|
|
135
|
-
unselectedPressedStateLayerColor: unsafeCSS(
|
|
136
|
-
`var(--m3e-switch-unselected-pressed-state-layer-color, ${DesignToken.color.onSurface})`
|
|
137
|
-
),
|
|
138
|
-
unselectedPressedStateLayerOpacity: unsafeCSS("var(--m3e-switch-unselected-pressed-state-layer-opacity, 10%)"),
|
|
139
|
-
selectedPressedHandleColor: unsafeCSS(
|
|
140
|
-
`var(--m3e-switch-selected-pressed-handle-color, ${DesignToken.color.primaryContainer})`
|
|
141
|
-
),
|
|
142
|
-
unselectedPressedHandleColor: unsafeCSS(
|
|
143
|
-
`var(--m3e-switch-unselected-pressed-handle-color, ${DesignToken.color.onSurfaceVariant})`
|
|
144
|
-
),
|
|
145
|
-
} as const;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { css, unsafeCSS } from "lit";
|
|
2
|
-
import { DesignToken } from "@m3e/core";
|
|
3
|
-
|
|
4
|
-
import { SwitchToken } from "./SwitchToken";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Track styles for `M3eSwitchElement`.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const SwitchTrackStyle = css`
|
|
11
|
-
.track {
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
position: relative;
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
border-radius: ${SwitchToken.trackShape};
|
|
17
|
-
width: ${SwitchToken.trackWidth};
|
|
18
|
-
height: ${SwitchToken.trackHeight};
|
|
19
|
-
transition: ${unsafeCSS(
|
|
20
|
-
`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`
|
|
21
|
-
)};
|
|
22
|
-
}
|
|
23
|
-
:host(:not([checked])) .track {
|
|
24
|
-
border-width: ${SwitchToken.trackOutlineWidth};
|
|
25
|
-
border-style: solid;
|
|
26
|
-
}
|
|
27
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed) {
|
|
28
|
-
border-color: ${SwitchToken.trackOutlineColor};
|
|
29
|
-
background-color: ${SwitchToken.unselectedTrackColor};
|
|
30
|
-
}
|
|
31
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed) {
|
|
32
|
-
border-color: ${SwitchToken.unselectedHoverTrackOutlineColor};
|
|
33
|
-
background-color: ${SwitchToken.unselectedHoverTrackColor};
|
|
34
|
-
}
|
|
35
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed) {
|
|
36
|
-
border-color: ${SwitchToken.unselectedFocusTrackOutlineColor};
|
|
37
|
-
background-color: ${SwitchToken.unselectedFocusTrackColor};
|
|
38
|
-
}
|
|
39
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed {
|
|
40
|
-
border-color: ${SwitchToken.unselectedPressedTrackOutlineColor};
|
|
41
|
-
background-color: ${SwitchToken.unselectedPressedTrackColor};
|
|
42
|
-
}
|
|
43
|
-
:host([aria-disabled="true"]:not([checked])) .track {
|
|
44
|
-
border-color: color-mix(
|
|
45
|
-
in srgb,
|
|
46
|
-
${SwitchToken.disabledUnselectedTrackOutlineColor} ${SwitchToken.disabledTrackOpacity},
|
|
47
|
-
transparent
|
|
48
|
-
);
|
|
49
|
-
background-color: color-mix(
|
|
50
|
-
in srgb,
|
|
51
|
-
${SwitchToken.disabledUnselectedTrackColor} ${SwitchToken.disabledTrackOpacity},
|
|
52
|
-
transparent
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed) {
|
|
56
|
-
background-color: ${SwitchToken.selectedTrackColor};
|
|
57
|
-
}
|
|
58
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed) {
|
|
59
|
-
background-color: ${SwitchToken.selectedHoverTrackColor};
|
|
60
|
-
}
|
|
61
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed) {
|
|
62
|
-
background-color: ${SwitchToken.selectedFocusTrackColor};
|
|
63
|
-
}
|
|
64
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed {
|
|
65
|
-
background-color: ${SwitchToken.selectedPressedTrackColor};
|
|
66
|
-
}
|
|
67
|
-
:host([aria-disabled="true"][checked]) .track {
|
|
68
|
-
background-color: color-mix(
|
|
69
|
-
in srgb,
|
|
70
|
-
${SwitchToken.disabledSelectedTrackColor} ${SwitchToken.disabledTrackOpacity},
|
|
71
|
-
transparent
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
@media (forced-colors: active) {
|
|
75
|
-
.track {
|
|
76
|
-
transition: none;
|
|
77
|
-
}
|
|
78
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):not(:hover)) .track:not(.pressed),
|
|
79
|
-
:host(:not([aria-disabled="true"]):not([checked]):not(:focus):hover) .track:not(.pressed),
|
|
80
|
-
:host(:not([aria-disabled="true"]):not([checked]):focus) .track:not(.pressed),
|
|
81
|
-
:host(:not([aria-disabled="true"]):not([checked])) .track.pressed {
|
|
82
|
-
border-color: ButtonText;
|
|
83
|
-
background-color: Canvas;
|
|
84
|
-
}
|
|
85
|
-
:host([aria-disabled="true"]:not([checked])) .track {
|
|
86
|
-
border-color: GrayText;
|
|
87
|
-
background-color: Canvas;
|
|
88
|
-
}
|
|
89
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):not(:hover)) .track:not(.pressed),
|
|
90
|
-
:host(:not([aria-disabled="true"])[checked]:not(:focus):hover) .track:not(.pressed),
|
|
91
|
-
:host(:not([aria-disabled="true"])[checked]:focus) .track:not(.pressed),
|
|
92
|
-
:host(:not([aria-disabled="true"])[checked]) .track.pressed {
|
|
93
|
-
background-color: ButtonText;
|
|
94
|
-
}
|
|
95
|
-
:host([aria-disabled="true"][checked]) .track {
|
|
96
|
-
background-color: GrayText;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
@media (prefers-reduced-motion) {
|
|
100
|
-
.track {
|
|
101
|
-
transition: none;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
`;
|
package/src/styles/index.ts
DELETED