@opencode/ui 0.0.0-dev-569 → 0.0.0-dev-572
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/dist/components/spinner.d.ts +11 -3
- package/dist/feedback/activity-ring/activity-ring.d.ts +2 -1
- package/package.json +2 -2
- package/src/components/spinner.css +18 -5
- package/src/components/spinner.tsx +28 -14
- package/src/feedback/activity-ring/activity-ring.tsx +1 -1
- package/src/typography/text-shimmer/text-shimmer.css +71 -39
- package/src/typography/text-shimmer/text-shimmer.tsx +3 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { type ComponentProps } from "solid-js";
|
|
2
|
-
|
|
1
|
+
import { type ComponentProps, type JSX } from "solid-js";
|
|
2
|
+
/**
|
|
3
|
+
* Each dot is its own SVG over the whole box, drawn exactly where it sat in one SVG. The compositor runs the opacity
|
|
4
|
+
* animation of an SVG element but not of a shape inside one, so a spinner no longer restyles and repaints on every
|
|
5
|
+
* frame. `width` and `height` size it like an SVG's attributes, below any CSS size.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Spinner(props: Omit<ComponentProps<"span">, "style"> & {
|
|
3
8
|
"data-component"?: string;
|
|
4
|
-
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
style?: JSX.CSSProperties;
|
|
12
|
+
}): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type ComponentProps } from "solid-js";
|
|
2
|
+
import { Spinner } from "../../components/spinner";
|
|
2
3
|
import "./activity-ring.css";
|
|
3
|
-
export declare function ActivityRing(props: ComponentProps<
|
|
4
|
+
export declare function ActivityRing(props: ComponentProps<typeof Spinner>): import("solid-js").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencode/ui",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-572",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
"dependencies": {
|
|
289
289
|
"@kitlangton/solid-motion": "0.2.2",
|
|
290
290
|
"@kobalte/core": "0.13.13",
|
|
291
|
-
"@opencode/util": "0.0.0-dev-
|
|
291
|
+
"@opencode/util": "0.0.0-dev-572",
|
|
292
292
|
"@pierre/diffs": "1.6.1",
|
|
293
293
|
"@pierre/highlights": "0.2.0",
|
|
294
294
|
"@solid-primitives/event-listener": "2.4.6",
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
/* `width` and `height` props arrive as variables, so classes and other CSS still size the spinner over them, as they
|
|
2
|
+
did over an SVG's attributes. */
|
|
3
|
+
[data-slot="spinner-dots"] {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
width: var(--spinner-width, 18px);
|
|
7
|
+
height: var(--spinner-height, auto);
|
|
8
|
+
aspect-ratio: 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
[data-component="spinner"] {
|
|
2
12
|
color: inherit;
|
|
3
13
|
flex-shrink: 0;
|
|
4
|
-
width: 18px;
|
|
5
|
-
aspect-ratio: 1;
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
/* Each dot rests at its frozen pose, so reduced motion only has to stop the animation. */
|
|
9
|
-
[data-slot="spinner-dots"]
|
|
17
|
+
[data-slot="spinner-dots"] > svg {
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
overflow: visible;
|
|
10
23
|
opacity: var(--still);
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
/* syncSpinPhase marks spinners out of view; `!important` beats the inline animation each dot carries. */
|
|
14
|
-
[data-slot="spinner-dots"][data-offscreen]
|
|
27
|
+
[data-slot="spinner-dots"][data-offscreen] > svg {
|
|
15
28
|
animation-play-state: paused !important;
|
|
16
29
|
}
|
|
17
30
|
|
|
18
|
-
:root[data-motion="reduce"] [data-slot="spinner-dots"]
|
|
31
|
+
:root[data-motion="reduce"] [data-slot="spinner-dots"] > svg {
|
|
19
32
|
/* Beats the inline animation each dot carries. */
|
|
20
33
|
animation: none !important;
|
|
21
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { For, splitProps, type ComponentProps } from "solid-js"
|
|
1
|
+
import { For, splitProps, type ComponentProps, type JSX } from "solid-js"
|
|
2
2
|
import { syncSpinPhase } from "../hooks/spin-phase"
|
|
3
3
|
import { radarDots, radarKeyframes, radarLoop } from "./spinner-radar"
|
|
4
4
|
|
|
@@ -12,8 +12,20 @@ const dots = radarDots()
|
|
|
12
12
|
// The keyframes are added to the document once, the first time a spinner renders.
|
|
13
13
|
let added = false
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Each dot is its own SVG over the whole box, drawn exactly where it sat in one SVG. The compositor runs the opacity
|
|
17
|
+
* animation of an SVG element but not of a shape inside one, so a spinner no longer restyles and repaints on every
|
|
18
|
+
* frame. `width` and `height` size it like an SVG's attributes, below any CSS size.
|
|
19
|
+
*/
|
|
20
|
+
export function Spinner(
|
|
21
|
+
props: Omit<ComponentProps<"span">, "style"> & {
|
|
22
|
+
"data-component"?: string
|
|
23
|
+
width?: number
|
|
24
|
+
height?: number
|
|
25
|
+
style?: JSX.CSSProperties
|
|
26
|
+
},
|
|
27
|
+
) {
|
|
28
|
+
const [local, rest] = splitProps(props, ["class", "classList", "data-component", "width", "height", "style"])
|
|
17
29
|
|
|
18
30
|
if (!added) {
|
|
19
31
|
added = true
|
|
@@ -23,32 +35,34 @@ export function Spinner(props: ComponentProps<"svg"> & { "data-component"?: stri
|
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
return (
|
|
26
|
-
<
|
|
38
|
+
<span
|
|
27
39
|
{...rest}
|
|
28
40
|
ref={syncSpinPhase}
|
|
29
|
-
viewBox="0 0 16 16"
|
|
30
41
|
data-component={local["data-component"] ?? "spinner"}
|
|
31
42
|
data-slot="spinner-dots"
|
|
32
43
|
classList={{ ...local.classList, [local.class ?? ""]: !!local.class }}
|
|
33
|
-
|
|
44
|
+
style={{
|
|
45
|
+
...local.style,
|
|
46
|
+
"--spinner-width": local.width === undefined ? undefined : `${local.width}px`,
|
|
47
|
+
"--spinner-height": local.height === undefined ? undefined : `${local.height}px`,
|
|
48
|
+
}}
|
|
34
49
|
>
|
|
35
50
|
<For each={dots}>
|
|
36
51
|
{(dot) => (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
width={dot.size}
|
|
41
|
-
height={dot.size}
|
|
42
|
-
rx={dot.size * 0.24}
|
|
52
|
+
<svg
|
|
53
|
+
viewBox="0 0 16 16"
|
|
54
|
+
fill="currentColor"
|
|
43
55
|
style={{
|
|
44
56
|
"--still": dot.still,
|
|
45
57
|
animation: dot.steady
|
|
46
58
|
? undefined
|
|
47
59
|
: `${keyframes}-${dot.shape} calc(${radarLoop}s * var(--spinner-time, 1)) linear calc(${-radarLoop * (1 - dot.at)}s * var(--spinner-time, 1)) infinite`,
|
|
48
60
|
}}
|
|
49
|
-
|
|
61
|
+
>
|
|
62
|
+
<rect x={dot.x} y={dot.y} width={dot.size} height={dot.size} rx={dot.size * 0.24} />
|
|
63
|
+
</svg>
|
|
50
64
|
)}
|
|
51
65
|
</For>
|
|
52
|
-
</
|
|
66
|
+
</span>
|
|
53
67
|
)
|
|
54
68
|
}
|
|
@@ -2,7 +2,7 @@ import { type ComponentProps } from "solid-js"
|
|
|
2
2
|
import { Spinner } from "../../components/spinner"
|
|
3
3
|
import "./activity-ring.css"
|
|
4
4
|
|
|
5
|
-
export function ActivityRing(props: ComponentProps<
|
|
5
|
+
export function ActivityRing(props: ComponentProps<typeof Spinner>) {
|
|
6
6
|
return (
|
|
7
7
|
<Spinner
|
|
8
8
|
{...props}
|
|
@@ -3,19 +3,10 @@
|
|
|
3
3
|
--text-shimmer-duration: 1200ms;
|
|
4
4
|
--text-shimmer-swap: 220ms;
|
|
5
5
|
--text-shimmer-index: 0;
|
|
6
|
-
--text-shimmer-angle: 90deg;
|
|
7
6
|
--text-shimmer-spread: 5.2ch;
|
|
8
7
|
--text-shimmer-gutter: calc(var(--text-shimmer-spread) + 1ch);
|
|
9
|
-
--text-shimmer-size: calc(200% + var(--text-shimmer-gutter) + var(--text-shimmer-gutter));
|
|
10
8
|
--text-shimmer-base-color: var(--text-weak);
|
|
11
9
|
--text-shimmer-peak-color: var(--text-strong);
|
|
12
|
-
--text-shimmer-sweep: linear-gradient(
|
|
13
|
-
var(--text-shimmer-angle),
|
|
14
|
-
transparent calc(50% - var(--text-shimmer-spread)),
|
|
15
|
-
var(--text-shimmer-peak-color) 50%,
|
|
16
|
-
transparent calc(50% + var(--text-shimmer-spread))
|
|
17
|
-
);
|
|
18
|
-
--text-shimmer-base: linear-gradient(var(--text-shimmer-base-color), var(--text-shimmer-base-color));
|
|
19
10
|
|
|
20
11
|
display: inline-flex;
|
|
21
12
|
align-items: baseline;
|
|
@@ -47,8 +38,11 @@
|
|
|
47
38
|
opacity: 1;
|
|
48
39
|
}
|
|
49
40
|
|
|
41
|
+
/* Clipped to its box, where the old background sweep painted, so the sweep's travel never adds overflow. */
|
|
50
42
|
[data-component="text-shimmer"] [data-slot="text-shimmer-char-shimmer"] {
|
|
51
|
-
|
|
43
|
+
position: relative;
|
|
44
|
+
overflow: clip;
|
|
45
|
+
color: var(--text-shimmer-base-color);
|
|
52
46
|
opacity: 0;
|
|
53
47
|
}
|
|
54
48
|
|
|
@@ -56,48 +50,85 @@
|
|
|
56
50
|
opacity: 1;
|
|
57
51
|
}
|
|
58
52
|
|
|
59
|
-
[data-component="text-shimmer"] [data-slot="text-shimmer-char-
|
|
60
|
-
|
|
53
|
+
[data-component="text-shimmer"][data-active="true"] [data-slot="text-shimmer-char-base"] {
|
|
54
|
+
opacity: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* The sweep is the text again in the peak colour, seen through a soft window that crosses it. The window and the text
|
|
58
|
+
inside it move in opposite directions by the same amount, so the text stays put while the window travels: both are
|
|
59
|
+
transforms, which the compositor runs, where an animated background position restyled and repainted the text on
|
|
60
|
+
every frame. The window's centre runs from one gutter before the text to one gutter past it. */
|
|
61
|
+
[data-component="text-shimmer"] [data-slot="text-shimmer-sweep"] {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
bottom: 0;
|
|
65
|
+
left: calc(-1 * var(--text-shimmer-spread));
|
|
66
|
+
right: calc(-1 * var(--text-shimmer-spread));
|
|
67
|
+
display: none;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
user-select: none;
|
|
70
|
+
mask-image: linear-gradient(
|
|
71
|
+
90deg,
|
|
72
|
+
transparent calc(50% - var(--text-shimmer-spread)),
|
|
73
|
+
#000 50%,
|
|
74
|
+
transparent calc(50% + var(--text-shimmer-spread))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-component="text-shimmer"] [data-slot="text-shimmer-sweep-text"] {
|
|
79
|
+
display: block;
|
|
80
|
+
margin-left: var(--text-shimmer-spread);
|
|
81
|
+
margin-right: var(--text-shimmer-spread);
|
|
82
|
+
white-space: pre;
|
|
83
|
+
color: var(--text-shimmer-peak-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[data-component="text-shimmer"]
|
|
87
|
+
[data-slot="text-shimmer-char-shimmer"][data-run="true"]
|
|
88
|
+
> [data-slot="text-shimmer-sweep"] {
|
|
89
|
+
display: block;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
[data-component="text-shimmer"]
|
|
93
|
+
[data-slot="text-shimmer-char-shimmer"][data-run="true"]
|
|
94
|
+
:is([data-slot="text-shimmer-sweep"], [data-slot="text-shimmer-sweep-text"]) {
|
|
61
95
|
animation-duration: var(--text-shimmer-duration);
|
|
62
96
|
animation-iteration-count: infinite;
|
|
63
97
|
animation-timing-function: linear;
|
|
64
98
|
animation-fill-mode: both;
|
|
65
99
|
animation-delay: calc(var(--text-shimmer-step) * var(--text-shimmer-index) * -1);
|
|
66
|
-
will-change: background-position;
|
|
67
100
|
}
|
|
68
101
|
|
|
69
|
-
|
|
102
|
+
[data-component="text-shimmer"]
|
|
103
|
+
[data-slot="text-shimmer-char-shimmer"][data-run="true"]
|
|
104
|
+
[data-slot="text-shimmer-sweep"] {
|
|
105
|
+
animation-name: text-shimmer-window;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-component="text-shimmer"]
|
|
109
|
+
[data-slot="text-shimmer-char-shimmer"][data-run="true"]
|
|
110
|
+
[data-slot="text-shimmer-sweep-text"] {
|
|
111
|
+
animation-name: text-shimmer-text;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* The window is one spread wider than the text on each side, so its percentages carry the spread back out. */
|
|
115
|
+
@keyframes text-shimmer-window {
|
|
70
116
|
0% {
|
|
71
|
-
|
|
72
|
-
100% 0,
|
|
73
|
-
0 0;
|
|
117
|
+
translate: calc(-50% + var(--text-shimmer-spread) - var(--text-shimmer-gutter)) 0;
|
|
74
118
|
}
|
|
75
119
|
|
|
76
120
|
100% {
|
|
77
|
-
|
|
78
|
-
0% 0,
|
|
79
|
-
0 0;
|
|
121
|
+
translate: calc(50% - var(--text-shimmer-spread) + var(--text-shimmer-gutter)) 0;
|
|
80
122
|
}
|
|
81
123
|
}
|
|
82
124
|
|
|
83
|
-
@
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-webkit-text-fill-color: transparent;
|
|
87
|
-
background-image: var(--text-shimmer-sweep), var(--text-shimmer-base);
|
|
88
|
-
background-size:
|
|
89
|
-
var(--text-shimmer-size) 100%,
|
|
90
|
-
100% 100%;
|
|
91
|
-
background-position:
|
|
92
|
-
100% 0,
|
|
93
|
-
0 0;
|
|
94
|
-
background-repeat: no-repeat;
|
|
95
|
-
-webkit-background-clip: text;
|
|
96
|
-
background-clip: text;
|
|
125
|
+
@keyframes text-shimmer-text {
|
|
126
|
+
0% {
|
|
127
|
+
translate: calc(50% + var(--text-shimmer-gutter)) 0;
|
|
97
128
|
}
|
|
98
129
|
|
|
99
|
-
|
|
100
|
-
|
|
130
|
+
100% {
|
|
131
|
+
translate: calc(-50% - var(--text-shimmer-gutter)) 0;
|
|
101
132
|
}
|
|
102
133
|
}
|
|
103
134
|
|
|
@@ -108,10 +139,11 @@
|
|
|
108
139
|
}
|
|
109
140
|
|
|
110
141
|
[data-component="text-shimmer"] [data-slot="text-shimmer-char-shimmer"] {
|
|
111
|
-
animation: none !important;
|
|
112
142
|
color: inherit;
|
|
113
|
-
|
|
114
|
-
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
[data-component="text-shimmer"] [data-slot="text-shimmer-sweep"] {
|
|
146
|
+
display: none !important;
|
|
115
147
|
}
|
|
116
148
|
|
|
117
149
|
[data-component="text-shimmer"] [data-slot="text-shimmer-char-base"] {
|
|
@@ -57,6 +57,9 @@ export const TextShimmer = <T extends ValidComponent = "span">(props: {
|
|
|
57
57
|
</span>
|
|
58
58
|
<span data-slot="text-shimmer-char-shimmer" data-run={run() ? "true" : "false"} aria-hidden="true">
|
|
59
59
|
{text()}
|
|
60
|
+
<span data-slot="text-shimmer-sweep">
|
|
61
|
+
<span data-slot="text-shimmer-sweep-text">{text()}</span>
|
|
62
|
+
</span>
|
|
60
63
|
</span>
|
|
61
64
|
</span>
|
|
62
65
|
</Dynamic>
|