@hyperframes/studio 0.6.0-alpha.8 → 0.6.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/dist/assets/{hyperframes-player-DjsVzYFP.js → hyperframes-player-DOFETgjy.js} +1 -1
- package/dist/assets/index-D1JDq7Gg.css +1 -0
- package/dist/assets/index-DUqUmaoH.js +117 -0
- package/dist/favicon.svg +14 -0
- package/dist/index.html +3 -2
- package/package.json +9 -9
- package/src/App.tsx +428 -4299
- package/src/components/AskAgentModal.tsx +120 -0
- package/src/components/StudioHeader.tsx +133 -0
- package/src/components/StudioLeftSidebar.tsx +125 -0
- package/src/components/StudioPreviewArea.tsx +163 -0
- package/src/components/StudioRightPanel.tsx +198 -0
- package/src/components/TimelineToolbar.tsx +89 -0
- package/src/components/editor/DomEditOverlay.tsx +15 -1
- package/src/components/editor/PropertyPanel.test.ts +0 -49
- package/src/components/editor/PropertyPanel.tsx +132 -2763
- package/src/components/editor/domEditing.ts +38 -5
- package/src/components/editor/manualEditingAvailability.test.ts +2 -2
- package/src/components/editor/manualEditingAvailability.ts +1 -1
- package/src/components/editor/manualEdits.ts +32 -0
- package/src/components/editor/propertyPanelColor.tsx +371 -0
- package/src/components/editor/propertyPanelFill.tsx +421 -0
- package/src/components/editor/propertyPanelFont.tsx +455 -0
- package/src/components/editor/propertyPanelHelpers.ts +401 -0
- package/src/components/editor/propertyPanelPrimitives.tsx +357 -0
- package/src/components/editor/propertyPanelSections.tsx +453 -0
- package/src/components/editor/propertyPanelStyleSections.tsx +411 -0
- package/src/components/nle/NLELayout.tsx +8 -11
- package/src/components/nle/NLEPreview.tsx +3 -0
- package/src/components/renders/RenderQueue.tsx +102 -31
- package/src/components/renders/useRenderQueue.ts +8 -2
- package/src/components/sidebar/LeftSidebar.tsx +186 -186
- package/src/contexts/DomEditContext.tsx +137 -0
- package/src/contexts/FileManagerContext.tsx +110 -0
- package/src/contexts/PanelLayoutContext.tsx +68 -0
- package/src/contexts/StudioContext.tsx +135 -0
- package/src/hooks/useAppHotkeys.ts +326 -0
- package/src/hooks/useAskAgentModal.ts +162 -0
- package/src/hooks/useCaptionDetection.ts +132 -0
- package/src/hooks/useCompositionDimensions.ts +25 -0
- package/src/hooks/useConsoleErrorCapture.ts +60 -0
- package/src/hooks/useDomEditCommits.ts +437 -0
- package/src/hooks/useDomEditSession.ts +342 -0
- package/src/hooks/useDomEditTextCommits.ts +330 -0
- package/src/hooks/useDomSelection.ts +398 -0
- package/src/hooks/useFileManager.ts +431 -0
- package/src/hooks/useFrameCapture.ts +77 -0
- package/src/hooks/useLintModal.ts +35 -0
- package/src/hooks/useManifestPersistence.ts +492 -0
- package/src/hooks/usePanelLayout.ts +68 -0
- package/src/hooks/usePreviewInteraction.ts +153 -0
- package/src/hooks/useRenderClipContent.ts +124 -0
- package/src/hooks/useTimelineEditing.ts +472 -0
- package/src/player/components/Player.tsx +35 -4
- package/src/player/components/Timeline.test.ts +0 -8
- package/src/player/components/Timeline.tsx +10 -103
- package/src/player/components/TimelineClip.tsx +9 -244
- package/src/player/hooks/useTimelinePlayer.ts +140 -103
- package/src/utils/domEditHelpers.ts +50 -0
- package/src/utils/studioFontHelpers.ts +83 -0
- package/src/utils/studioHelpers.ts +214 -0
- package/src/utils/studioPreviewHelpers.ts +185 -0
- package/src/utils/timelineDiscovery.ts +1 -1
- package/dist/assets/index-14zH9lqh.css +0 -1
- package/dist/assets/index-ClYcrksa.js +0 -108
- package/src/player/components/TimelineClip.test.ts +0 -92
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Plus, Type } from "../../icons/SystemIcons";
|
|
3
|
+
import { isTextEditableSelection, type DomEditSelection } from "./domEditing";
|
|
4
|
+
import type { ImportedFontAsset } from "./fontAssets";
|
|
5
|
+
import { FIELD, LABEL, normalizeTextMetricValue, RESPONSIVE_GRID } from "./propertyPanelHelpers";
|
|
6
|
+
import { MetricField, Section, SelectField } from "./propertyPanelPrimitives";
|
|
7
|
+
import { ColorField } from "./propertyPanelColor";
|
|
8
|
+
import { FontFamilyField } from "./propertyPanelFont";
|
|
9
|
+
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
/* Text helpers (used only by text section components) */
|
|
12
|
+
/* ------------------------------------------------------------------ */
|
|
13
|
+
|
|
14
|
+
function formatTextFieldPreview(value: string): string {
|
|
15
|
+
const collapsed = value.trim().replace(/\s+/g, " ");
|
|
16
|
+
if (collapsed.length <= 56) return collapsed;
|
|
17
|
+
return `${collapsed.slice(0, 55)}…`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getTextFieldColor(
|
|
21
|
+
field: { computedStyles: Record<string, string> },
|
|
22
|
+
inheritedStyles: Record<string, string>,
|
|
23
|
+
): string {
|
|
24
|
+
return field.computedStyles.color || inheritedStyles.color || "rgb(0, 0, 0)";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getTextStyleValue(
|
|
28
|
+
field: { computedStyles: Record<string, string> },
|
|
29
|
+
inheritedStyles: Record<string, string>,
|
|
30
|
+
property: string,
|
|
31
|
+
fallback: string,
|
|
32
|
+
): string {
|
|
33
|
+
return field.computedStyles[property] || inheritedStyles[property] || fallback;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const ALL_WEIGHTS = ["100", "200", "300", "400", "500", "600", "700", "800", "900"];
|
|
37
|
+
const WEIGHT_LABELS: Record<string, string> = {
|
|
38
|
+
"100": "100 · Thin",
|
|
39
|
+
"200": "200 · Extra Light",
|
|
40
|
+
"300": "300 · Light",
|
|
41
|
+
"400": "400 · Regular",
|
|
42
|
+
"500": "500 · Medium",
|
|
43
|
+
"600": "600 · Semi Bold",
|
|
44
|
+
"700": "700 · Bold",
|
|
45
|
+
"800": "800 · Extra Bold",
|
|
46
|
+
"900": "900 · Black",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function detectAvailableWeights(fontFamily: string): string[] {
|
|
50
|
+
const fonts = document.fonts;
|
|
51
|
+
if (!fonts) return ALL_WEIGHTS;
|
|
52
|
+
const family = fontFamily.split(",")[0]?.trim().replace(/['"]/g, "");
|
|
53
|
+
if (!family) return ALL_WEIGHTS;
|
|
54
|
+
const available: string[] = [];
|
|
55
|
+
for (const w of ALL_WEIGHTS) {
|
|
56
|
+
if (fonts.check(`${w} 16px "${family}"`)) available.push(w);
|
|
57
|
+
}
|
|
58
|
+
return available.length > 0 ? available : ALL_WEIGHTS;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function TextAreaField({
|
|
62
|
+
label,
|
|
63
|
+
value,
|
|
64
|
+
disabled,
|
|
65
|
+
autoFocus,
|
|
66
|
+
onCommit,
|
|
67
|
+
}: {
|
|
68
|
+
label: string;
|
|
69
|
+
value: string;
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
autoFocus?: boolean;
|
|
72
|
+
onCommit: (nextValue: string) => void;
|
|
73
|
+
}) {
|
|
74
|
+
const [draft, setDraft] = useState(value);
|
|
75
|
+
const textareaRef = useRef<HTMLTextAreaElement | null>(null);
|
|
76
|
+
const commitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
77
|
+
const focusedRef = useRef(false);
|
|
78
|
+
const valueRef = useRef(value);
|
|
79
|
+
valueRef.current = value;
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (focusedRef.current) return;
|
|
83
|
+
setDraft(value);
|
|
84
|
+
}, [value]);
|
|
85
|
+
useEffect(
|
|
86
|
+
() => () => {
|
|
87
|
+
if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
|
|
88
|
+
},
|
|
89
|
+
[],
|
|
90
|
+
);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!autoFocus) return;
|
|
93
|
+
textareaRef.current?.focus();
|
|
94
|
+
}, [autoFocus]);
|
|
95
|
+
|
|
96
|
+
const commitDraft = (d: string) => {
|
|
97
|
+
if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
|
|
98
|
+
if (d !== valueRef.current) onCommit(d);
|
|
99
|
+
};
|
|
100
|
+
const scheduleCommit = (d: string) => {
|
|
101
|
+
if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
|
|
102
|
+
commitTimerRef.current = setTimeout(() => {
|
|
103
|
+
if (d !== valueRef.current) onCommit(d);
|
|
104
|
+
}, 120);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<label className="grid min-w-0 gap-1.5">
|
|
109
|
+
<span className={LABEL}>{label}</span>
|
|
110
|
+
<div className={FIELD}>
|
|
111
|
+
<textarea
|
|
112
|
+
ref={textareaRef}
|
|
113
|
+
value={draft}
|
|
114
|
+
disabled={disabled}
|
|
115
|
+
rows={4}
|
|
116
|
+
onFocus={() => {
|
|
117
|
+
focusedRef.current = true;
|
|
118
|
+
}}
|
|
119
|
+
onChange={(e) => {
|
|
120
|
+
setDraft(e.target.value);
|
|
121
|
+
scheduleCommit(e.target.value);
|
|
122
|
+
}}
|
|
123
|
+
onBlur={() => {
|
|
124
|
+
focusedRef.current = false;
|
|
125
|
+
commitDraft(draft);
|
|
126
|
+
}}
|
|
127
|
+
className="w-full resize-none bg-transparent text-[11px] font-medium text-neutral-100 outline-none disabled:cursor-not-allowed disabled:text-neutral-600"
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
</label>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function FontWeightField({
|
|
135
|
+
value,
|
|
136
|
+
disabled,
|
|
137
|
+
fontFamily,
|
|
138
|
+
onCommit,
|
|
139
|
+
}: {
|
|
140
|
+
value: string;
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
fontFamily?: string;
|
|
143
|
+
onCommit: (nextValue: string) => void;
|
|
144
|
+
}) {
|
|
145
|
+
const options = fontFamily ? detectAvailableWeights(fontFamily) : ALL_WEIGHTS;
|
|
146
|
+
const displayOptions = value && !options.includes(value) ? [value, ...options] : options;
|
|
147
|
+
return (
|
|
148
|
+
<div className={FIELD}>
|
|
149
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
150
|
+
<span className="flex-shrink-0 text-[11px] font-medium text-neutral-500">Weight</span>
|
|
151
|
+
<select
|
|
152
|
+
value={value}
|
|
153
|
+
disabled={disabled}
|
|
154
|
+
onChange={(e) => onCommit(e.target.value)}
|
|
155
|
+
className="min-w-0 w-full appearance-none bg-transparent text-[11px] font-medium text-neutral-100 outline-none disabled:cursor-not-allowed disabled:text-neutral-600"
|
|
156
|
+
>
|
|
157
|
+
{displayOptions.map((o) => (
|
|
158
|
+
<option key={o} value={o}>
|
|
159
|
+
{WEIGHT_LABELS[o] ?? o}
|
|
160
|
+
</option>
|
|
161
|
+
))}
|
|
162
|
+
</select>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function AdvancedTextControls({
|
|
169
|
+
field,
|
|
170
|
+
inheritedStyles,
|
|
171
|
+
disabled,
|
|
172
|
+
onCommit,
|
|
173
|
+
}: {
|
|
174
|
+
field: DomEditSelection["textFields"][number];
|
|
175
|
+
inheritedStyles: Record<string, string>;
|
|
176
|
+
disabled?: boolean;
|
|
177
|
+
onCommit: (property: string, value: string) => void;
|
|
178
|
+
}) {
|
|
179
|
+
return (
|
|
180
|
+
<div className="space-y-4">
|
|
181
|
+
<div className={RESPONSIVE_GRID}>
|
|
182
|
+
<SelectField
|
|
183
|
+
label="Line"
|
|
184
|
+
value={getTextStyleValue(field, inheritedStyles, "line-height", "normal")}
|
|
185
|
+
disabled={disabled}
|
|
186
|
+
options={["normal", "1", "1.1", "1.2", "1.25", "1.3", "1.4", "1.5", "1.6", "1.75", "2"]}
|
|
187
|
+
onChange={(n) => onCommit("line-height", normalizeTextMetricValue("line-height", n))}
|
|
188
|
+
/>
|
|
189
|
+
<SelectField
|
|
190
|
+
label="Track"
|
|
191
|
+
value={getTextStyleValue(field, inheritedStyles, "letter-spacing", "0px")}
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
options={[
|
|
194
|
+
"0px",
|
|
195
|
+
"-0.05em",
|
|
196
|
+
"-0.04em",
|
|
197
|
+
"-0.03em",
|
|
198
|
+
"-0.02em",
|
|
199
|
+
"-0.01em",
|
|
200
|
+
"0em",
|
|
201
|
+
"0.01em",
|
|
202
|
+
"0.02em",
|
|
203
|
+
"0.03em",
|
|
204
|
+
"0.05em",
|
|
205
|
+
"0.1em",
|
|
206
|
+
"0.15em",
|
|
207
|
+
"0.2em",
|
|
208
|
+
]}
|
|
209
|
+
onChange={(n) =>
|
|
210
|
+
onCommit("letter-spacing", normalizeTextMetricValue("letter-spacing", n))
|
|
211
|
+
}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
<div className={RESPONSIVE_GRID}>
|
|
215
|
+
<SelectField
|
|
216
|
+
label="Align"
|
|
217
|
+
value={getTextStyleValue(field, inheritedStyles, "text-align", "start")}
|
|
218
|
+
disabled={disabled}
|
|
219
|
+
onChange={(n) => onCommit("text-align", n)}
|
|
220
|
+
options={["start", "left", "center", "right", "justify", "end"]}
|
|
221
|
+
/>
|
|
222
|
+
<SelectField
|
|
223
|
+
label="Case"
|
|
224
|
+
value={getTextStyleValue(field, inheritedStyles, "text-transform", "none")}
|
|
225
|
+
disabled={disabled}
|
|
226
|
+
onChange={(n) => onCommit("text-transform", n)}
|
|
227
|
+
options={["none", "uppercase", "lowercase", "capitalize"]}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
<SelectField
|
|
231
|
+
label="Style"
|
|
232
|
+
value={getTextStyleValue(field, inheritedStyles, "font-style", "normal")}
|
|
233
|
+
disabled={disabled}
|
|
234
|
+
onChange={(n) => onCommit("font-style", n)}
|
|
235
|
+
options={["normal", "italic"]}
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* ------------------------------------------------------------------ */
|
|
242
|
+
/* Text section */
|
|
243
|
+
/* ------------------------------------------------------------------ */
|
|
244
|
+
|
|
245
|
+
function TextFieldEditor({
|
|
246
|
+
field,
|
|
247
|
+
styles,
|
|
248
|
+
fontAssets,
|
|
249
|
+
onImportFonts,
|
|
250
|
+
showRemove,
|
|
251
|
+
onSetText,
|
|
252
|
+
onSetTextFieldStyle,
|
|
253
|
+
onRemoveTextField,
|
|
254
|
+
}: {
|
|
255
|
+
field: DomEditSelection["textFields"][number];
|
|
256
|
+
styles: Record<string, string>;
|
|
257
|
+
fontAssets: ImportedFontAsset[];
|
|
258
|
+
onImportFonts?: (files: FileList | File[]) => Promise<ImportedFontAsset[]>;
|
|
259
|
+
showRemove: boolean;
|
|
260
|
+
onSetText: (value: string, fieldKey?: string) => void;
|
|
261
|
+
onSetTextFieldStyle: (fieldKey: string, property: string, value: string) => void;
|
|
262
|
+
onRemoveTextField: (fieldKey: string) => void;
|
|
263
|
+
}) {
|
|
264
|
+
return (
|
|
265
|
+
<div className="space-y-4 rounded-xl border border-neutral-800 bg-neutral-900/60 p-3">
|
|
266
|
+
<div className={showRemove ? "flex min-w-0 items-center justify-between gap-2" : "min-w-0"}>
|
|
267
|
+
<div className="min-w-0">
|
|
268
|
+
<div className="truncate text-[11px] font-medium text-neutral-100">
|
|
269
|
+
{formatTextFieldPreview(field.value) || "Text"}
|
|
270
|
+
</div>
|
|
271
|
+
<div className="text-[10px] uppercase tracking-[0.12em] text-neutral-500">
|
|
272
|
+
{field.tagName}
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
{showRemove && (
|
|
276
|
+
<button
|
|
277
|
+
type="button"
|
|
278
|
+
onClick={() => onRemoveTextField(field.key)}
|
|
279
|
+
className="inline-flex h-7 flex-shrink-0 items-center rounded-lg border border-neutral-700 bg-neutral-950 px-2.5 text-[11px] font-medium text-neutral-300 transition-colors hover:border-neutral-600 hover:text-white"
|
|
280
|
+
>
|
|
281
|
+
Remove
|
|
282
|
+
</button>
|
|
283
|
+
)}
|
|
284
|
+
</div>
|
|
285
|
+
<TextAreaField
|
|
286
|
+
key={field.key}
|
|
287
|
+
label="Content"
|
|
288
|
+
value={field.value}
|
|
289
|
+
disabled={false}
|
|
290
|
+
autoFocus={showRemove}
|
|
291
|
+
onCommit={(next) => onSetText(next, field.key)}
|
|
292
|
+
/>
|
|
293
|
+
<ColorField
|
|
294
|
+
label="Text color"
|
|
295
|
+
value={getTextFieldColor(field, styles)}
|
|
296
|
+
disabled={false}
|
|
297
|
+
onCommit={(next) => onSetTextFieldStyle(field.key, "color", next)}
|
|
298
|
+
/>
|
|
299
|
+
<div className={RESPONSIVE_GRID}>
|
|
300
|
+
<MetricField
|
|
301
|
+
label="Size"
|
|
302
|
+
value={field.computedStyles["font-size"] || styles["font-size"] || "16px"}
|
|
303
|
+
disabled={false}
|
|
304
|
+
liveCommit
|
|
305
|
+
onCommit={(next) => onSetTextFieldStyle(field.key, "font-size", next)}
|
|
306
|
+
/>
|
|
307
|
+
<FontWeightField
|
|
308
|
+
value={field.computedStyles["font-weight"] || styles["font-weight"] || "400"}
|
|
309
|
+
fontFamily={field.computedStyles["font-family"] || styles["font-family"]}
|
|
310
|
+
disabled={false}
|
|
311
|
+
onCommit={(next) => onSetTextFieldStyle(field.key, "font-weight", next)}
|
|
312
|
+
/>
|
|
313
|
+
</div>
|
|
314
|
+
<FontFamilyField
|
|
315
|
+
value={field.computedStyles["font-family"] || styles["font-family"] || "inherit"}
|
|
316
|
+
disabled={false}
|
|
317
|
+
importedFonts={fontAssets}
|
|
318
|
+
onImportFonts={onImportFonts}
|
|
319
|
+
onCommit={(next) => onSetTextFieldStyle(field.key, "font-family", next)}
|
|
320
|
+
/>
|
|
321
|
+
<AdvancedTextControls
|
|
322
|
+
field={field}
|
|
323
|
+
inheritedStyles={styles}
|
|
324
|
+
disabled={false}
|
|
325
|
+
onCommit={(property, value) => onSetTextFieldStyle(field.key, property, value)}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function TextSection({
|
|
332
|
+
element,
|
|
333
|
+
styles,
|
|
334
|
+
fontAssets,
|
|
335
|
+
onImportFonts,
|
|
336
|
+
onSetText,
|
|
337
|
+
onSetTextFieldStyle,
|
|
338
|
+
onAddTextField,
|
|
339
|
+
onRemoveTextField,
|
|
340
|
+
}: {
|
|
341
|
+
element: DomEditSelection;
|
|
342
|
+
styles: Record<string, string>;
|
|
343
|
+
fontAssets: ImportedFontAsset[];
|
|
344
|
+
onImportFonts?: (files: FileList | File[]) => Promise<ImportedFontAsset[]>;
|
|
345
|
+
onSetText: (value: string, fieldKey?: string) => void;
|
|
346
|
+
onSetTextFieldStyle: (fieldKey: string, property: string, value: string) => void;
|
|
347
|
+
onAddTextField: (afterFieldKey?: string) => string | Promise<string | null> | null;
|
|
348
|
+
onRemoveTextField: (fieldKey: string) => void;
|
|
349
|
+
}) {
|
|
350
|
+
const hasTextControls = isTextEditableSelection(element);
|
|
351
|
+
const [activeTextFieldKey, setActiveTextFieldKey] = useState<string | null>(
|
|
352
|
+
element.textFields[0]?.key ?? null,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
useEffect(() => {
|
|
356
|
+
const nextFields = element.textFields;
|
|
357
|
+
setActiveTextFieldKey((current) => {
|
|
358
|
+
if (current && nextFields.some((field) => field.key === current)) return current;
|
|
359
|
+
return nextFields[0]?.key ?? null;
|
|
360
|
+
});
|
|
361
|
+
}, [element.id, element.selector, element.textFields]);
|
|
362
|
+
|
|
363
|
+
if (!hasTextControls) return null;
|
|
364
|
+
|
|
365
|
+
const textFields = element.textFields;
|
|
366
|
+
const activeField = textFields.find((field) => field.key === activeTextFieldKey) ?? textFields[0];
|
|
367
|
+
if (!activeField) return null;
|
|
368
|
+
|
|
369
|
+
if (textFields.length === 1) {
|
|
370
|
+
return (
|
|
371
|
+
<Section title="Text" icon={<Type size={15} />}>
|
|
372
|
+
<TextFieldEditor
|
|
373
|
+
field={activeField}
|
|
374
|
+
styles={styles}
|
|
375
|
+
fontAssets={fontAssets}
|
|
376
|
+
onImportFonts={onImportFonts}
|
|
377
|
+
showRemove={false}
|
|
378
|
+
onSetText={onSetText}
|
|
379
|
+
onSetTextFieldStyle={onSetTextFieldStyle}
|
|
380
|
+
onRemoveTextField={onRemoveTextField}
|
|
381
|
+
/>
|
|
382
|
+
</Section>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return (
|
|
387
|
+
<Section title="Text" icon={<Type size={15} />}>
|
|
388
|
+
<div className="space-y-4">
|
|
389
|
+
<div className="grid gap-1.5">
|
|
390
|
+
<div className="flex min-w-0 flex-wrap items-center justify-between gap-2">
|
|
391
|
+
<span className={LABEL}>Text layers</span>
|
|
392
|
+
<button
|
|
393
|
+
type="button"
|
|
394
|
+
onClick={() => {
|
|
395
|
+
void Promise.resolve(onAddTextField(activeField.key)).then((nextKey) => {
|
|
396
|
+
if (nextKey) setActiveTextFieldKey(nextKey);
|
|
397
|
+
});
|
|
398
|
+
}}
|
|
399
|
+
className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-lg border border-neutral-700 bg-neutral-950 px-2.5 text-[11px] font-medium text-neutral-300 transition-colors hover:border-neutral-600 hover:text-white"
|
|
400
|
+
>
|
|
401
|
+
<Plus size={12} className="flex-shrink-0" />
|
|
402
|
+
<span className="truncate">Add text</span>
|
|
403
|
+
</button>
|
|
404
|
+
</div>
|
|
405
|
+
<div className="grid gap-2">
|
|
406
|
+
{textFields.map((field, index) => {
|
|
407
|
+
const active = field.key === activeField.key;
|
|
408
|
+
return (
|
|
409
|
+
<button
|
|
410
|
+
key={field.key}
|
|
411
|
+
type="button"
|
|
412
|
+
onClick={() => setActiveTextFieldKey(field.key)}
|
|
413
|
+
className={`min-w-0 w-full rounded-xl border px-3 py-2 text-left transition-colors ${
|
|
414
|
+
active
|
|
415
|
+
? "border-studio-accent/50 bg-studio-accent/10"
|
|
416
|
+
: "border-neutral-800 bg-neutral-900/80 hover:border-neutral-700 hover:bg-neutral-900"
|
|
417
|
+
}`}
|
|
418
|
+
>
|
|
419
|
+
<div className="flex min-w-0 items-center justify-between gap-2">
|
|
420
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
421
|
+
<span
|
|
422
|
+
className="h-4 w-4 flex-shrink-0 rounded border border-neutral-700 bg-neutral-950"
|
|
423
|
+
style={{ backgroundColor: getTextFieldColor(field, styles) }}
|
|
424
|
+
/>
|
|
425
|
+
<span className="min-w-0 truncate text-[11px] font-medium text-neutral-100">
|
|
426
|
+
{formatTextFieldPreview(field.value) || `Text ${index + 1}`}
|
|
427
|
+
</span>
|
|
428
|
+
</div>
|
|
429
|
+
<span className="flex-shrink-0 rounded-md border border-neutral-700 bg-neutral-950 px-1.5 py-0.5 text-[10px] uppercase tracking-[0.12em] text-neutral-500">
|
|
430
|
+
{field.tagName}
|
|
431
|
+
</span>
|
|
432
|
+
</div>
|
|
433
|
+
</button>
|
|
434
|
+
);
|
|
435
|
+
})}
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
<TextFieldEditor
|
|
439
|
+
field={activeField}
|
|
440
|
+
styles={styles}
|
|
441
|
+
fontAssets={fontAssets}
|
|
442
|
+
onImportFonts={onImportFonts}
|
|
443
|
+
showRemove={true}
|
|
444
|
+
onSetText={onSetText}
|
|
445
|
+
onSetTextFieldStyle={onSetTextFieldStyle}
|
|
446
|
+
onRemoveTextField={onRemoveTextField}
|
|
447
|
+
/>
|
|
448
|
+
</div>
|
|
449
|
+
</Section>
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export { StyleSections } from "./propertyPanelStyleSections";
|