@dotcraft/island 0.0.0-stage → 0.12.1
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/LICENSE +201 -0
- package/README.md +46 -2
- package/dist/EdgeGlow.d.ts +9 -0
- package/dist/EdgeGlow.d.ts.map +1 -0
- package/dist/EdgeGlow.js +36 -0
- package/dist/EdgeGlow.js.map +1 -0
- package/dist/Island.d.ts +11 -0
- package/dist/Island.d.ts.map +1 -0
- package/dist/Island.js +23 -0
- package/dist/Island.js.map +1 -0
- package/dist/card.d.ts +33 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +27 -0
- package/dist/card.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/parts.d.ts +31 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +21 -0
- package/dist/parts.js.map +1 -0
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +5 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.css +488 -0
- package/package.json +49 -4
- package/src/EdgeGlow.tsx +65 -0
- package/src/Island.tsx +47 -0
- package/src/card.tsx +88 -0
- package/src/glow.css +91 -0
- package/src/index.ts +39 -0
- package/src/island.css +398 -0
- package/src/parts.tsx +57 -0
- package/src/react.ts +21 -0
- package/src/styles.css +2 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
.dci-island {
|
|
2
|
+
--dci-text: #eeeeec;
|
|
3
|
+
--dci-text-secondary: #a4a4a3;
|
|
4
|
+
--dci-text-dimmed: #70706f;
|
|
5
|
+
--dci-hover: rgb(238 238 236 / 0.08);
|
|
6
|
+
--dci-active: #343434;
|
|
7
|
+
--dci-border: rgb(238 238 236 / 0.16);
|
|
8
|
+
--dci-accent: #4566cc;
|
|
9
|
+
--dci-accent-hover: #5976d0;
|
|
10
|
+
--dci-on-accent: #ffffff;
|
|
11
|
+
--dci-surface: rgb(36 36 36 / 0.92);
|
|
12
|
+
--dci-shadow: 0 12px 30px rgb(0 0 0 / 0.24), 0 1px 2px rgb(0 0 0 / 0.16);
|
|
13
|
+
--dci-rim-lit: rgb(255 255 255 / 0.38);
|
|
14
|
+
--dci-rim: rgb(255 255 255 / 0.08);
|
|
15
|
+
--dci-font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
|
|
16
|
+
--dci-font-mono: Consolas, "Cascadia Mono", monospace;
|
|
17
|
+
--dci-ease: cubic-bezier(0.4, 0, 0.2, 1);
|
|
18
|
+
--dci-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
19
|
+
--dci-morph: 420ms cubic-bezier(0.33, 0, 0.2, 1);
|
|
20
|
+
|
|
21
|
+
position: relative;
|
|
22
|
+
box-sizing: content-box;
|
|
23
|
+
max-width: min(100%, 540px);
|
|
24
|
+
height: 44px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
border-radius: 22px;
|
|
27
|
+
background: var(--dci-surface);
|
|
28
|
+
box-shadow: var(--dci-shadow);
|
|
29
|
+
color: var(--dci-text);
|
|
30
|
+
font-family: var(--dci-font-ui);
|
|
31
|
+
font-size: 13px;
|
|
32
|
+
line-height: 18px;
|
|
33
|
+
user-select: none;
|
|
34
|
+
-webkit-user-select: none;
|
|
35
|
+
interpolate-size: allow-keywords;
|
|
36
|
+
transition: width var(--dci-morph), height var(--dci-morph), opacity 120ms var(--dci-ease);
|
|
37
|
+
animation: dci-island-enter 280ms var(--dci-ease-out) both;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.dci-island[data-theme="light"] {
|
|
41
|
+
--dci-text: #1a1c1f;
|
|
42
|
+
--dci-text-secondary: #5d5e60;
|
|
43
|
+
--dci-text-dimmed: #8a8b8c;
|
|
44
|
+
--dci-hover: rgb(26 28 31 / 0.06);
|
|
45
|
+
--dci-active: #e8e8e8;
|
|
46
|
+
--dci-border: rgb(26 28 31 / 0.12);
|
|
47
|
+
--dci-accent: #4f6cce;
|
|
48
|
+
--dci-accent-hover: #4962b9;
|
|
49
|
+
--dci-surface: rgb(255 255 255 / 0.94);
|
|
50
|
+
--dci-shadow: 0 12px 30px rgb(0 0 0 / 0.14), 0 1px 2px rgb(0 0 0 / 0.08);
|
|
51
|
+
--dci-rim-lit: rgb(26 28 31 / 0.2);
|
|
52
|
+
--dci-rim: rgb(26 28 31 / 0.08);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.dci-island[data-card] {
|
|
56
|
+
width: 440px;
|
|
57
|
+
height: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dci-island[data-leaving] {
|
|
61
|
+
animation: dci-island-leave 180ms var(--dci-ease) both;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@keyframes dci-island-enter {
|
|
65
|
+
from { opacity: 0; translate: 0 -10px; scale: 0.96; }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes dci-island-leave {
|
|
69
|
+
to { opacity: 0; translate: 0 -8px; scale: 0.98; }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.dci-island[data-reduce-motion="on"] {
|
|
73
|
+
animation: none;
|
|
74
|
+
transition: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.dci-island::before {
|
|
78
|
+
position: absolute;
|
|
79
|
+
z-index: 1;
|
|
80
|
+
inset: 0;
|
|
81
|
+
padding: 1px;
|
|
82
|
+
border-radius: inherit;
|
|
83
|
+
background: conic-gradient(from 315deg, var(--dci-rim-lit), var(--dci-rim) 25%, var(--dci-rim) 75%, var(--dci-rim-lit));
|
|
84
|
+
content: "";
|
|
85
|
+
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.dci-island__content {
|
|
90
|
+
display: flex;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
width: max-content;
|
|
93
|
+
max-width: 540px;
|
|
94
|
+
height: 100%;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 2px;
|
|
97
|
+
padding: 0 6px 0 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.dci-island[data-card] .dci-island__content {
|
|
101
|
+
display: block;
|
|
102
|
+
width: 100%;
|
|
103
|
+
max-width: none;
|
|
104
|
+
height: auto;
|
|
105
|
+
padding: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.dci-island button {
|
|
109
|
+
font: inherit;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.dci-island button:focus-visible {
|
|
113
|
+
outline: 2px solid var(--dci-accent);
|
|
114
|
+
outline-offset: -2px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.dci-head {
|
|
118
|
+
display: flex;
|
|
119
|
+
min-width: 0;
|
|
120
|
+
height: 44px;
|
|
121
|
+
flex: 1 1 auto;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 8px;
|
|
124
|
+
padding: 0 10px 0 5px;
|
|
125
|
+
border: 0;
|
|
126
|
+
border-radius: 22px;
|
|
127
|
+
background: transparent;
|
|
128
|
+
color: inherit;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
text-align: left;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.dci-head:disabled {
|
|
134
|
+
color: inherit;
|
|
135
|
+
cursor: default;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.dci-island[data-card] .dci-head {
|
|
139
|
+
width: 100%;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.dci-body {
|
|
143
|
+
padding: 2px 12px 12px;
|
|
144
|
+
animation: dci-body-in 280ms var(--dci-ease-out) 60ms both;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.dci-body[data-leaving] {
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transition: opacity 180ms var(--dci-ease);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@keyframes dci-body-in {
|
|
153
|
+
from { opacity: 0; translate: 0 -4px; }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.dci-choices {
|
|
157
|
+
display: grid;
|
|
158
|
+
gap: 8px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.dci-choices__title {
|
|
162
|
+
margin: 0;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.dci-choices__detail {
|
|
167
|
+
display: flex;
|
|
168
|
+
min-width: 0;
|
|
169
|
+
align-items: center;
|
|
170
|
+
gap: 10px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.dci-choices__options {
|
|
174
|
+
display: grid;
|
|
175
|
+
gap: 6px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.dci-choices__options button {
|
|
179
|
+
display: grid;
|
|
180
|
+
gap: 2px;
|
|
181
|
+
padding: 8px 12px;
|
|
182
|
+
border: 1px solid var(--dci-border);
|
|
183
|
+
border-radius: 12px;
|
|
184
|
+
background: transparent;
|
|
185
|
+
color: var(--dci-text);
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
text-align: left;
|
|
188
|
+
transition: background-color 120ms var(--dci-ease);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.dci-choices__options button:hover {
|
|
192
|
+
background: var(--dci-hover);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.dci-choices__options button[data-primary] {
|
|
196
|
+
border-color: transparent;
|
|
197
|
+
background: var(--dci-accent);
|
|
198
|
+
color: var(--dci-on-accent);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.dci-choices__options button[data-primary]:hover {
|
|
202
|
+
background: var(--dci-accent-hover);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.dci-choices__options small {
|
|
206
|
+
color: inherit;
|
|
207
|
+
font-size: 12px;
|
|
208
|
+
opacity: 0.7;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.dci-robots {
|
|
212
|
+
display: flex;
|
|
213
|
+
flex: none;
|
|
214
|
+
align-items: center;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.dci-robot {
|
|
218
|
+
position: relative;
|
|
219
|
+
display: grid;
|
|
220
|
+
width: calc(var(--dci-robot) + 4px);
|
|
221
|
+
height: calc(var(--dci-robot) + 4px);
|
|
222
|
+
place-items: center;
|
|
223
|
+
line-height: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.dci-robot + .dci-robot {
|
|
227
|
+
margin-left: calc(var(--dci-robot) * -0.46);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.dci-robot[data-lead] {
|
|
231
|
+
z-index: 1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* The robot's face sits below the middle of its box, so beside a line it rises a tenth of its size. */
|
|
235
|
+
.dci-robot > * {
|
|
236
|
+
translate: 0 -10%;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.dci-live {
|
|
240
|
+
background: linear-gradient(90deg, var(--dci-text) 0%, var(--dci-text) 35%, var(--dci-text-dimmed) 50%, var(--dci-text) 65%, var(--dci-text) 100%) 0 0 / 300% 100%;
|
|
241
|
+
color: transparent;
|
|
242
|
+
background-clip: text;
|
|
243
|
+
-webkit-background-clip: text;
|
|
244
|
+
animation: dci-live 2.4s linear infinite;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@keyframes dci-live {
|
|
248
|
+
from { background-position: 100% 0; }
|
|
249
|
+
to { background-position: 0 0; }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.dci-detail {
|
|
253
|
+
display: flex;
|
|
254
|
+
min-width: 0;
|
|
255
|
+
flex: 1;
|
|
256
|
+
align-items: baseline;
|
|
257
|
+
gap: 6px;
|
|
258
|
+
overflow: hidden;
|
|
259
|
+
color: var(--dci-text-secondary);
|
|
260
|
+
font-family: var(--dci-font-mono);
|
|
261
|
+
font-size: 12px;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.dci-detail b {
|
|
265
|
+
flex: none;
|
|
266
|
+
color: var(--dci-text);
|
|
267
|
+
font-family: var(--dci-font-ui);
|
|
268
|
+
font-size: 11px;
|
|
269
|
+
font-weight: 500;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.dci-detail > span {
|
|
273
|
+
min-width: 0;
|
|
274
|
+
overflow: hidden;
|
|
275
|
+
text-overflow: ellipsis;
|
|
276
|
+
white-space: nowrap;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.dci-badge {
|
|
280
|
+
flex: none;
|
|
281
|
+
padding: 0 5px;
|
|
282
|
+
border-radius: 999px;
|
|
283
|
+
background: var(--dci-active);
|
|
284
|
+
color: var(--dci-text-secondary);
|
|
285
|
+
font-size: 11px;
|
|
286
|
+
line-height: 15px;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.dci-button {
|
|
290
|
+
display: inline-flex;
|
|
291
|
+
flex: none;
|
|
292
|
+
align-items: center;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
gap: 6px;
|
|
295
|
+
height: 28px;
|
|
296
|
+
padding: 0 8px;
|
|
297
|
+
border: 0;
|
|
298
|
+
border-radius: 8px;
|
|
299
|
+
background: transparent;
|
|
300
|
+
color: var(--dci-text-secondary);
|
|
301
|
+
font-size: 11px;
|
|
302
|
+
cursor: pointer;
|
|
303
|
+
transition: background-color 120ms var(--dci-ease), color 120ms var(--dci-ease);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.dci-button:hover:not(:disabled) {
|
|
307
|
+
background: var(--dci-active);
|
|
308
|
+
color: var(--dci-text);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.dci-button:disabled {
|
|
312
|
+
opacity: 0.4;
|
|
313
|
+
cursor: default;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.dci-button[data-variant="icon"] {
|
|
317
|
+
width: 32px;
|
|
318
|
+
height: 32px;
|
|
319
|
+
padding: 0;
|
|
320
|
+
border-radius: 999px;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.dci-button[data-variant="secondary"],
|
|
324
|
+
.dci-button[data-variant="primary"] {
|
|
325
|
+
padding: 0 12px;
|
|
326
|
+
font-size: 12px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.dci-button[data-variant="secondary"] {
|
|
330
|
+
border: 1px solid var(--dci-border);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.dci-button[data-variant="secondary"]:hover {
|
|
334
|
+
background: var(--dci-hover);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.dci-button[data-variant="primary"] {
|
|
338
|
+
background: var(--dci-accent);
|
|
339
|
+
color: var(--dci-on-accent);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.dci-button[data-variant="primary"]:hover {
|
|
343
|
+
background: var(--dci-accent-hover);
|
|
344
|
+
color: var(--dci-on-accent);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.dci-countdown {
|
|
348
|
+
position: relative;
|
|
349
|
+
display: flex;
|
|
350
|
+
flex: none;
|
|
351
|
+
width: 32px;
|
|
352
|
+
height: 32px;
|
|
353
|
+
align-items: center;
|
|
354
|
+
justify-content: center;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.dci-countdown svg {
|
|
358
|
+
position: absolute;
|
|
359
|
+
inset: 0;
|
|
360
|
+
width: 100%;
|
|
361
|
+
height: 100%;
|
|
362
|
+
rotate: -90deg;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.dci-countdown circle {
|
|
366
|
+
fill: none;
|
|
367
|
+
stroke-width: 1.5;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.dci-countdown__track {
|
|
371
|
+
stroke: var(--dci-border);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.dci-countdown__value {
|
|
375
|
+
stroke: var(--dci-accent);
|
|
376
|
+
stroke-linecap: round;
|
|
377
|
+
transition: stroke-dashoffset 1s linear;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.dci-countdown em {
|
|
381
|
+
color: var(--dci-text-secondary);
|
|
382
|
+
font-size: 9px;
|
|
383
|
+
font-style: normal;
|
|
384
|
+
font-variant-numeric: tabular-nums;
|
|
385
|
+
line-height: 1;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.dci-island[data-reduce-motion="on"] .dci-body,
|
|
389
|
+
.dci-island[data-reduce-motion="on"] .dci-live,
|
|
390
|
+
.dci-island[data-reduce-motion="on"] .dci-countdown__value {
|
|
391
|
+
animation: none;
|
|
392
|
+
transition: none;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.dci-island[data-reduce-motion="on"] .dci-live {
|
|
396
|
+
color: inherit;
|
|
397
|
+
background: none;
|
|
398
|
+
}.dci-glow {
|
|
399
|
+
--dci-glow-rim: rgb(123 149 255 / 0.6);
|
|
400
|
+
--dci-glow-haze: rgb(69 102 204 / 0.3);
|
|
401
|
+
--dci-glow-comet: rgb(150 174 255);
|
|
402
|
+
--dci-glow-source: rgb(143 165 255 / 0.4);
|
|
403
|
+
--dci-glow-depth: 30px;
|
|
404
|
+
--dci-glow-period: 5.6s;
|
|
405
|
+
|
|
406
|
+
position: absolute;
|
|
407
|
+
inset: 0;
|
|
408
|
+
overflow: hidden;
|
|
409
|
+
pointer-events: none;
|
|
410
|
+
contain: strict;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.dci-glow__rim {
|
|
414
|
+
position: absolute;
|
|
415
|
+
inset: 0;
|
|
416
|
+
box-shadow:
|
|
417
|
+
inset 0 0 0 1.5px var(--dci-glow-rim),
|
|
418
|
+
inset 0 0 var(--dci-glow-depth) var(--dci-glow-haze),
|
|
419
|
+
inset 0 0 calc(var(--dci-glow-depth) * 2.6) rgb(69 102 204 / 0.12);
|
|
420
|
+
animation: dci-glow-breathe 4.8s ease-in-out infinite;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.dci-glow__source {
|
|
424
|
+
position: absolute;
|
|
425
|
+
top: var(--dci-glow-y);
|
|
426
|
+
left: var(--dci-glow-x);
|
|
427
|
+
width: 440px;
|
|
428
|
+
height: 440px;
|
|
429
|
+
background: radial-gradient(closest-side, var(--dci-glow-source), rgb(69 102 204 / 0.14) 46%, transparent);
|
|
430
|
+
translate: -50% -50%;
|
|
431
|
+
animation: dci-glow-source var(--dci-glow-period) ease-out infinite;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.dci-glow__comets {
|
|
435
|
+
position: absolute;
|
|
436
|
+
inset: 0;
|
|
437
|
+
overflow: visible;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.dci-glow__comet {
|
|
441
|
+
opacity: 0;
|
|
442
|
+
animation: dci-glow-fade var(--dci-glow-period) linear infinite;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.dci-glow__comet path {
|
|
446
|
+
fill: none;
|
|
447
|
+
stroke: var(--dci-glow-comet);
|
|
448
|
+
stroke-linecap: round;
|
|
449
|
+
stroke-linejoin: round;
|
|
450
|
+
animation: dci-glow-forward var(--dci-glow-period) cubic-bezier(0.45, 0, 0.25, 1) infinite;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/* The back comet runs counterclockwise from the end of the clockwise path. */
|
|
454
|
+
.dci-glow__comet[data-direction="back"] path {
|
|
455
|
+
animation-name: dci-glow-back;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
@keyframes dci-glow-forward {
|
|
459
|
+
0% { stroke-dashoffset: var(--dci-glow-tail); }
|
|
460
|
+
72%, 100% { stroke-dashoffset: calc(var(--dci-glow-tail) - var(--dci-glow-meet)); }
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
@keyframes dci-glow-back {
|
|
464
|
+
0% { stroke-dashoffset: calc(-1 * var(--dci-glow-loop)); }
|
|
465
|
+
72%, 100% { stroke-dashoffset: calc(-1 * var(--dci-glow-meet)); }
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
@keyframes dci-glow-fade {
|
|
469
|
+
0% { opacity: 0; }
|
|
470
|
+
6%, 58% { opacity: 1; }
|
|
471
|
+
72%, 100% { opacity: 0; }
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
@keyframes dci-glow-source {
|
|
475
|
+
0% { opacity: 0.55; }
|
|
476
|
+
8% { opacity: 1; }
|
|
477
|
+
40%, 100% { opacity: 0.55; }
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
@keyframes dci-glow-breathe {
|
|
481
|
+
0%, 100% { opacity: 0.78; }
|
|
482
|
+
50% { opacity: 1; }
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.dci-glow[data-reduce-motion="on"] .dci-glow__rim,
|
|
486
|
+
.dci-glow[data-reduce-motion="on"] .dci-glow__source {
|
|
487
|
+
animation: none;
|
|
488
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcraft/island",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.12.1",
|
|
4
|
+
"description": "The DotCraft island and edge glow that show an Agent working on a machine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react.d.ts",
|
|
15
|
+
"import": "./dist/react.js"
|
|
16
|
+
},
|
|
17
|
+
"./styles.css": "./dist/styles.css"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node ../../scripts/clean-dist.mjs . && tsc -p tsconfig.json && node scripts/copy-styles.mjs",
|
|
28
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
29
|
+
"test": "npm run build && node --test tests/*.test.mjs"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@dotcraft/avatar": ">=0.12.1",
|
|
33
|
+
"react": "^19.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"react": "^19.0.0",
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
38
|
+
"@types/react": "^19.0.0",
|
|
39
|
+
"typescript": "^5.7.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/DotHarness/dotcraft.git",
|
|
48
|
+
"directory": "sdk/typescript/packages/island"
|
|
49
|
+
},
|
|
50
|
+
"license": "Apache-2.0"
|
|
51
|
+
}
|
package/src/EdgeGlow.tsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState, type CSSProperties } from 'react'
|
|
2
|
+
import { glowGeometry, type GlowPoint } from './index.js'
|
|
3
|
+
|
|
4
|
+
export interface EdgeGlowProps {
|
|
5
|
+
/** The island's centre in this surface's pixels. */
|
|
6
|
+
origin?: GlowPoint | null
|
|
7
|
+
reduceMotion?: boolean
|
|
8
|
+
className?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Each comet is drawn as strokes of falling length sharing one head, which reads as a fading tail. */
|
|
12
|
+
const TAIL = [
|
|
13
|
+
{ length: 360, width: 20, opacity: 0.06 },
|
|
14
|
+
{ length: 260, width: 13, opacity: 0.1 },
|
|
15
|
+
{ length: 180, width: 8, opacity: 0.18 },
|
|
16
|
+
{ length: 110, width: 4, opacity: 0.4 },
|
|
17
|
+
{ length: 48, width: 2, opacity: 1 },
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
export function EdgeGlow({ origin = null, reduceMotion = false, className }: EdgeGlowProps) {
|
|
21
|
+
const element = useRef<HTMLDivElement | null>(null)
|
|
22
|
+
const [size, setSize] = useState({ width: 0, height: 0 })
|
|
23
|
+
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
const node = element.current
|
|
26
|
+
if (!node) return undefined
|
|
27
|
+
const measure = () => setSize({ width: node.clientWidth, height: node.clientHeight })
|
|
28
|
+
measure()
|
|
29
|
+
const observer = new ResizeObserver(measure)
|
|
30
|
+
observer.observe(node)
|
|
31
|
+
return () => observer.disconnect()
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
const { width, height } = size
|
|
35
|
+
const { edge, path, meetAt } = glowGeometry(width, height, origin)
|
|
36
|
+
const loop = 2 * (Math.max(0, width - 2) + Math.max(0, height - 2))
|
|
37
|
+
const style = {
|
|
38
|
+
'--dci-glow-x': `${edge.x}px`,
|
|
39
|
+
'--dci-glow-y': `${edge.y}px`,
|
|
40
|
+
'--dci-glow-loop': `${loop}px`,
|
|
41
|
+
'--dci-glow-meet': `${loop * meetAt}px`,
|
|
42
|
+
} as CSSProperties
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div ref={element} className={className ? `dci-glow ${className}` : 'dci-glow'} data-reduce-motion={reduceMotion ? 'on' : 'off'} style={style} aria-hidden="true">
|
|
46
|
+
<div className="dci-glow__rim" />
|
|
47
|
+
<div className="dci-glow__source" />
|
|
48
|
+
{!reduceMotion && width > 0 && (
|
|
49
|
+
<svg className="dci-glow__comets" width={width} height={height} viewBox={`0 0 ${width} ${height}`}>
|
|
50
|
+
{(['forward', 'back'] as const).map((direction) => (
|
|
51
|
+
<g key={direction} className="dci-glow__comet" data-direction={direction}>
|
|
52
|
+
{TAIL.map((stroke) => (
|
|
53
|
+
<path
|
|
54
|
+
key={stroke.length}
|
|
55
|
+
d={path}
|
|
56
|
+
style={{ '--dci-glow-tail': `${stroke.length}px`, strokeWidth: stroke.width, strokeOpacity: stroke.opacity, strokeDasharray: `${stroke.length}px ${loop}px` } as CSSProperties}
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
</g>
|
|
60
|
+
))}
|
|
61
|
+
</svg>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
package/src/Island.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState, type HTMLAttributes, type Ref } from 'react'
|
|
2
|
+
import type { IslandTheme } from './index.js'
|
|
3
|
+
|
|
4
|
+
export interface IslandProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
theme?: IslandTheme
|
|
6
|
+
reduceMotion?: boolean
|
|
7
|
+
card?: boolean
|
|
8
|
+
leaving?: boolean
|
|
9
|
+
ref?: Ref<HTMLDivElement>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Island({ theme = 'dark', reduceMotion = false, card = false, leaving = false, className, ref, onPointerEnter, onPointerLeave, children, ...rest }: IslandProps) {
|
|
13
|
+
const content = useRef<HTMLDivElement | null>(null)
|
|
14
|
+
const [width, setWidth] = useState<number | null>(null)
|
|
15
|
+
const [hovered, setHovered] = useState(false)
|
|
16
|
+
|
|
17
|
+
// Under the pointer the island only grows, so a control never moves out from under it.
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
const node = content.current
|
|
20
|
+
if (!node || card) return undefined
|
|
21
|
+
const measure = () => {
|
|
22
|
+
const next = node.offsetWidth
|
|
23
|
+
setWidth((value) => (hovered && value !== null ? Math.max(value, next) : next))
|
|
24
|
+
}
|
|
25
|
+
measure()
|
|
26
|
+
const observer = new ResizeObserver(measure)
|
|
27
|
+
observer.observe(node)
|
|
28
|
+
return () => observer.disconnect()
|
|
29
|
+
}, [card, hovered])
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
{...rest}
|
|
34
|
+
ref={ref}
|
|
35
|
+
className={className ? `dci-island ${className}` : 'dci-island'}
|
|
36
|
+
data-theme={theme}
|
|
37
|
+
data-reduce-motion={reduceMotion ? 'on' : 'off'}
|
|
38
|
+
data-card={card || undefined}
|
|
39
|
+
data-leaving={leaving || undefined}
|
|
40
|
+
style={card || width === null ? rest.style : { ...rest.style, width }}
|
|
41
|
+
onPointerEnter={(event) => { setHovered(true); onPointerEnter?.(event) }}
|
|
42
|
+
onPointerLeave={(event) => { setHovered(false); onPointerLeave?.(event) }}
|
|
43
|
+
>
|
|
44
|
+
<div ref={content} className="dci-island__content">{children}</div>
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|