@vetta-org/theme-ui 0.1.2 → 0.2.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/package.json +8 -16
- package/src/action-approval/StorageCleanListView.test.tsx +36 -0
- package/src/action-approval/StorageCleanListView.tsx +52 -0
- package/src/action-approval/index.ts +2 -0
- package/src/activity/ActivityPanel.tsx +7 -1
- package/src/activity/ActivityPanelFrame.tsx +1 -1
- package/src/activity/BackgroundTasksTabPanelView.tsx +18 -2
- package/src/activity/BrowserPanelView.tsx +15 -1
- package/src/activity/BrowserSelectionView.tsx +199 -0
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +86 -10
- package/src/activity/index.ts +1 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/EditDiffView.tsx +4 -4
- package/src/chat/HeaderActionBarView.tsx +135 -48
- package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
- package/src/chat/MessageFeedLayoutView.tsx +6 -5
- package/src/chat/MessageInputView.tsx +5 -1
- package/src/chat/index.ts +2 -1
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/streaming-reveal.test.ts +1 -74
- package/src/chat/streaming-reveal.ts +0 -3
- package/src/file-preview/FilePreviewDialogView.tsx +2 -1
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/layout/ResizeHandle.tsx +4 -1
- package/src/layout/resize-handle-reset.test.tsx +50 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/MarkdownContent.tsx +61 -31
- package/src/markdown/MarkdownImage.tsx +6 -16
- package/src/markdown/MermaidBlock.tsx +50 -11
- package/src/markdown/UrlLinkBadge.tsx +84 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +2 -0
- package/src/markdown/nodes.ts +6 -1
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +33 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +9 -0
- package/src/markdown/streaming-fade.test.ts +83 -0
- package/src/markdown/streaming-fade.tsx +141 -0
- package/src/markdown/streaming-reveal.ts +0 -67
- package/src/markdown/streaming.ts +64 -131
- package/src/overlays/CommandMenuRow.tsx +47 -26
- package/src/overlays/CommandMenuView.tsx +107 -15
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteImage.test.tsx +105 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +49 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +120 -7
- package/src/overlays/SplashPanel.tsx +4 -4
- package/src/overlays/SplashParts.tsx +6 -2
- package/src/overlays/UpdateCheckerView.tsx +17 -15
- package/src/overlays/UpdateRestartDialogView.tsx +76 -2
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/index.ts +13 -0
- package/src/plugin-ui/index.ts +4 -0
- package/src/project/DefaultConversationSectionView.tsx +17 -22
- package/src/project/DefaultSessionRowView.tsx +8 -0
- package/src/project/ManageSessionsSplashView.tsx +0 -2
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/GeneralSettingsView.tsx +21 -5
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +272 -0
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderRowView.tsx +37 -98
- package/src/settings/ShortcutsSettingsView.tsx +0 -4
- package/src/settings/SpaceEditorDialogView.tsx +94 -56
- package/src/settings/SpacesSettingsView.tsx +53 -8
- package/src/settings/StorageBar.tsx +70 -0
- package/src/settings/StorageExplorer.tsx +488 -0
- package/src/settings/StorageReadout.tsx +64 -0
- package/src/settings/StorageSettingsView.test.tsx +181 -0
- package/src/settings/StorageSettingsView.tsx +458 -0
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +28 -39
- package/src/settings/storage-treemap-layout.test.ts +32 -0
- package/src/settings/storage-treemap-layout.ts +55 -0
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +18 -11
- package/src/shared/StageDialogContent.test.tsx +61 -0
- package/src/shared/StageDialogContent.tsx +80 -0
- package/src/shared/TabBar.tsx +2 -2
- package/src/shared/VettaKbd.tsx +20 -1
- package/src/shared/index.ts +4 -1
- package/src/shared/platform.ts +9 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +13 -12
- package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/styles.css +7 -0
- package/src/markdown/streaming.test.ts +0 -57
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -43
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import type { JSX } from "react";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useReducedMotion } from "motion/react";
|
|
4
|
-
import {
|
|
5
|
-
AmbientLight,
|
|
6
|
-
CanvasTexture,
|
|
7
|
-
Color,
|
|
8
|
-
DirectionalLight,
|
|
9
|
-
DoubleSide,
|
|
10
|
-
ExtrudeGeometry,
|
|
11
|
-
Group,
|
|
12
|
-
LinearFilter,
|
|
13
|
-
Mesh,
|
|
14
|
-
MeshBasicMaterial,
|
|
15
|
-
MeshPhysicalMaterial,
|
|
16
|
-
PerspectiveCamera,
|
|
17
|
-
PlaneGeometry,
|
|
18
|
-
Scene,
|
|
19
|
-
Shape,
|
|
20
|
-
SRGBColorSpace,
|
|
21
|
-
Texture,
|
|
22
|
-
TextureLoader,
|
|
23
|
-
Vector2,
|
|
24
|
-
WebGLRenderer,
|
|
25
|
-
} from "three";
|
|
26
|
-
|
|
27
|
-
export interface AchievementPromotionBadge3DProps {
|
|
28
|
-
imageUrl: string;
|
|
29
|
-
onCelebrate: () => void;
|
|
30
|
-
onComplete: () => void;
|
|
31
|
-
onHideText: () => void;
|
|
32
|
-
onRevealText: () => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ANIMATION_DURATION_MS = 4300;
|
|
36
|
-
const BADGE_RENDER_SCALE = 0.6;
|
|
37
|
-
const BADGE_WIDTH = 2.35;
|
|
38
|
-
const BADGE_DEPTH = 0.22;
|
|
39
|
-
const OUTLINE_RESOLUTION = 512;
|
|
40
|
-
const OUTLINE_POINT_COUNT = 384;
|
|
41
|
-
|
|
42
|
-
function easeOutCubic(value: number): number {
|
|
43
|
-
return 1 - (1 - value) ** 3;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function interpolateKeyframes(
|
|
47
|
-
progress: number,
|
|
48
|
-
times: readonly number[],
|
|
49
|
-
values: readonly number[],
|
|
50
|
-
): number {
|
|
51
|
-
const lastIndex = times.length - 1;
|
|
52
|
-
if (progress <= times[0]) return values[0];
|
|
53
|
-
if (progress >= times[lastIndex]) return values[lastIndex];
|
|
54
|
-
|
|
55
|
-
for (let index = 1; index <= lastIndex; index += 1) {
|
|
56
|
-
if (progress > times[index]) continue;
|
|
57
|
-
const segmentProgress = (progress - times[index - 1]) / (times[index] - times[index - 1]);
|
|
58
|
-
return values[index - 1] + (values[index] - values[index - 1]) * segmentProgress;
|
|
59
|
-
}
|
|
60
|
-
return values[lastIndex];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function createFallbackTexture(): CanvasTexture {
|
|
64
|
-
const canvas = document.createElement("canvas");
|
|
65
|
-
canvas.width = 2;
|
|
66
|
-
canvas.height = 2;
|
|
67
|
-
const context = canvas.getContext("2d");
|
|
68
|
-
if (context) {
|
|
69
|
-
context.fillStyle = "#b9893f";
|
|
70
|
-
context.fillRect(0, 0, 2, 2);
|
|
71
|
-
}
|
|
72
|
-
return new CanvasTexture(canvas);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function smoothClosedOutline(points: readonly Vector2[]): Vector2[] {
|
|
76
|
-
let smoothed = points.map((point) => point.clone());
|
|
77
|
-
for (let pass = 0; pass < 4; pass += 1) {
|
|
78
|
-
smoothed = smoothed.map((point, index, allPoints) => {
|
|
79
|
-
const previous = allPoints[(index - 1 + allPoints.length) % allPoints.length];
|
|
80
|
-
const next = allPoints[(index + 1) % allPoints.length];
|
|
81
|
-
return new Vector2(
|
|
82
|
-
previous.x * 0.25 + point.x * 0.5 + next.x * 0.25,
|
|
83
|
-
previous.y * 0.25 + point.y * 0.5 + next.y * 0.25,
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return smoothed;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function createBadgeShape(image: HTMLImageElement): Shape {
|
|
91
|
-
const canvas = document.createElement("canvas");
|
|
92
|
-
canvas.width = OUTLINE_RESOLUTION;
|
|
93
|
-
canvas.height = OUTLINE_RESOLUTION;
|
|
94
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
95
|
-
const aspectRatio = image.naturalWidth / image.naturalHeight;
|
|
96
|
-
const drawWidth = aspectRatio >= 1
|
|
97
|
-
? OUTLINE_RESOLUTION
|
|
98
|
-
: OUTLINE_RESOLUTION * aspectRatio;
|
|
99
|
-
const drawHeight = aspectRatio >= 1
|
|
100
|
-
? OUTLINE_RESOLUTION / aspectRatio
|
|
101
|
-
: OUTLINE_RESOLUTION;
|
|
102
|
-
const drawX = (OUTLINE_RESOLUTION - drawWidth) / 2;
|
|
103
|
-
const drawY = (OUTLINE_RESOLUTION - drawHeight) / 2;
|
|
104
|
-
context?.drawImage(image, drawX, drawY, drawWidth, drawHeight);
|
|
105
|
-
const pixels = context?.getImageData(0, 0, OUTLINE_RESOLUTION, OUTLINE_RESOLUTION).data;
|
|
106
|
-
const center = OUTLINE_RESOLUTION / 2;
|
|
107
|
-
const maxRadius = Math.SQRT2 * center;
|
|
108
|
-
const badgeHeight = BADGE_WIDTH / aspectRatio;
|
|
109
|
-
const points: Vector2[] = [];
|
|
110
|
-
|
|
111
|
-
if (pixels) {
|
|
112
|
-
for (let step = 0; step < OUTLINE_POINT_COUNT; step += 1) {
|
|
113
|
-
const angle = (step / OUTLINE_POINT_COUNT) * Math.PI * 2;
|
|
114
|
-
for (let radius = maxRadius; radius >= 0; radius -= 1) {
|
|
115
|
-
const pixelX = Math.round(center + Math.cos(angle) * radius);
|
|
116
|
-
const pixelY = Math.round(center - Math.sin(angle) * radius);
|
|
117
|
-
if (
|
|
118
|
-
pixelX < 0
|
|
119
|
-
|| pixelX >= OUTLINE_RESOLUTION
|
|
120
|
-
|| pixelY < 0
|
|
121
|
-
|| pixelY >= OUTLINE_RESOLUTION
|
|
122
|
-
) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
const alpha = pixels[(pixelY * OUTLINE_RESOLUTION + pixelX) * 4 + 3];
|
|
126
|
-
if (alpha < 64) continue;
|
|
127
|
-
points.push(new Vector2(
|
|
128
|
-
(pixelX / OUTLINE_RESOLUTION - 0.5) * BADGE_WIDTH,
|
|
129
|
-
(0.5 - pixelY / OUTLINE_RESOLUTION) * badgeHeight,
|
|
130
|
-
));
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (points.length >= 24) return new Shape(smoothClosedOutline(points));
|
|
137
|
-
const fallback = new Shape();
|
|
138
|
-
fallback.absellipse(0, 0, BADGE_WIDTH / 2, badgeHeight / 2, 0, Math.PI * 2);
|
|
139
|
-
return fallback;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function createBadgeGeometry(shape: Shape): ExtrudeGeometry {
|
|
143
|
-
const geometry = new ExtrudeGeometry(shape, {
|
|
144
|
-
bevelEnabled: true,
|
|
145
|
-
bevelSegments: 6,
|
|
146
|
-
bevelSize: 0.025,
|
|
147
|
-
bevelThickness: 0.035,
|
|
148
|
-
curveSegments: 4,
|
|
149
|
-
depth: BADGE_DEPTH,
|
|
150
|
-
});
|
|
151
|
-
geometry.translate(0, 0, -BADGE_DEPTH / 2);
|
|
152
|
-
return geometry;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function AchievementPromotionBadge3D({
|
|
156
|
-
imageUrl,
|
|
157
|
-
onCelebrate,
|
|
158
|
-
onComplete,
|
|
159
|
-
onHideText,
|
|
160
|
-
onRevealText,
|
|
161
|
-
}: AchievementPromotionBadge3DProps): JSX.Element {
|
|
162
|
-
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
163
|
-
const reduceMotion = useReducedMotion();
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
const canvas = canvasRef.current;
|
|
167
|
-
if (!canvas) return;
|
|
168
|
-
|
|
169
|
-
const renderer = new WebGLRenderer({
|
|
170
|
-
alpha: true,
|
|
171
|
-
antialias: true,
|
|
172
|
-
canvas,
|
|
173
|
-
powerPreference: "high-performance",
|
|
174
|
-
});
|
|
175
|
-
renderer.setClearColor(0x000000, 0);
|
|
176
|
-
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
177
|
-
renderer.outputColorSpace = SRGBColorSpace;
|
|
178
|
-
|
|
179
|
-
const scene = new Scene();
|
|
180
|
-
const camera = new PerspectiveCamera(34, 1, 0.1, 100);
|
|
181
|
-
camera.position.set(0, 0.15, 7);
|
|
182
|
-
|
|
183
|
-
scene.add(new AmbientLight(0xffffff, 2.1));
|
|
184
|
-
const keyLight = new DirectionalLight(0xffe0a3, 4.8);
|
|
185
|
-
keyLight.position.set(3, 4, 6);
|
|
186
|
-
scene.add(keyLight);
|
|
187
|
-
const rimLight = new DirectionalLight(0xc1472d, 3.2);
|
|
188
|
-
rimLight.position.set(-4, 1, -3);
|
|
189
|
-
scene.add(rimLight);
|
|
190
|
-
|
|
191
|
-
const badge = new Group();
|
|
192
|
-
badge.scale.setScalar(BADGE_RENDER_SCALE);
|
|
193
|
-
scene.add(badge);
|
|
194
|
-
|
|
195
|
-
const fallbackShape = new Shape();
|
|
196
|
-
fallbackShape.absellipse(0, 0, 1.08, 1, 0, Math.PI * 2);
|
|
197
|
-
let edgeGeometry = createBadgeGeometry(fallbackShape);
|
|
198
|
-
const edgeMaterial = new MeshPhysicalMaterial({
|
|
199
|
-
color: new Color("#c58a32"),
|
|
200
|
-
metalness: 0.86,
|
|
201
|
-
roughness: 0.22,
|
|
202
|
-
clearcoat: 0.78,
|
|
203
|
-
clearcoatRoughness: 0.16,
|
|
204
|
-
transparent: true,
|
|
205
|
-
});
|
|
206
|
-
const edge = new Mesh(edgeGeometry, edgeMaterial);
|
|
207
|
-
badge.add(edge);
|
|
208
|
-
|
|
209
|
-
const faceGeometry = new PlaneGeometry(1, 1);
|
|
210
|
-
const texture = createFallbackTexture();
|
|
211
|
-
texture.colorSpace = SRGBColorSpace;
|
|
212
|
-
texture.minFilter = LinearFilter;
|
|
213
|
-
texture.magFilter = LinearFilter;
|
|
214
|
-
const faceMaterial = new MeshBasicMaterial({
|
|
215
|
-
alphaTest: 0.02,
|
|
216
|
-
map: texture,
|
|
217
|
-
side: DoubleSide,
|
|
218
|
-
toneMapped: false,
|
|
219
|
-
transparent: true,
|
|
220
|
-
});
|
|
221
|
-
const front = new Mesh(faceGeometry, faceMaterial);
|
|
222
|
-
front.position.z = BADGE_DEPTH / 2 + 0.04;
|
|
223
|
-
front.scale.set(BADGE_WIDTH, 2.16, 1);
|
|
224
|
-
badge.add(front);
|
|
225
|
-
|
|
226
|
-
const back = new Mesh(faceGeometry, faceMaterial);
|
|
227
|
-
back.position.z = -(BADGE_DEPTH / 2 + 0.04);
|
|
228
|
-
back.rotation.y = Math.PI;
|
|
229
|
-
back.scale.copy(front.scale);
|
|
230
|
-
badge.add(back);
|
|
231
|
-
|
|
232
|
-
let active = true;
|
|
233
|
-
const loadedTexture = new TextureLoader().load(imageUrl, (nextTexture: Texture) => {
|
|
234
|
-
if (!active) {
|
|
235
|
-
nextTexture.dispose();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
nextTexture.colorSpace = SRGBColorSpace;
|
|
239
|
-
nextTexture.minFilter = LinearFilter;
|
|
240
|
-
nextTexture.magFilter = LinearFilter;
|
|
241
|
-
faceMaterial.map = nextTexture;
|
|
242
|
-
faceMaterial.needsUpdate = true;
|
|
243
|
-
const image = nextTexture.image as HTMLImageElement;
|
|
244
|
-
const badgeHeight = BADGE_WIDTH * image.naturalHeight / image.naturalWidth;
|
|
245
|
-
front.scale.set(BADGE_WIDTH, badgeHeight, 1);
|
|
246
|
-
back.scale.copy(front.scale);
|
|
247
|
-
const nextGeometry = createBadgeGeometry(createBadgeShape(image));
|
|
248
|
-
edge.geometry = nextGeometry;
|
|
249
|
-
edgeGeometry.dispose();
|
|
250
|
-
edgeGeometry = nextGeometry;
|
|
251
|
-
texture.dispose();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
255
|
-
const width = Math.max(1, entry.contentRect.width);
|
|
256
|
-
const height = Math.max(1, entry.contentRect.height);
|
|
257
|
-
renderer.setSize(width, height, false);
|
|
258
|
-
camera.aspect = width / height;
|
|
259
|
-
camera.updateProjectionMatrix();
|
|
260
|
-
});
|
|
261
|
-
resizeObserver.observe(canvas);
|
|
262
|
-
|
|
263
|
-
let animationFrame = 0;
|
|
264
|
-
let celebrated = false;
|
|
265
|
-
let completed = false;
|
|
266
|
-
let textHidden = false;
|
|
267
|
-
let textRevealed = false;
|
|
268
|
-
const startTime = performance.now();
|
|
269
|
-
const materials = [edgeMaterial, faceMaterial];
|
|
270
|
-
|
|
271
|
-
const renderFrame = (time: number) => {
|
|
272
|
-
const elapsed = time - startTime;
|
|
273
|
-
const progress = Math.min(elapsed / ANIMATION_DURATION_MS, 1);
|
|
274
|
-
if (!celebrated && progress >= 0.28) {
|
|
275
|
-
celebrated = true;
|
|
276
|
-
onCelebrate();
|
|
277
|
-
}
|
|
278
|
-
if (!textRevealed && progress >= 0.52) {
|
|
279
|
-
textRevealed = true;
|
|
280
|
-
onRevealText();
|
|
281
|
-
}
|
|
282
|
-
if (textRevealed && !textHidden && progress >= 0.78) {
|
|
283
|
-
textHidden = true;
|
|
284
|
-
onHideText();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (reduceMotion) {
|
|
288
|
-
badge.position.y = 0.18;
|
|
289
|
-
badge.rotation.set(0, 0, 0);
|
|
290
|
-
badge.scale.setScalar(BADGE_RENDER_SCALE);
|
|
291
|
-
} else {
|
|
292
|
-
badge.position.y = interpolateKeyframes(
|
|
293
|
-
progress,
|
|
294
|
-
[0, 0.1, 0.25, 0.36, 0.44, 0.53, 1],
|
|
295
|
-
[-1.48, -1.48, 0.86, 0.02, 0.31, 0.18, 0.18],
|
|
296
|
-
);
|
|
297
|
-
const stretch = interpolateKeyframes(
|
|
298
|
-
progress,
|
|
299
|
-
[0, 0.1, 0.2, 0.28, 0.36, 0.44, 0.53, 1],
|
|
300
|
-
[0.68, 0.68, 1.34, 1.12, 0.88, 1.08, 1, 1],
|
|
301
|
-
);
|
|
302
|
-
badge.scale.set(
|
|
303
|
-
(2 - stretch) * BADGE_RENDER_SCALE,
|
|
304
|
-
stretch * BADGE_RENDER_SCALE,
|
|
305
|
-
BADGE_RENDER_SCALE,
|
|
306
|
-
);
|
|
307
|
-
const rotationProgress = easeOutCubic(Math.min(progress / 0.58, 1));
|
|
308
|
-
badge.rotation.y = -0.8 * (1 - rotationProgress) + rotationProgress * Math.PI * 4;
|
|
309
|
-
badge.rotation.x = Math.sin(progress * Math.PI * 5) * (1 - rotationProgress) * 0.38;
|
|
310
|
-
badge.rotation.z = Math.sin(progress * Math.PI * 3) * (1 - rotationProgress) * 0.16;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const opacity = interpolateKeyframes(
|
|
314
|
-
progress,
|
|
315
|
-
[0, 0.09, 0.14, 0.78, 1],
|
|
316
|
-
[0, 0, 1, 1, 0],
|
|
317
|
-
);
|
|
318
|
-
for (const material of materials) {
|
|
319
|
-
material.opacity = opacity;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
renderer.render(scene, camera);
|
|
323
|
-
if (progress < 1) {
|
|
324
|
-
animationFrame = requestAnimationFrame(renderFrame);
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (!completed) {
|
|
328
|
-
completed = true;
|
|
329
|
-
onComplete();
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
animationFrame = requestAnimationFrame(renderFrame);
|
|
334
|
-
|
|
335
|
-
return () => {
|
|
336
|
-
active = false;
|
|
337
|
-
cancelAnimationFrame(animationFrame);
|
|
338
|
-
resizeObserver.disconnect();
|
|
339
|
-
loadedTexture.dispose();
|
|
340
|
-
texture.dispose();
|
|
341
|
-
edgeGeometry.dispose();
|
|
342
|
-
faceGeometry.dispose();
|
|
343
|
-
edgeMaterial.dispose();
|
|
344
|
-
faceMaterial.dispose();
|
|
345
|
-
renderer.dispose();
|
|
346
|
-
};
|
|
347
|
-
}, [imageUrl, onCelebrate, onComplete, onHideText, onRevealText, reduceMotion]);
|
|
348
|
-
|
|
349
|
-
return <canvas ref={canvasRef} className="h-full w-full" aria-hidden="true" />;
|
|
350
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, type JSX } from "react";
|
|
2
|
-
import confetti from "canvas-confetti";
|
|
3
|
-
|
|
4
|
-
export interface AchievementPromotionConfettiProps {
|
|
5
|
-
triggerToken: number;
|
|
6
|
-
colors?: readonly string[];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const DEFAULT_COLORS = ["#f4d58a", "#d79a3b", "#b91c1c", "#f5e6c8"];
|
|
10
|
-
|
|
11
|
-
export function AchievementPromotionConfetti({
|
|
12
|
-
triggerToken,
|
|
13
|
-
colors = DEFAULT_COLORS,
|
|
14
|
-
}: AchievementPromotionConfettiProps): JSX.Element {
|
|
15
|
-
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
16
|
-
const confettiRef = useRef<ReturnType<typeof confetti.create> | null>(null);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const canvas = canvasRef.current;
|
|
20
|
-
if (!canvas) return;
|
|
21
|
-
const instance = confetti.create(canvas, {
|
|
22
|
-
disableForReducedMotion: true,
|
|
23
|
-
resize: true,
|
|
24
|
-
useWorker: false,
|
|
25
|
-
});
|
|
26
|
-
confettiRef.current = instance;
|
|
27
|
-
return () => {
|
|
28
|
-
instance.reset();
|
|
29
|
-
confettiRef.current = null;
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (triggerToken === 0) return;
|
|
35
|
-
const instance = confettiRef.current;
|
|
36
|
-
if (!instance) return;
|
|
37
|
-
|
|
38
|
-
const sharedOptions: confetti.Options = {
|
|
39
|
-
colors: [...colors],
|
|
40
|
-
decay: 0.94,
|
|
41
|
-
disableForReducedMotion: true,
|
|
42
|
-
gravity: 0.72,
|
|
43
|
-
particleCount: 64,
|
|
44
|
-
scalar: 0.9,
|
|
45
|
-
shapes: ["square"],
|
|
46
|
-
spread: 58,
|
|
47
|
-
startVelocity: 46,
|
|
48
|
-
ticks: 240,
|
|
49
|
-
};
|
|
50
|
-
void instance({
|
|
51
|
-
...sharedOptions,
|
|
52
|
-
angle: 58,
|
|
53
|
-
drift: 0.08,
|
|
54
|
-
origin: { x: 0.16, y: 0.48 },
|
|
55
|
-
});
|
|
56
|
-
void instance({
|
|
57
|
-
...sharedOptions,
|
|
58
|
-
angle: 122,
|
|
59
|
-
drift: -0.08,
|
|
60
|
-
origin: { x: 0.84, y: 0.48 },
|
|
61
|
-
});
|
|
62
|
-
}, [triggerToken, colors]);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<canvas
|
|
66
|
-
ref={canvasRef}
|
|
67
|
-
aria-hidden="true"
|
|
68
|
-
className="pointer-events-none absolute inset-0 h-full w-full"
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties, JSX } from "react";
|
|
2
|
-
|
|
3
|
-
export interface AchievementTitleLayout {
|
|
4
|
-
top: number;
|
|
5
|
-
left: number;
|
|
6
|
-
width: number;
|
|
7
|
-
aspectRatio: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AchievementTitleProps {
|
|
11
|
-
title: string;
|
|
12
|
-
layout: AchievementTitleLayout;
|
|
13
|
-
titleImageUrl: string;
|
|
14
|
-
titleTextOffsetY: number;
|
|
15
|
-
titleColor?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function AchievementTitle({
|
|
19
|
-
title,
|
|
20
|
-
layout,
|
|
21
|
-
titleImageUrl,
|
|
22
|
-
titleTextOffsetY,
|
|
23
|
-
titleColor = "#f4d58a",
|
|
24
|
-
}: AchievementTitleProps): JSX.Element {
|
|
25
|
-
const layoutStyle: CSSProperties = {
|
|
26
|
-
top: layout.top,
|
|
27
|
-
left: layout.left,
|
|
28
|
-
width: layout.width,
|
|
29
|
-
aspectRatio: layout.aspectRatio,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="relative z-30 mx-auto flex max-w-full items-center justify-center" style={layoutStyle}>
|
|
34
|
-
<img
|
|
35
|
-
aria-hidden="true"
|
|
36
|
-
alt=""
|
|
37
|
-
draggable={false}
|
|
38
|
-
src={titleImageUrl}
|
|
39
|
-
className="pointer-events-none absolute inset-0 h-full w-full select-none object-contain"
|
|
40
|
-
/>
|
|
41
|
-
<h1
|
|
42
|
-
className="relative px-20 pb-1 text-center text-[20px] font-bold"
|
|
43
|
-
style={{
|
|
44
|
-
color: titleColor,
|
|
45
|
-
transform: `translateY(${titleTextOffsetY}px)`,
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
{title}
|
|
49
|
-
</h1>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
AchievementCurtainSideLayout,
|
|
3
|
-
AchievementCurtainsAssets,
|
|
4
|
-
AchievementCurtainsLayout,
|
|
5
|
-
AchievementCurtainsProps,
|
|
6
|
-
} from "./AchievementCurtains";
|
|
7
|
-
export { AchievementCurtains } from "./AchievementCurtains";
|
|
8
|
-
export type { AchievementPromotionBadge3DProps } from "./AchievementPromotionBadge3D";
|
|
9
|
-
export { AchievementPromotionBadge3D } from "./AchievementPromotionBadge3D";
|
|
10
|
-
export type { AchievementPromotionConfettiProps } from "./AchievementPromotionConfetti";
|
|
11
|
-
export { AchievementPromotionConfetti } from "./AchievementPromotionConfetti";
|
|
12
|
-
export type { AchievementTitleLayout, AchievementTitleProps } from "./AchievementTitle";
|
|
13
|
-
export { AchievementTitle } from "./AchievementTitle";
|