@dotcraft/island 0.0.0-stage → 0.13.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/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/src/card.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useEffect, useState, type ReactNode, type Ref } from 'react'
|
|
2
|
+
|
|
3
|
+
const MORPH_MS = 420
|
|
4
|
+
|
|
5
|
+
export interface IslandHeadProps {
|
|
6
|
+
open: boolean
|
|
7
|
+
onToggle: () => void
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
expandLabel: string
|
|
10
|
+
collapseLabel: string
|
|
11
|
+
children: ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function IslandHead({ open, onToggle, disabled = false, expandLabel, collapseLabel, children }: IslandHeadProps) {
|
|
15
|
+
return (
|
|
16
|
+
<button
|
|
17
|
+
className="dci-head"
|
|
18
|
+
type="button"
|
|
19
|
+
disabled={disabled}
|
|
20
|
+
aria-expanded={disabled ? undefined : open}
|
|
21
|
+
aria-label={disabled ? undefined : open ? collapseLabel : expandLabel}
|
|
22
|
+
onClick={onToggle}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</button>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IslandBodyContent {
|
|
30
|
+
key: string
|
|
31
|
+
node: ReactNode
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A closing body stays until the island has shrunk, so its height never snaps. */
|
|
35
|
+
export function IslandBody({ body }: { body: IslandBodyContent | null }) {
|
|
36
|
+
const [held, setHeld] = useState(body)
|
|
37
|
+
const key = body?.key
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (body) { setHeld(body); return undefined }
|
|
40
|
+
const timer = setTimeout(() => setHeld(null), MORPH_MS)
|
|
41
|
+
return () => clearTimeout(timer)
|
|
42
|
+
}, [key])
|
|
43
|
+
const shown = body ?? held
|
|
44
|
+
if (!shown) return null
|
|
45
|
+
return (
|
|
46
|
+
<div className="dci-body" key={shown.key} data-leaving={body ? undefined : ''} inert={!body}>
|
|
47
|
+
{shown.node}
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IslandChoice {
|
|
53
|
+
id: string
|
|
54
|
+
label: string
|
|
55
|
+
description?: string
|
|
56
|
+
primary?: boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IslandChoicesProps {
|
|
60
|
+
title: string
|
|
61
|
+
detail?: ReactNode
|
|
62
|
+
choices: IslandChoice[]
|
|
63
|
+
onChoose: (id: string) => void
|
|
64
|
+
firstRef?: Ref<HTMLButtonElement>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function IslandChoices({ title, detail, choices, onChoose, firstRef }: IslandChoicesProps) {
|
|
68
|
+
return (
|
|
69
|
+
<div className="dci-choices">
|
|
70
|
+
<p className="dci-choices__title">{title}</p>
|
|
71
|
+
{detail && <div className="dci-choices__detail">{detail}</div>}
|
|
72
|
+
<div className="dci-choices__options" role="group" aria-label={title}>
|
|
73
|
+
{choices.map((choice, index) => (
|
|
74
|
+
<button
|
|
75
|
+
key={choice.id}
|
|
76
|
+
ref={index === 0 ? firstRef : undefined}
|
|
77
|
+
type="button"
|
|
78
|
+
data-primary={choice.primary || undefined}
|
|
79
|
+
onClick={() => onChoose(choice.id)}
|
|
80
|
+
>
|
|
81
|
+
<span>{choice.label}</span>
|
|
82
|
+
{choice.description && <small>{choice.description}</small>}
|
|
83
|
+
</button>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
package/src/glow.css
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
.dci-glow {
|
|
2
|
+
--dci-glow-rim: rgb(123 149 255 / 0.6);
|
|
3
|
+
--dci-glow-haze: rgb(69 102 204 / 0.3);
|
|
4
|
+
--dci-glow-comet: rgb(150 174 255);
|
|
5
|
+
--dci-glow-source: rgb(143 165 255 / 0.4);
|
|
6
|
+
--dci-glow-depth: 30px;
|
|
7
|
+
--dci-glow-period: 5.6s;
|
|
8
|
+
|
|
9
|
+
position: absolute;
|
|
10
|
+
inset: 0;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
contain: strict;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.dci-glow__rim {
|
|
17
|
+
position: absolute;
|
|
18
|
+
inset: 0;
|
|
19
|
+
box-shadow:
|
|
20
|
+
inset 0 0 0 1.5px var(--dci-glow-rim),
|
|
21
|
+
inset 0 0 var(--dci-glow-depth) var(--dci-glow-haze),
|
|
22
|
+
inset 0 0 calc(var(--dci-glow-depth) * 2.6) rgb(69 102 204 / 0.12);
|
|
23
|
+
animation: dci-glow-breathe 4.8s ease-in-out infinite;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dci-glow__source {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: var(--dci-glow-y);
|
|
29
|
+
left: var(--dci-glow-x);
|
|
30
|
+
width: 440px;
|
|
31
|
+
height: 440px;
|
|
32
|
+
background: radial-gradient(closest-side, var(--dci-glow-source), rgb(69 102 204 / 0.14) 46%, transparent);
|
|
33
|
+
translate: -50% -50%;
|
|
34
|
+
animation: dci-glow-source var(--dci-glow-period) ease-out infinite;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dci-glow__comets {
|
|
38
|
+
position: absolute;
|
|
39
|
+
inset: 0;
|
|
40
|
+
overflow: visible;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dci-glow__comet {
|
|
44
|
+
opacity: 0;
|
|
45
|
+
animation: dci-glow-fade var(--dci-glow-period) linear infinite;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dci-glow__comet path {
|
|
49
|
+
fill: none;
|
|
50
|
+
stroke: var(--dci-glow-comet);
|
|
51
|
+
stroke-linecap: round;
|
|
52
|
+
stroke-linejoin: round;
|
|
53
|
+
animation: dci-glow-forward var(--dci-glow-period) cubic-bezier(0.45, 0, 0.25, 1) infinite;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* The back comet runs counterclockwise from the end of the clockwise path. */
|
|
57
|
+
.dci-glow__comet[data-direction="back"] path {
|
|
58
|
+
animation-name: dci-glow-back;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes dci-glow-forward {
|
|
62
|
+
0% { stroke-dashoffset: var(--dci-glow-tail); }
|
|
63
|
+
72%, 100% { stroke-dashoffset: calc(var(--dci-glow-tail) - var(--dci-glow-meet)); }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@keyframes dci-glow-back {
|
|
67
|
+
0% { stroke-dashoffset: calc(-1 * var(--dci-glow-loop)); }
|
|
68
|
+
72%, 100% { stroke-dashoffset: calc(-1 * var(--dci-glow-meet)); }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes dci-glow-fade {
|
|
72
|
+
0% { opacity: 0; }
|
|
73
|
+
6%, 58% { opacity: 1; }
|
|
74
|
+
72%, 100% { opacity: 0; }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@keyframes dci-glow-source {
|
|
78
|
+
0% { opacity: 0.55; }
|
|
79
|
+
8% { opacity: 1; }
|
|
80
|
+
40%, 100% { opacity: 0.55; }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@keyframes dci-glow-breathe {
|
|
84
|
+
0%, 100% { opacity: 0.78; }
|
|
85
|
+
50% { opacity: 1; }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dci-glow[data-reduce-motion="on"] .dci-glow__rim,
|
|
89
|
+
.dci-glow[data-reduce-motion="on"] .dci-glow__source {
|
|
90
|
+
animation: none;
|
|
91
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type IslandTheme = 'dark' | 'light'
|
|
2
|
+
|
|
3
|
+
export interface GlowPoint {
|
|
4
|
+
x: number
|
|
5
|
+
y: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface GlowGeometry {
|
|
9
|
+
edge: GlowPoint
|
|
10
|
+
/** A closed clockwise path around the surface, `inset` from its edge, starting at `edge`. */
|
|
11
|
+
path: string
|
|
12
|
+
/** How far clockwise along `path` the comets meet, straight across from `edge`, as a share of its length. */
|
|
13
|
+
meetAt: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Without an origin the light starts at the top centre. */
|
|
17
|
+
export function glowGeometry(width: number, height: number, origin?: GlowPoint | null, inset = 1): GlowGeometry {
|
|
18
|
+
const w = Math.max(0, width - 2 * inset)
|
|
19
|
+
const h = Math.max(0, height - 2 * inset)
|
|
20
|
+
const x = Math.min(w, Math.max(0, (origin?.x ?? width / 2) - inset))
|
|
21
|
+
const y = Math.min(h, Math.max(0, (origin?.y ?? 0) - inset))
|
|
22
|
+
const distances = origin ? [y, w - x, h - y, x] : [0, 1, 1, 1]
|
|
23
|
+
const side = distances.indexOf(Math.min(...distances))
|
|
24
|
+
const edge = [{ x, y: 0 }, { x: w, y }, { x, y: h }, { x: 0, y }][side]!
|
|
25
|
+
const meet = [{ x, y: h }, { x: 0, y }, { x, y: 0 }, { x: w, y }][side]!
|
|
26
|
+
const perimeter = 2 * (w + h)
|
|
27
|
+
const along = (point: GlowPoint) =>
|
|
28
|
+
point.y === 0 ? point.x : point.x === w ? w + point.y : point.y === h ? w + h + (w - point.x) : 2 * w + h + (h - point.y)
|
|
29
|
+
const start = along(edge)
|
|
30
|
+
const corners = [{ x: w, y: 0 }, { x: w, y: h }, { x: 0, y: h }, { x: 0, y: 0 }]
|
|
31
|
+
.map((corner) => ({ corner, at: (along(corner) - start + perimeter) % perimeter || perimeter }))
|
|
32
|
+
.sort((a, b) => a.at - b.at)
|
|
33
|
+
const point = (p: GlowPoint) => `${round(p.x + inset)} ${round(p.y + inset)}`
|
|
34
|
+
const path = `M${point(edge)}${corners.map(({ corner }) => `L${point(corner)}`).join('')}Z`
|
|
35
|
+
const meetAt = ((along(meet) - start + perimeter) % perimeter) / perimeter
|
|
36
|
+
return { edge: { x: edge.x + inset, y: edge.y + inset }, path, meetAt }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const round = (value: number) => Math.round(value * 100) / 100
|
package/src/island.css
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
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
|
+
}
|
package/src/parts.tsx
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react'
|
|
2
|
+
import type { AvatarPose } from '@dotcraft/avatar'
|
|
3
|
+
import { Avatar } from '@dotcraft/avatar/react'
|
|
4
|
+
|
|
5
|
+
export interface IslandRobot {
|
|
6
|
+
id: string
|
|
7
|
+
name: string
|
|
8
|
+
pose: AvatarPose
|
|
9
|
+
lead?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function IslandRobots({ robots, size = 30, animate = true }: { robots: IslandRobot[]; size?: number; animate?: boolean }) {
|
|
13
|
+
const ordered = [...robots].sort((a, b) => Number(Boolean(b.lead)) - Number(Boolean(a.lead)))
|
|
14
|
+
return (
|
|
15
|
+
<span className="dci-robots" aria-hidden="true" style={{ ['--dci-robot' as string]: `${size}px` }}>
|
|
16
|
+
{ordered.map((robot) => (
|
|
17
|
+
<span className="dci-robot" key={robot.id} data-lead={robot.lead || undefined}>
|
|
18
|
+
<Avatar name={robot.name} size={size} state={robot.pose} motion={animate ? 'on' : 'off'} />
|
|
19
|
+
</span>
|
|
20
|
+
))}
|
|
21
|
+
</span>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function IslandDetail({ children, title, lead }: { children: string; title?: string; lead?: string }) {
|
|
26
|
+
return (
|
|
27
|
+
<span className="dci-detail" title={title ?? children}>
|
|
28
|
+
{lead && <b>{lead}</b>}
|
|
29
|
+
<span>{children}</span>
|
|
30
|
+
</span>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function IslandBadge({ children }: { children: ReactNode }) {
|
|
35
|
+
return <span className="dci-badge">{children}</span>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type IslandButtonVariant = 'icon' | 'primary' | 'secondary'
|
|
39
|
+
|
|
40
|
+
export function IslandButton({ variant = 'secondary', className, type = 'button', ...rest }: ButtonHTMLAttributes<HTMLButtonElement> & { variant?: IslandButtonVariant; ref?: Ref<HTMLButtonElement> }) {
|
|
41
|
+
return <button {...rest} type={type} className={className ? `dci-button ${className}` : 'dci-button'} data-variant={variant} />
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const RING = 2 * Math.PI * 8
|
|
45
|
+
|
|
46
|
+
export function IslandCountdown({ fraction, label }: { fraction: number; label: string }) {
|
|
47
|
+
const left = Math.min(1, Math.max(0, fraction))
|
|
48
|
+
return (
|
|
49
|
+
<span className="dci-countdown" aria-hidden="true">
|
|
50
|
+
<svg viewBox="0 0 20 20">
|
|
51
|
+
<circle cx="10" cy="10" r="8" className="dci-countdown__track" />
|
|
52
|
+
<circle cx="10" cy="10" r="8" className="dci-countdown__value" style={{ strokeDasharray: RING, strokeDashoffset: RING * (1 - left) }} />
|
|
53
|
+
</svg>
|
|
54
|
+
<em>{label}</em>
|
|
55
|
+
</span>
|
|
56
|
+
)
|
|
57
|
+
}
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { Island, type IslandProps } from './Island.js'
|
|
2
|
+
export {
|
|
3
|
+
IslandBadge,
|
|
4
|
+
IslandButton,
|
|
5
|
+
IslandCountdown,
|
|
6
|
+
IslandDetail,
|
|
7
|
+
IslandRobots,
|
|
8
|
+
type IslandButtonVariant,
|
|
9
|
+
type IslandRobot,
|
|
10
|
+
} from './parts.js'
|
|
11
|
+
export {
|
|
12
|
+
IslandBody,
|
|
13
|
+
IslandChoices,
|
|
14
|
+
IslandHead,
|
|
15
|
+
type IslandBodyContent,
|
|
16
|
+
type IslandChoice,
|
|
17
|
+
type IslandChoicesProps,
|
|
18
|
+
type IslandHeadProps,
|
|
19
|
+
} from './card.js'
|
|
20
|
+
export { EdgeGlow, type EdgeGlowProps } from './EdgeGlow.js'
|
|
21
|
+
export type { GlowGeometry, GlowPoint, IslandTheme } from './index.js'
|
package/src/styles.css
ADDED