@jsb188/gfx 1.1.2 → 1.1.11
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 +54 -248
- package/libs/dotGrid.ts +77 -480
- package/libs/effects/effectQuad.ts +2 -8
- package/libs/pointer.ts +0 -6
- package/libs/runtime.ts +4 -6
- package/libs/types.ts +1 -8
- package/main.ts +0 -2
- package/modules/Carousel.helpers.ts +0 -234
- package/modules/Carousel.tsx +29 -135
- package/modules/DotsArea.tsx +120 -0
- package/modules/GfxCanvas.tsx +2 -10
- package/modules/ScrollSteps.tsx +52 -7
- package/modules/VisionBoard.helpers.ts +561 -0
- package/modules/VisionBoard.tsx +358 -0
- package/modules/VisionBoard.types.ts +88 -0
- package/package.json +5 -15
- package/scenes/Carousel.ts +18 -99
- package/scenes/DotsArea.ts +208 -0
- package/tsconfig.json +1 -1
- package/utils/color.ts +2 -64
- package/utils/dotGridSpecs.ts +46 -304
- package/elements/Shapes.helpers.ts +0 -204
- package/elements/Shapes.hooks.ts +0 -171
- package/elements/Shapes.tsx +0 -505
- package/elements/Shapes.types.ts +0 -81
- package/elements/Stack.helpers.ts +0 -42
- package/elements/Stack.tsx +0 -143
- package/elements/Text.helpers.ts +0 -45
- package/elements/Text.hooks.ts +0 -197
- package/elements/Text.tsx +0 -98
- package/libs/dotGrid.helpers.ts +0 -53
- package/libs/effects/dotEffects.ts +0 -136
- package/modules/Carousel.hooks.ts +0 -520
- package/modules/Dots.tsx +0 -269
- package/modules/DotsBoard.helpers.ts +0 -388
- package/modules/DotsBoard.hooks.ts +0 -144
- package/modules/DotsBoard.strings.ts +0 -649
- package/modules/DotsBoard.types.ts +0 -240
- package/modules/DotsBoardCanvas.hooks.ts +0 -49
- package/modules/DotsBoardCanvas.tsx +0 -190
- package/modules/DotsBoardElements.tsx +0 -330
- package/modules/Gallery.helpers.ts +0 -32
- package/modules/Gallery.hooks.ts +0 -149
- package/modules/Gallery.tsx +0 -194
- package/modules/KineticHeader.helpers.ts +0 -44
- package/modules/KineticHeader.hooks.ts +0 -206
- package/modules/KineticHeader.tsx +0 -305
- package/modules/KineticHeader.types.ts +0 -56
- package/modules/ScrollSteps.hooks.ts +0 -138
- package/scenes/DotsBoard.helpers.ts +0 -12
- package/scenes/DotsBoard.ts +0 -245
- package/utils/align.ts +0 -18
- package/utils/dotEffectSpecs.ts +0 -79
- package/utils/motion.ts +0 -88
- package/utils/random.ts +0 -22
- package/utils/strings.ts +0 -116
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { cn } from '@jsb188/app/utils/string.ts';
|
|
2
|
+
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
3
|
+
import type { CSSProperties, PointerEvent } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
VISION_BOARD_DEFAULTS,
|
|
6
|
+
buildRestStringPath,
|
|
7
|
+
createVisionBoardEngine,
|
|
8
|
+
getVisionBoardSegments,
|
|
9
|
+
getVisionBoardTextStyle,
|
|
10
|
+
resolveVisionBoardItems,
|
|
11
|
+
} from './VisionBoard.helpers.ts';
|
|
12
|
+
import type { VisionBoardEngine } from './VisionBoard.helpers.ts';
|
|
13
|
+
import type {
|
|
14
|
+
ResolvedVisionBoardItem,
|
|
15
|
+
VisionBoardConnection,
|
|
16
|
+
VisionBoardItem,
|
|
17
|
+
VisionBoardOverrides,
|
|
18
|
+
VisionBoardPhysicsOptions,
|
|
19
|
+
VisionBoardSegment,
|
|
20
|
+
VisionBoardTextPlacement,
|
|
21
|
+
VisionBoardTextVisibility,
|
|
22
|
+
} from './VisionBoard.types.ts';
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
VisionBoardConnection,
|
|
26
|
+
VisionBoardItem,
|
|
27
|
+
VisionBoardItemOverride,
|
|
28
|
+
VisionBoardOverrides,
|
|
29
|
+
VisionBoardPhysicsOptions,
|
|
30
|
+
VisionBoardTextPlacement,
|
|
31
|
+
VisionBoardTextVisibility,
|
|
32
|
+
} from './VisionBoard.types.ts';
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* One item: a point in the board (its `left` / `top`, in percent, never change after mount so
|
|
36
|
+
* the engine can move it by transform alone) holding the node centered on it and the texts to
|
|
37
|
+
* one side. Hiding fades and shrinks the inner block so the point itself keeps its physics.
|
|
38
|
+
*/
|
|
39
|
+
const VisionBoardNode = memo(
|
|
40
|
+
(p: {
|
|
41
|
+
item: ResolvedVisionBoardItem;
|
|
42
|
+
boardWidth: number;
|
|
43
|
+
boardHeight: number;
|
|
44
|
+
size: number;
|
|
45
|
+
color: string;
|
|
46
|
+
textPlacement: VisionBoardTextPlacement;
|
|
47
|
+
textWidth: number;
|
|
48
|
+
hoverText: boolean;
|
|
49
|
+
draggable: boolean;
|
|
50
|
+
engine: VisionBoardEngine;
|
|
51
|
+
}) => {
|
|
52
|
+
const { item, boardWidth, boardHeight, size, color, textPlacement, textWidth, hoverText, draggable, engine } = p;
|
|
53
|
+
const { id, image, icon, title, text, tags, hidden } = item;
|
|
54
|
+
// The position the markup was rendered at; later moves are transforms from here.
|
|
55
|
+
const [base] = useState(() => ({ x: item.x, y: item.y }));
|
|
56
|
+
const hasText = !!(title || text || tags?.length);
|
|
57
|
+
const placement = item.textPlacement ?? textPlacement;
|
|
58
|
+
|
|
59
|
+
const setElement = useCallback((el: HTMLDivElement | null) => engine.setNode(id, el, base.x, base.y), [engine, id, base]);
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Drag with the pointer captured, so the item follows even when the pointer leaves it; the
|
|
63
|
+
* engine rubber-bands the distance and springs the item back on release.
|
|
64
|
+
*/
|
|
65
|
+
const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {
|
|
66
|
+
if (!draggable || e.button !== 0) return;
|
|
67
|
+
if (!engine.startDrag(id, e.clientX, e.clientY)) return;
|
|
68
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
};
|
|
71
|
+
const onPointerMove = (e: PointerEvent<HTMLDivElement>) => {
|
|
72
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) engine.moveDrag(id, e.clientX, e.clientY, e.timeStamp);
|
|
73
|
+
};
|
|
74
|
+
const onPointerEnd = (e: PointerEvent<HTMLDivElement>) => {
|
|
75
|
+
if (!e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
76
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
77
|
+
engine.endDrag(id, e.timeStamp);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
ref={setElement}
|
|
83
|
+
className={cn('abs', hoverText && 'op_hv_area')}
|
|
84
|
+
style={{ left: `${(base.x / boardWidth) * 100}%`, top: `${(base.y / boardHeight) * 100}%`, willChange: 'transform' }}
|
|
85
|
+
aria-hidden={hidden}
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
style={{
|
|
89
|
+
opacity: hidden ? 0 : 1,
|
|
90
|
+
transform: hidden ? 'scale(0.5)' : 'none',
|
|
91
|
+
transition: `opacity ${VISION_BOARD_DEFAULTS.hideMs}ms ease, transform ${VISION_BOARD_DEFAULTS.hideMs}ms ease`,
|
|
92
|
+
pointerEvents: hidden ? 'none' : undefined,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<div
|
|
96
|
+
className={cn('abs r bg h_center of', draggable && 'cs_grab')}
|
|
97
|
+
style={{
|
|
98
|
+
left: -size / 2,
|
|
99
|
+
top: -size / 2,
|
|
100
|
+
width: size,
|
|
101
|
+
height: size,
|
|
102
|
+
// Icons size themselves in em, so they scale with the node.
|
|
103
|
+
fontSize: Math.round(size * 0.36),
|
|
104
|
+
color,
|
|
105
|
+
boxShadow: `0 0 0 2px ${color}, 0 4px 14px rgba(0, 0, 0, 0.1)`,
|
|
106
|
+
transition: 'box-shadow 350ms ease, color 350ms ease',
|
|
107
|
+
touchAction: 'none',
|
|
108
|
+
}}
|
|
109
|
+
role={title ? 'img' : undefined}
|
|
110
|
+
aria-label={title}
|
|
111
|
+
onPointerDown={onPointerDown}
|
|
112
|
+
onPointerMove={onPointerMove}
|
|
113
|
+
onPointerUp={onPointerEnd}
|
|
114
|
+
onPointerCancel={onPointerEnd}
|
|
115
|
+
>
|
|
116
|
+
{image ? (
|
|
117
|
+
<img
|
|
118
|
+
src={image}
|
|
119
|
+
alt=""
|
|
120
|
+
draggable={false}
|
|
121
|
+
className="w_f h_f img_cover bl"
|
|
122
|
+
/>
|
|
123
|
+
) : (
|
|
124
|
+
icon
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
{hasText && (
|
|
128
|
+
<div
|
|
129
|
+
className={cn('abs lh_2', hoverText && 'op_0 op_100_hv trans_op')}
|
|
130
|
+
style={getVisionBoardTextStyle(placement, size, VISION_BOARD_DEFAULTS.textGap, textWidth)}
|
|
131
|
+
>
|
|
132
|
+
{title && <div className="ft_sm ft_semibold">{title}</div>}
|
|
133
|
+
{text && <div className="ft_xs op_70">{text}</div>}
|
|
134
|
+
{!!tags?.length && (
|
|
135
|
+
<div
|
|
136
|
+
className="h_item f_wrap gap_xs mt_xs"
|
|
137
|
+
style={{ justifyContent: placement === 'left' ? 'flex-end' : placement === 'right' ? 'flex-start' : 'center' }}
|
|
138
|
+
>
|
|
139
|
+
{tags.map((tag) => (
|
|
140
|
+
<span
|
|
141
|
+
key={tag}
|
|
142
|
+
className="ft_xxs px_5 r bg_active no_wrap"
|
|
143
|
+
>
|
|
144
|
+
{tag}
|
|
145
|
+
</span>
|
|
146
|
+
))}
|
|
147
|
+
</div>
|
|
148
|
+
)}
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* One stretch of string. The markup carries its rest path; from then on the engine owns `d`,
|
|
159
|
+
* so React never resets a moving string (the path never re-renders `d`).
|
|
160
|
+
*/
|
|
161
|
+
const VisionBoardString = memo(
|
|
162
|
+
(p: {
|
|
163
|
+
segment: VisionBoardSegment;
|
|
164
|
+
from: ResolvedVisionBoardItem;
|
|
165
|
+
to: ResolvedVisionBoardItem;
|
|
166
|
+
color: string;
|
|
167
|
+
width: number;
|
|
168
|
+
engine: VisionBoardEngine;
|
|
169
|
+
}) => {
|
|
170
|
+
const { segment, from, to, color, width, engine } = p;
|
|
171
|
+
const [restPath] = useState(() => buildRestStringPath(from.x, from.y, to.x, to.y, segment.slack));
|
|
172
|
+
const setElement = useCallback((el: SVGPathElement | null) => engine.setSegmentElement(segment.key, el), [engine, segment.key]);
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<path
|
|
176
|
+
ref={setElement}
|
|
177
|
+
d={restPath}
|
|
178
|
+
fill="none"
|
|
179
|
+
strokeWidth={width}
|
|
180
|
+
strokeLinecap="round"
|
|
181
|
+
strokeDasharray={segment.dashed ? '4 8' : undefined}
|
|
182
|
+
vectorEffect="non-scaling-stroke"
|
|
183
|
+
style={{
|
|
184
|
+
stroke: color,
|
|
185
|
+
opacity: segment.hidden ? 0 : 1,
|
|
186
|
+
transition: `opacity ${VISION_BOARD_DEFAULTS.hideMs}ms ease, stroke ${VISION_BOARD_DEFAULTS.hideMs}ms ease`,
|
|
187
|
+
}}
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* A board of items (a photo or an icon in a ring, with a title, text, and tags beside it) placed
|
|
195
|
+
* in a `width` × `height` design space, joined by strings. The board keeps that aspect ratio at
|
|
196
|
+
* any CSS width, so positions scale while node sizes and texts stay in pixels. Items can be
|
|
197
|
+
* dragged: they move freely up to `dragLimit` board units from home, resist beyond it, and
|
|
198
|
+
* spring back with a bounce when released (a fast release throws them a little). Each string
|
|
199
|
+
* is a chain through item ids, drawn as a quadratic curve per stretch that sags by `slack` and,
|
|
200
|
+
* with string physics on, lags and wobbles behind the items it joins before settling.
|
|
201
|
+
* `overrides` change any item property (position, `hidden`, color, texts) by id: switching to
|
|
202
|
+
* another overrides object springs the items to their new places and fades hidden ones out, so
|
|
203
|
+
* a set of buttons or a scroll position can drive the board as a sequence of states.
|
|
204
|
+
* `visibleTags` hides tagged items that carry none of the given tags (untagged items always show).
|
|
205
|
+
* Motion runs outside React on one frame loop that stops when everything is still; reduced
|
|
206
|
+
* motion snaps instead of springing. The markup renders the rest state, so the server output
|
|
207
|
+
* already shows the whole board.
|
|
208
|
+
*/
|
|
209
|
+
export const VisionBoard = memo(
|
|
210
|
+
(p: {
|
|
211
|
+
items: VisionBoardItem[];
|
|
212
|
+
connections?: VisionBoardConnection[];
|
|
213
|
+
/** Design space the item coordinates live in; the board keeps this aspect ratio. */
|
|
214
|
+
width: number;
|
|
215
|
+
height: number;
|
|
216
|
+
/** The current state of the board, applied over `items` by id. */
|
|
217
|
+
overrides?: VisionBoardOverrides;
|
|
218
|
+
/** Show only tagged items carrying at least one of these tags; `null` or omitted shows all. */
|
|
219
|
+
visibleTags?: string[] | null;
|
|
220
|
+
/** Whether the texts are always beside the node or appear while it is hovered. */
|
|
221
|
+
textVisibility?: VisionBoardTextVisibility;
|
|
222
|
+
textPlacement?: VisionBoardTextPlacement;
|
|
223
|
+
/** Width of the text block in CSS pixels. */
|
|
224
|
+
textWidth?: number;
|
|
225
|
+
/** Node diameter in CSS pixels. */
|
|
226
|
+
nodeSize?: number;
|
|
227
|
+
/** Default accent color of the nodes. */
|
|
228
|
+
color?: string;
|
|
229
|
+
draggable?: boolean;
|
|
230
|
+
/** How far, in board units, an item drags freely before the rubber band resists. */
|
|
231
|
+
dragLimit?: number;
|
|
232
|
+
/** Default sag of the strings as a fraction of each stretch's length; 0 for straight lines. */
|
|
233
|
+
slack?: number;
|
|
234
|
+
stringColor?: string;
|
|
235
|
+
/** Default stroke width of the strings in CSS pixels. */
|
|
236
|
+
stringWidth?: number;
|
|
237
|
+
physics?: VisionBoardPhysicsOptions;
|
|
238
|
+
className?: string;
|
|
239
|
+
style?: CSSProperties;
|
|
240
|
+
}) => {
|
|
241
|
+
const {
|
|
242
|
+
items,
|
|
243
|
+
connections,
|
|
244
|
+
width,
|
|
245
|
+
height,
|
|
246
|
+
overrides,
|
|
247
|
+
visibleTags,
|
|
248
|
+
textVisibility = 'always',
|
|
249
|
+
textPlacement = 'right',
|
|
250
|
+
textWidth = VISION_BOARD_DEFAULTS.textWidth,
|
|
251
|
+
nodeSize = VISION_BOARD_DEFAULTS.nodeSize,
|
|
252
|
+
color = 'currentColor',
|
|
253
|
+
draggable = true,
|
|
254
|
+
dragLimit = VISION_BOARD_DEFAULTS.dragLimit,
|
|
255
|
+
slack = VISION_BOARD_DEFAULTS.slack,
|
|
256
|
+
stringColor,
|
|
257
|
+
stringWidth = VISION_BOARD_DEFAULTS.stringWidth,
|
|
258
|
+
physics,
|
|
259
|
+
className,
|
|
260
|
+
style,
|
|
261
|
+
} = p;
|
|
262
|
+
const itemSpring = { ...VISION_BOARD_DEFAULTS.itemSpring, ...physics?.item };
|
|
263
|
+
const stringSpring = physics?.string === false ? null : { ...VISION_BOARD_DEFAULTS.stringSpring, ...physics?.string };
|
|
264
|
+
const [engine] = useState(() =>
|
|
265
|
+
createVisionBoardEngine({
|
|
266
|
+
dragLimit,
|
|
267
|
+
dragStretch: VISION_BOARD_DEFAULTS.dragStretch,
|
|
268
|
+
throwFactor: VISION_BOARD_DEFAULTS.throwFactor,
|
|
269
|
+
itemSpring,
|
|
270
|
+
stringSpring,
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
const [boardEl, setBoardEl] = useState<HTMLDivElement | null>(null);
|
|
274
|
+
|
|
275
|
+
const resolvedItems = useMemo(() => resolveVisionBoardItems(items, overrides, visibleTags), [items, overrides, visibleTags]);
|
|
276
|
+
const itemsById = useMemo(() => new Map(resolvedItems.map((item) => [item.id, item])), [resolvedItems]);
|
|
277
|
+
const segments = useMemo(() => getVisionBoardSegments(connections ?? [], itemsById, slack), [connections, itemsById, slack]);
|
|
278
|
+
|
|
279
|
+
useLayoutEffect(() => {
|
|
280
|
+
engine.setOptions({
|
|
281
|
+
dragLimit,
|
|
282
|
+
dragStretch: VISION_BOARD_DEFAULTS.dragStretch,
|
|
283
|
+
throwFactor: VISION_BOARD_DEFAULTS.throwFactor,
|
|
284
|
+
itemSpring,
|
|
285
|
+
stringSpring,
|
|
286
|
+
});
|
|
287
|
+
}, [dragLimit, itemSpring.stiffness, itemSpring.damping, stringSpring?.stiffness, stringSpring?.damping]);
|
|
288
|
+
|
|
289
|
+
// Before paint, so a state change never shows the new markup with a stale transform.
|
|
290
|
+
useLayoutEffect(() => {
|
|
291
|
+
for (const item of resolvedItems) engine.setHome(item.id, item.x, item.y);
|
|
292
|
+
}, [resolvedItems]);
|
|
293
|
+
|
|
294
|
+
useLayoutEffect(() => {
|
|
295
|
+
engine.setSegments(segments);
|
|
296
|
+
}, [segments]);
|
|
297
|
+
|
|
298
|
+
// CSS pixels per board unit, kept current so drags and transforms stay in step with the layout.
|
|
299
|
+
useLayoutEffect(() => {
|
|
300
|
+
engine.setBoard(boardEl);
|
|
301
|
+
if (!boardEl) return;
|
|
302
|
+
const measure = () => engine.setScale(boardEl.clientWidth / width);
|
|
303
|
+
measure();
|
|
304
|
+
const observer = new ResizeObserver(measure);
|
|
305
|
+
observer.observe(boardEl);
|
|
306
|
+
return () => observer.disconnect();
|
|
307
|
+
}, [boardEl, width]);
|
|
308
|
+
|
|
309
|
+
useEffect(() => () => engine.dispose(), []);
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<div
|
|
313
|
+
ref={setBoardEl}
|
|
314
|
+
className={cn('rel unsel', className)}
|
|
315
|
+
style={{ aspectRatio: `${width} / ${height}`, ...style }}
|
|
316
|
+
>
|
|
317
|
+
<svg
|
|
318
|
+
className="abs_full w_f h_f noclick"
|
|
319
|
+
viewBox={`0 0 ${width} ${height}`}
|
|
320
|
+
preserveAspectRatio="none"
|
|
321
|
+
aria-hidden
|
|
322
|
+
>
|
|
323
|
+
{segments.map((segment) => {
|
|
324
|
+
const from = itemsById.get(segment.from);
|
|
325
|
+
const to = itemsById.get(segment.to);
|
|
326
|
+
if (!from || !to) return null;
|
|
327
|
+
return (
|
|
328
|
+
<VisionBoardString
|
|
329
|
+
key={segment.key}
|
|
330
|
+
segment={segment}
|
|
331
|
+
from={from}
|
|
332
|
+
to={to}
|
|
333
|
+
color={segment.color ?? stringColor ?? color}
|
|
334
|
+
width={segment.width ?? stringWidth}
|
|
335
|
+
engine={engine}
|
|
336
|
+
/>
|
|
337
|
+
);
|
|
338
|
+
})}
|
|
339
|
+
</svg>
|
|
340
|
+
{resolvedItems.map((item) => (
|
|
341
|
+
<VisionBoardNode
|
|
342
|
+
key={item.id}
|
|
343
|
+
item={item}
|
|
344
|
+
boardWidth={width}
|
|
345
|
+
boardHeight={height}
|
|
346
|
+
size={item.size ?? nodeSize}
|
|
347
|
+
color={item.color ?? color}
|
|
348
|
+
textPlacement={textPlacement}
|
|
349
|
+
textWidth={textWidth}
|
|
350
|
+
hoverText={(item.textVisibility ?? textVisibility) === 'hover'}
|
|
351
|
+
draggable={item.draggable ?? draggable}
|
|
352
|
+
engine={engine}
|
|
353
|
+
/>
|
|
354
|
+
))}
|
|
355
|
+
</div>
|
|
356
|
+
);
|
|
357
|
+
},
|
|
358
|
+
);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Types shared by the vision board component, its helpers, and callers that describe boards.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type VisionBoardTextPlacement = 'right' | 'left' | 'top' | 'bottom';
|
|
8
|
+
|
|
9
|
+
export type VisionBoardTextVisibility = 'always' | 'hover';
|
|
10
|
+
|
|
11
|
+
export interface VisionBoardItem {
|
|
12
|
+
/** Names the item for connections, overrides, and hover; defaults to its index in `items`. */
|
|
13
|
+
id?: string;
|
|
14
|
+
/** Center of the item in board units (the `width` × `height` design space of the board). */
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
/** Photo filling the node. */
|
|
18
|
+
image?: string;
|
|
19
|
+
/** Custom node content (an SVG, an icon) centered in the node; ignored when `image` is set. */
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
title?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
/** Shown as small pills under the texts; the board's `visibleTags` filters on them. */
|
|
24
|
+
tags?: string[];
|
|
25
|
+
/** Node diameter in CSS pixels; defaults to the board's `nodeSize`. */
|
|
26
|
+
size?: number;
|
|
27
|
+
/** Accent color of the node ring and its icon; strings leaving this item take it unless they set their own. */
|
|
28
|
+
color?: string;
|
|
29
|
+
/** Fade the item (and every string touching it) out; it keeps its place so it can come back. */
|
|
30
|
+
hidden?: boolean;
|
|
31
|
+
/** Side of the node the texts sit on; defaults to the board's `textPlacement`. */
|
|
32
|
+
textPlacement?: VisionBoardTextPlacement;
|
|
33
|
+
/** Overrides the board's `textVisibility` for this item. */
|
|
34
|
+
textVisibility?: VisionBoardTextVisibility;
|
|
35
|
+
/** Overrides the board's `draggable` for this item. */
|
|
36
|
+
draggable?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Per-item changes a board state applies on top of `items`: positions, visibility, colors, texts. */
|
|
40
|
+
export type VisionBoardItemOverride = Partial<Omit<VisionBoardItem, 'id'>>;
|
|
41
|
+
|
|
42
|
+
/** Overrides keyed by item id. */
|
|
43
|
+
export type VisionBoardOverrides = Record<string, VisionBoardItemOverride>;
|
|
44
|
+
|
|
45
|
+
/** An item with its overrides and the tag filter applied; `id` is always set. */
|
|
46
|
+
export interface ResolvedVisionBoardItem extends Omit<VisionBoardItem, 'id' | 'hidden'> {
|
|
47
|
+
id: string;
|
|
48
|
+
hidden: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface VisionBoardConnection {
|
|
52
|
+
/** Ids of the items the string runs through, in order; a string needs at least two. */
|
|
53
|
+
items: string[];
|
|
54
|
+
/** Sag of each stretch at rest as a fraction of its length; 0 draws it straight. Defaults to the board's `slack`. */
|
|
55
|
+
slack?: number;
|
|
56
|
+
/** Defaults to the color of the item each stretch leaves, then the board's `stringColor`. */
|
|
57
|
+
color?: string;
|
|
58
|
+
/** Stroke width in CSS pixels; defaults to the board's `stringWidth`. */
|
|
59
|
+
width?: number;
|
|
60
|
+
dashed?: boolean;
|
|
61
|
+
hidden?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** One stretch of string between two neighbouring items of a connection. */
|
|
65
|
+
export interface VisionBoardSegment {
|
|
66
|
+
key: string;
|
|
67
|
+
from: string;
|
|
68
|
+
to: string;
|
|
69
|
+
slack: number;
|
|
70
|
+
color?: string;
|
|
71
|
+
width?: number;
|
|
72
|
+
dashed: boolean;
|
|
73
|
+
hidden: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface VisionBoardSpring {
|
|
77
|
+
/** Pull toward the rest position, per unit of distance. */
|
|
78
|
+
stiffness: number;
|
|
79
|
+
/** Resistance to velocity; below about `2 × √stiffness` the motion overshoots and bounces. */
|
|
80
|
+
damping: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface VisionBoardPhysicsOptions {
|
|
84
|
+
/** Spring that returns a released or relocated item to its place. */
|
|
85
|
+
item?: Partial<VisionBoardSpring>;
|
|
86
|
+
/** Spring on each string's bend, so the strings lag and wobble behind moving items; `false` keeps them taut. */
|
|
87
|
+
string?: Partial<VisionBoardSpring> | false;
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/gfx",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Shared OGL/WebGL2 runtime, fullscreen pass chain, shader passes, and hero/section components for web graphics.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -10,14 +10,10 @@
|
|
|
10
10
|
".": "./main.ts",
|
|
11
11
|
"./modules/GfxCanvas": "./modules/GfxCanvas.tsx",
|
|
12
12
|
"./modules/Hero": "./modules/Hero.tsx",
|
|
13
|
-
"./modules/
|
|
14
|
-
"./modules/Dots": "./modules/Dots.tsx",
|
|
13
|
+
"./modules/DotsArea": "./modules/DotsArea.tsx",
|
|
15
14
|
"./modules/Carousel": "./modules/Carousel.tsx",
|
|
16
|
-
"./modules/
|
|
15
|
+
"./modules/VisionBoard": "./modules/VisionBoard.tsx",
|
|
17
16
|
"./modules/ScrollSteps": "./modules/ScrollSteps.tsx",
|
|
18
|
-
"./elements/Shapes": "./elements/Shapes.tsx",
|
|
19
|
-
"./elements/Stack": "./elements/Stack.tsx",
|
|
20
|
-
"./elements/Text": "./elements/Text.tsx",
|
|
21
17
|
"./libs/runtime": "./libs/runtime.ts",
|
|
22
18
|
"./libs/types": "./libs/types.ts",
|
|
23
19
|
"./libs/uniforms": "./libs/uniforms.ts",
|
|
@@ -31,20 +27,14 @@
|
|
|
31
27
|
"./libs/effects/effectRegion": "./libs/effects/effectRegion.ts",
|
|
32
28
|
"./libs/effects/effectQuad": "./libs/effects/effectQuad.ts",
|
|
33
29
|
"./libs/effects/ripple": "./libs/effects/ripple.ts",
|
|
34
|
-
"./libs/effects/dotEffects": "./libs/effects/dotEffects.ts",
|
|
35
30
|
"./utils/color": "./utils/color.ts",
|
|
36
31
|
"./utils/easing": "./utils/easing.ts",
|
|
37
|
-
"./utils/motion": "./utils/motion.ts",
|
|
38
|
-
"./utils/align": "./utils/align.ts",
|
|
39
32
|
"./utils/imageEffectSpecs": "./utils/imageEffectSpecs.ts",
|
|
40
|
-
"./utils/dotGridSpecs": "./utils/dotGridSpecs.ts"
|
|
41
|
-
"./utils/dotEffectSpecs": "./utils/dotEffectSpecs.ts",
|
|
42
|
-
"./utils/strings": "./utils/strings.ts",
|
|
43
|
-
"./utils/random": "./utils/random.ts"
|
|
33
|
+
"./utils/dotGridSpecs": "./utils/dotGridSpecs.ts"
|
|
44
34
|
},
|
|
45
35
|
"peerDependencies": {
|
|
46
36
|
"ogl": "^1.0.11",
|
|
47
|
-
"react": "^19.
|
|
37
|
+
"react": "^19.2.8"
|
|
48
38
|
},
|
|
49
39
|
"scripts": {
|
|
50
40
|
"build": "tsc"
|