@glasshome/ui 1.23.0 → 1.25.0
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/SPEC.md +40 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/lib/anchor-placement.d.ts +3 -4
- package/dist/lib/card-classes.d.ts +4 -4
- package/dist/lib/hold.d.ts +6 -0
- package/dist/lib/input-classes.d.ts +1 -0
- package/dist/lib/motion-classes.d.ts +1 -1
- package/dist/lib/overlay-classes.d.ts +2 -2
- package/dist/lib/position-bar-classes.d.ts +1 -1
- package/dist/lib/thumb-classes.d.ts +0 -1
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +4230 -4208
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/toggle-group.d.ts +1 -1
- package/dist/tokens/index.js +201 -101
- package/dist/tokens/material.d.ts +53 -8
- package/dist/{utils-o6ev-9h_.js → utils-Sl2ceVna.js} +119 -119
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/lib/anchor-placement.ts +38 -15
- package/src/lib/button-variants.ts +1 -1
- package/src/lib/card-classes.ts +2 -2
- package/src/lib/hold.ts +7 -0
- package/src/lib/input-classes.ts +5 -0
- package/src/lib/motion-classes.ts +1 -1
- package/src/lib/overlay-classes.ts +1 -1
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/thumb-classes.ts +0 -7
- package/src/solid/checkbox.tsx +1 -1
- package/src/solid/dialog.tsx +16 -1
- package/src/solid/index.ts +1 -0
- package/src/solid/slider.tsx +5 -3
- package/src/solid/sliding-indicator.tsx +2 -2
- package/src/solid/switch.tsx +5 -7
- package/src/solid/tabs.tsx +1 -1
- package/src/solid/toggle-group.tsx +3 -3
- package/src/solid/toggle.tsx +1 -1
- package/src/styles/globals.css +237 -21
- package/src/styles/theme.css +31 -15
- package/src/tokens/material.ts +215 -41
|
@@ -2,27 +2,50 @@ import type { JSX } from "solid-js";
|
|
|
2
2
|
|
|
3
3
|
const EDGE = 16;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface Box {
|
|
6
|
+
left: number;
|
|
7
|
+
top: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Where a panel of this size sits over its anchor: centred on it, shifted only as far as the
|
|
13
|
+
* screen needs, as wide as the anchor at least. Before the panel is measured (`height`
|
|
14
|
+
* undefined) its top sits on the anchor's top. */
|
|
15
|
+
function anchoredBox(
|
|
16
|
+
anchor: Box,
|
|
17
|
+
viewport: { width: number; height: number },
|
|
18
|
+
width: number,
|
|
19
|
+
height?: number,
|
|
20
|
+
): Box {
|
|
21
|
+
const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(v, hi));
|
|
22
|
+
const w = Math.min(Math.max(width, anchor.width), viewport.width - 2 * EDGE);
|
|
23
|
+
const x = clamp(anchor.left + (anchor.width - w) / 2, EDGE, viewport.width - EDGE - w);
|
|
24
|
+
const h = Math.min(Math.max(height ?? 0, anchor.height), viewport.height - 2 * EDGE);
|
|
25
|
+
const y =
|
|
26
|
+
height === undefined
|
|
27
|
+
? clamp(anchor.top, EDGE, viewport.height - EDGE - h)
|
|
28
|
+
: clamp(anchor.top + (anchor.height - h) / 2, EDGE, viewport.height - EDGE - h);
|
|
29
|
+
return { left: x, top: y, width: w, height: h };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A panel that grows out of the element that opened it. The --morph-* values start the panel
|
|
33
|
+
* clipped to the element's box (MORPH_MOTION's keyframes), so it unrolls out of it. */
|
|
34
|
+
export function overAnchor(anchor: HTMLElement, width: number, height?: number): JSX.CSSProperties {
|
|
9
35
|
const box = anchor.getBoundingClientRect();
|
|
10
|
-
const vw = window.innerWidth;
|
|
11
36
|
const vh = window.innerHeight;
|
|
12
|
-
const
|
|
13
|
-
const x = Math.max(EDGE, Math.min(box.left, vw - EDGE - w));
|
|
14
|
-
const y = Math.max(EDGE, Math.min(box.top, vh - EDGE - Math.max(box.height, 240)));
|
|
37
|
+
const placed = anchoredBox(box, { width: window.innerWidth, height: vh }, width, height);
|
|
15
38
|
const radius = getComputedStyle(anchor).borderTopLeftRadius || "0px";
|
|
16
39
|
return {
|
|
17
|
-
left: `${
|
|
18
|
-
top: `${
|
|
40
|
+
left: `${placed.left}px`,
|
|
41
|
+
top: `${placed.top}px`,
|
|
19
42
|
translate: "none",
|
|
20
|
-
width: `${
|
|
43
|
+
width: `${placed.width}px`,
|
|
21
44
|
"max-width": "none",
|
|
22
|
-
"min-height": `${Math.min(box.height, vh -
|
|
23
|
-
"max-height": `${vh -
|
|
24
|
-
"--morph-x": `${box.left -
|
|
25
|
-
"--morph-y": `${box.top -
|
|
45
|
+
"min-height": `${Math.min(box.height, vh - 2 * EDGE)}px`,
|
|
46
|
+
"max-height": `${vh - 2 * EDGE}px`,
|
|
47
|
+
"--morph-x": `${box.left - placed.left}px`,
|
|
48
|
+
"--morph-y": `${box.top - placed.top}px`,
|
|
26
49
|
"--morph-w": `${box.width}px`,
|
|
27
50
|
"--morph-h": `${box.height}px`,
|
|
28
51
|
"--morph-radius": radius,
|
|
@@ -20,7 +20,7 @@ export const buttonVariants = cva({
|
|
|
20
20
|
base: "transition-glass focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-lg text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-[3px] active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
21
21
|
variants: {
|
|
22
22
|
variant: {
|
|
23
|
-
default: `glass glass-tint ${CONTROL_GLASS} [--glass-text:0%] [--glass-tone:var(--
|
|
23
|
+
default: `glass glass-tint ${CONTROL_GLASS} [--glass-text:0%] [--glass-tone:var(--material-accent)] [--glass-wash:55%] hover:[--glass-edge:color-mix(in_srgb,var(--material-accent)_60%,transparent)] hover:[--glass-wash:65%] dark:[color:oklch(from_var(--glass-tone)_calc((0.74_-_l)*100)_0_0)] dark:[--glass-tone:oklch(from_var(--material-accent)_calc(l_+_clamp(0,(l_-_0.74)*10,0.1))_c_h)] dark:[--glass-wash:62%] dark:hover:[--glass-wash:70%]`,
|
|
24
24
|
destructive: `glass glass-tint ${CONTROL_GLASS} focus-visible:ring-destructive/30 [--glass-text:0%] [--glass-tone:var(--destructive)] [--glass-wash:55%] hover:[--glass-edge:color-mix(in_srgb,var(--destructive)_60%,transparent)] hover:[--glass-wash:65%] dark:[color:oklch(from_var(--glass-tone)_calc((0.74_-_l)*100)_0_0)] dark:[--glass-tone:oklch(from_var(--destructive)_calc(l_+_clamp(0,(l_-_0.74)*10,0.1))_c_h)] dark:[--glass-wash:62%] dark:hover:[--glass-wash:70%]`,
|
|
25
25
|
secondary: `glass glass-tint ${CONTROL_GLASS} [--glass-text:0%] [--glass-tone:var(--accent)] [--glass-wash:55%] hover:[--glass-edge:color-mix(in_srgb,var(--accent)_60%,transparent)] hover:[--glass-wash:65%] dark:[color:oklch(from_var(--glass-tone)_calc((0.74_-_l)*100)_0_0)] dark:[--glass-tone:oklch(from_var(--accent)_calc(l_+_clamp(0,(l_-_0.74)*10,0.1))_c_h)] dark:[--glass-wash:62%] dark:hover:[--glass-wash:70%]`,
|
|
26
26
|
outline: OUTLINE_SURFACE,
|
package/src/lib/card-classes.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PRESS_DIP } from "./motion-classes.js";
|
|
2
2
|
|
|
3
3
|
const CARD_KNOBS =
|
|
4
|
-
"glass [--glass-wash:20%] [--glass-rim:0.3] [--glass-lift:0.45] [--glass-shade:0.05] dark:[--glass-shade:0]";
|
|
4
|
+
"glass [--glass-grain:var(--_material-grain)] [--glass-wash:20%] [--glass-rim:0.3] [--glass-lift:0.45] [--glass-shade:0.05] dark:[--glass-shade:0]";
|
|
5
5
|
|
|
6
6
|
export const CARD_SURFACE_BASE = `${CARD_KNOBS} [--glass-base:color-mix(in_srgb,var(--card)_var(--material-clarity),transparent)]`;
|
|
7
7
|
|
|
8
8
|
/* Split from the surface so dash's performant-blur engine can gate it off and
|
|
9
9
|
* paint a precomputed frost instead. */
|
|
10
10
|
export const CARD_BLUR =
|
|
11
|
-
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[1.8]";
|
|
11
|
+
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(1.8*var(--_material-vibrancy,1))] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]";
|
|
12
12
|
|
|
13
13
|
export const CARD_SURFACE = `${CARD_SURFACE_BASE} ${CARD_BLUR}`;
|
|
14
14
|
|
package/src/lib/hold.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A press held this long, without moving, is a hold. Matches Android's long-press timeout, so the
|
|
2
|
+
* browser's own long press never wins the race. */
|
|
3
|
+
export const HOLD_MS = 350;
|
|
4
|
+
|
|
5
|
+
/** A tap ends inside this window, so it never shows the hold fill. The fill then grows on
|
|
6
|
+
* --duration-hold, which is HOLD_MS - HOLD_GRACE_MS. */
|
|
7
|
+
export const HOLD_GRACE_MS = 100;
|
package/src/lib/input-classes.ts
CHANGED
|
@@ -17,6 +17,11 @@ export const INPUT_SURFACE =
|
|
|
17
17
|
* in the light theme. */
|
|
18
18
|
export const FIELD_CHROME = "glass glass-sink [--glass-base:var(--input)] [--glass-light:0.04]";
|
|
19
19
|
|
|
20
|
+
/* A control that is on: the material's accent, strong enough to carry the state
|
|
21
|
+
* on its own, so the knob riding it can stay plain. */
|
|
22
|
+
export const CONTROL_ON =
|
|
23
|
+
"glass glass-tint [--glass-tone:var(--material-accent)] [--glass-wash:100%] [--glass-text:0%]";
|
|
24
|
+
|
|
20
25
|
/* Focus on a glass element: border utilities are no-ops there, so the edge
|
|
21
26
|
* moves through the knob and the ring paints outside. */
|
|
22
27
|
export const FOCUS_RING =
|
|
@@ -47,7 +47,7 @@ export const PRESS_DIP = "active:scale-[0.97]";
|
|
|
47
47
|
/* Hold progress: a fill grows out of the touch while held, dissolves once the
|
|
48
48
|
* hold fires, and drains back faster if let go early. The host sets data-hold / data-fired. */
|
|
49
49
|
export const HOLD_MOTION =
|
|
50
|
-
"scale-0 opacity-0 transition-[scale,opacity] duration-(--duration-state) ease-(--ease-contract) data-[hold]:scale-100 data-[hold]:opacity-100 data-[hold]:duration-(--duration-
|
|
50
|
+
"scale-0 opacity-0 transition-[scale,opacity] duration-(--duration-state) ease-(--ease-contract) data-[hold]:scale-100 data-[hold]:opacity-100 data-[hold]:duration-(--duration-hold) data-[hold]:ease-linear data-[fired]:scale-100 data-[fired]:opacity-0";
|
|
51
51
|
|
|
52
52
|
/* MODAL_MOTION's twin for a surface that stays mounted: it rises out of what
|
|
53
53
|
* opened it, and its closed state is a resting style, since a mount door's exit
|
|
@@ -9,7 +9,7 @@ const OVERLAY_KNOBS =
|
|
|
9
9
|
/* Split from the surface the way CARD_BLUR is, so a host can gate it off and
|
|
10
10
|
* paint a precomputed frost instead. */
|
|
11
11
|
export const OVERLAY_BLUR =
|
|
12
|
-
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[1.2]";
|
|
12
|
+
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(1.2*var(--_material-vibrancy,1))] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]";
|
|
13
13
|
|
|
14
14
|
export const OVERLAY_SURFACE_BASE = `${OVERLAY_KNOBS} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`;
|
|
15
15
|
|
|
@@ -7,4 +7,4 @@ import { FIELD_CHROME } from "./input-classes.js";
|
|
|
7
7
|
export const POSITION_BAR = `${FIELD_CHROME} h-1.5 rounded-full transition-glass duration-(--duration-morph) ease-(--ease-morph)`;
|
|
8
8
|
|
|
9
9
|
export const POSITION_BAR_LIT =
|
|
10
|
-
"glass glass-tint [--glass-tone:var(--
|
|
10
|
+
"glass glass-tint [--glass-tone:var(--material-accent)] [--glass-wash:70%] [--glass-drop:0%]";
|
package/src/lib/thumb-classes.ts
CHANGED
|
@@ -11,13 +11,6 @@ export const THUMB_SIZE = 31;
|
|
|
11
11
|
export const THUMB_CLASS =
|
|
12
12
|
"block size-7 shrink-0 rounded-xl shadow-[0_2px_5px_oklch(0_0_0/0.35),inset_0_1px_0_oklch(1_0_0/0.35),inset_0_-2px_3px_oklch(0_0_0/0.2)]";
|
|
13
13
|
|
|
14
|
-
/* The lit knob wears the theme's hue at the depth theme.css sets per mode. The
|
|
15
|
-
* knob re-declares --thumb-face-on on itself with this value: a var() resolves
|
|
16
|
-
* where it is declared, so the :root one answers for the page only and a
|
|
17
|
-
* container that re-scopes --primary (a theme preview) would keep the page's. */
|
|
18
|
-
export const THUMB_FACE_ON =
|
|
19
|
-
"oklch(from var(--primary) var(--thumb-on-l) min(c, var(--thumb-on-c)) h)";
|
|
20
|
-
|
|
21
14
|
/* A rail pads by half a thumb so the knob stays inside the track at both ends;
|
|
22
15
|
* the fill cancels the same inset to reach the rounded edges. */
|
|
23
16
|
/* A thumb painted the live channel colour sits on a track of that same colour,
|
package/src/solid/checkbox.tsx
CHANGED
|
@@ -38,7 +38,7 @@ const Checkbox: Component<ComponentProps<typeof CheckboxPrimitive> & { size?: Ch
|
|
|
38
38
|
size().box,
|
|
39
39
|
"peer-focus-visible:ring-ring/50 peer-focus-visible:ring-[3px] peer-focus-visible:[--glass-edge:var(--ring)]",
|
|
40
40
|
state.checked()
|
|
41
|
-
? "glass glass-tint text-foreground [--glass-tone:var(--
|
|
41
|
+
? "glass glass-tint text-foreground [--glass-tone:var(--material-accent)]"
|
|
42
42
|
: FIELD_CHROME,
|
|
43
43
|
props.disabled && "cursor-not-allowed opacity-40",
|
|
44
44
|
local.class,
|
package/src/solid/dialog.tsx
CHANGED
|
@@ -87,25 +87,40 @@ const DialogContent: ParentComponent<DialogContentProps> = (props) => {
|
|
|
87
87
|
"ariaLabel",
|
|
88
88
|
"anchor",
|
|
89
89
|
"style",
|
|
90
|
+
"ref",
|
|
90
91
|
]);
|
|
91
92
|
const context = useDialogContext();
|
|
92
93
|
const [viewport, setViewport] = createSignal(0);
|
|
94
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
95
|
+
const [height, setHeight] = createSignal<number>();
|
|
93
96
|
createEffect(() => {
|
|
94
97
|
if (!local.anchor || !context.isOpen()) return;
|
|
95
98
|
const measure = () => setViewport((n) => n + 1);
|
|
96
99
|
window.addEventListener("resize", measure);
|
|
97
100
|
onCleanup(() => window.removeEventListener("resize", measure));
|
|
98
101
|
});
|
|
102
|
+
createEffect(() => {
|
|
103
|
+
const el = panel();
|
|
104
|
+
if (!local.anchor || !el) return;
|
|
105
|
+
setHeight(el.offsetHeight);
|
|
106
|
+
const observer = new ResizeObserver(() => setHeight(el.offsetHeight));
|
|
107
|
+
observer.observe(el);
|
|
108
|
+
onCleanup(() => observer.disconnect());
|
|
109
|
+
});
|
|
99
110
|
const placement = () => {
|
|
100
111
|
viewport();
|
|
101
112
|
const a = local.anchor;
|
|
102
|
-
return a ? overAnchor(a, ANCHORED_WIDTH[local.size ?? "lg"]) : undefined;
|
|
113
|
+
return a ? overAnchor(a, ANCHORED_WIDTH[local.size ?? "lg"], height()) : undefined;
|
|
103
114
|
};
|
|
104
115
|
return (
|
|
105
116
|
<DialogPrimitive.Portal>
|
|
106
117
|
<ModalScrollLock />
|
|
107
118
|
<DialogPrimitive.Overlay data-slot="dialog-overlay" class={MODAL_SCRIM} />
|
|
108
119
|
<DialogPrimitive.Content
|
|
120
|
+
ref={(el: HTMLElement) => {
|
|
121
|
+
setPanel(el);
|
|
122
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
123
|
+
}}
|
|
109
124
|
data-slot="dialog-content"
|
|
110
125
|
role="dialog"
|
|
111
126
|
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
package/src/solid/index.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export { type Color, parseColor } from "@kobalte/core/colors";
|
|
6
6
|
// Floating glass panel + its shared surface token.
|
|
7
7
|
export { SECTION_ROW_SURFACE } from "../lib/card-classes.js";
|
|
8
|
+
export { HOLD_GRACE_MS, HOLD_MS } from "../lib/hold.js";
|
|
8
9
|
export { RISE_MOTION, SETTLE_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
9
10
|
export { OVERLAY_SURFACE } from "../lib/overlay-classes.js";
|
|
10
11
|
// Section tokens re-exported from the Solid entry for convenience.
|
package/src/solid/slider.tsx
CHANGED
|
@@ -94,7 +94,7 @@ const Slider: Component<SliderProps> = (props) => {
|
|
|
94
94
|
class={cn(
|
|
95
95
|
// The fill sits sunk inside the recessed rail: the tinted-surface
|
|
96
96
|
// outer drop shadow would read as a halo leaking out of the groove.
|
|
97
|
-
"glass glass-tint absolute inset-y-0 rounded-xl [--glass-drop:0%]",
|
|
97
|
+
"glass glass-tint absolute inset-y-0 rounded-xl [--glass-drop:0%] [--glass-wash:90%]",
|
|
98
98
|
THUMB_RAIL_BLEED,
|
|
99
99
|
Array.isArray(local.fillTone) && "glass-edge-gradient",
|
|
100
100
|
)}
|
|
@@ -106,7 +106,7 @@ const Slider: Component<SliderProps> = (props) => {
|
|
|
106
106
|
"--glass-wash-2": "var(--glass-wash)",
|
|
107
107
|
"--glass-wash-angle": "90deg",
|
|
108
108
|
}
|
|
109
|
-
: { "--glass-tone": local.fillTone ?? "var(--
|
|
109
|
+
: { "--glass-tone": local.fillTone ?? "var(--material-accent)" }
|
|
110
110
|
}
|
|
111
111
|
/>
|
|
112
112
|
<Index each={local.markers ?? []}>
|
|
@@ -134,7 +134,9 @@ const Slider: Component<SliderProps> = (props) => {
|
|
|
134
134
|
)}
|
|
135
135
|
aria-label={local["aria-label"]}
|
|
136
136
|
aria-labelledby={local["aria-labelledby"]}
|
|
137
|
-
style={{
|
|
137
|
+
style={{
|
|
138
|
+
background: local.thumbColors?.[thumbIndex] ?? "var(--material-control-knob)",
|
|
139
|
+
}}
|
|
138
140
|
>
|
|
139
141
|
<KSlider.Input />
|
|
140
142
|
</KSlider.Thumb>
|
|
@@ -40,7 +40,7 @@ interface SlidingIndicatorProps extends ComponentProps<"div"> {
|
|
|
40
40
|
* this can't flatten the indicator; it only tunes it. Default radius: `rounded-lg`. */
|
|
41
41
|
indicatorClass?: string;
|
|
42
42
|
/** Glass tone that drives the `.glass` material (`--glass-tone`). Defaults to
|
|
43
|
-
* `var(--
|
|
43
|
+
* `var(--material-accent)`, the theme accent unless the material sets its own. Pass another CSS color to re-tint. */
|
|
44
44
|
indicatorTone?: string;
|
|
45
45
|
/** Selector for the measurable items. Default: direct children (minus the indicator). */
|
|
46
46
|
itemSelector?: string;
|
|
@@ -306,7 +306,7 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
306
306
|
transition: sliding()
|
|
307
307
|
? `transform ${SLIDE_MS}ms ease-in-out, width ${SLIDE_MS}ms ease-in-out, height ${SLIDE_MS}ms ease-in-out`
|
|
308
308
|
: "none",
|
|
309
|
-
"--glass-tone": local.indicatorTone ?? "var(--
|
|
309
|
+
"--glass-tone": local.indicatorTone ?? "var(--material-accent)",
|
|
310
310
|
...(local.wrapped && horizontal()
|
|
311
311
|
? {
|
|
312
312
|
transform: `translate(${p().offset}px, ${p().crossOffset}px)`,
|
package/src/solid/switch.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
|
|
2
|
-
import { FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
|
|
3
|
-
import { THUMB_CLASS
|
|
2
|
+
import { CONTROL_ON, FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
|
|
3
|
+
import { THUMB_CLASS } from "../lib/thumb-classes.js";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
5
|
|
|
6
6
|
type SwitchProps = Omit<ComponentProps<"button">, "onChange" | "children"> & {
|
|
@@ -35,7 +35,7 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
35
35
|
// the slider rail; checked matches the slider fill. A `border-input`
|
|
36
36
|
// utility here would beat `:where(.glass)` and flatten the rim.
|
|
37
37
|
`group/switch peer transition-glass relative inline-flex h-7 w-14 shrink-0 cursor-pointer items-center rounded-xl duration-200 ease-out disabled:cursor-not-allowed disabled:opacity-50 ${FOCUS_RING}`,
|
|
38
|
-
checked() ?
|
|
38
|
+
checked() ? CONTROL_ON : FIELD_CHROME,
|
|
39
39
|
local.class,
|
|
40
40
|
)}
|
|
41
41
|
onClick={() => {
|
|
@@ -50,11 +50,9 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
50
50
|
THUMB_CLASS,
|
|
51
51
|
"pointer-events-none transition-transform duration-300 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] group-data-[checked]/switch:translate-x-full",
|
|
52
52
|
)}
|
|
53
|
-
// Off must read quieter than on: the knob dims with the track
|
|
54
|
-
// than staying one bright material in both states.
|
|
53
|
+
// Off must read quieter than on: the knob dims with the track.
|
|
55
54
|
style={{
|
|
56
|
-
"--thumb-face-
|
|
57
|
-
background: checked() ? "var(--thumb-face-on)" : "var(--thumb-face-off)",
|
|
55
|
+
background: checked() ? "var(--material-control-knob)" : "var(--thumb-face-off)",
|
|
58
56
|
}}
|
|
59
57
|
/>
|
|
60
58
|
{local.name && <input type="hidden" name={local.name} value={checked() ? "on" : "off"} />}
|
package/src/solid/tabs.tsx
CHANGED
|
@@ -97,7 +97,7 @@ const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger> & { ic
|
|
|
97
97
|
class={cn(
|
|
98
98
|
SEGMENT_ITEM,
|
|
99
99
|
PRESS_DIP,
|
|
100
|
-
"hover:text-
|
|
100
|
+
"hover:text-(--material-accent)/80 data-[selected]:text-(--material-accent)",
|
|
101
101
|
local.icon && "h-auto flex-1 flex-col gap-1 py-2 text-xs",
|
|
102
102
|
local.class,
|
|
103
103
|
)}
|
|
@@ -29,7 +29,7 @@ const ToggleGroupContext = createContext<ToggleGroupContextValue>({
|
|
|
29
29
|
const ToggleGroup: ParentComponent<
|
|
30
30
|
ComponentProps<typeof ToggleGroupPrimitive> &
|
|
31
31
|
VariantProps<typeof toggleVariants> & {
|
|
32
|
-
/** CSS colour for the selected segment's glass. Default `var(--
|
|
32
|
+
/** CSS colour for the selected segment's glass. Default `var(--material-accent)`. */
|
|
33
33
|
tone?: string;
|
|
34
34
|
/** One row that scrolls sideways when it outgrows its container, instead of wrapping. */
|
|
35
35
|
scroll?: boolean;
|
|
@@ -109,8 +109,8 @@ const ToggleGroupItem: Component<
|
|
|
109
109
|
// its own neutral fill; hover still tints text only, since a fill there
|
|
110
110
|
// would read as a second, squarer selection.
|
|
111
111
|
context.sliding
|
|
112
|
-
? "hover:text-
|
|
113
|
-
: "
|
|
112
|
+
? "hover:text-(--material-accent)"
|
|
113
|
+
: "data-[pressed]:bg-muted data-[pressed]:text-foreground not-data-[pressed]:hover:text-(--material-accent)",
|
|
114
114
|
local.class,
|
|
115
115
|
)}
|
|
116
116
|
{...rest}
|
package/src/solid/toggle.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const Toggle: Component<
|
|
|
46
46
|
class={cn(
|
|
47
47
|
toggleVariants({ variant: local.variant, size: local.size }),
|
|
48
48
|
TOGGLE_HOVER[local.variant ?? "default"],
|
|
49
|
-
"data-[pressed]:glass data-[pressed]:[--glass-tone:var(--
|
|
49
|
+
"data-[pressed]:glass data-[pressed]:[--glass-tone:var(--material-accent)]",
|
|
50
50
|
local.class,
|
|
51
51
|
)}
|
|
52
52
|
{...rest}
|