@hyperframes/studio 0.7.58 → 0.7.59
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-CtTDO63S.js → hyperframes-player-Bm07FLkl.js} +1 -1
- package/dist/assets/{index-C47jAC3Q.js → index-B995FG46.js} +1 -1
- package/dist/assets/index-CrkAdJkb.js +426 -0
- package/dist/assets/index-Dj5p8U_A.css +1 -0
- package/dist/assets/{index-DeQPzqwH.js → index-FvzmPhfG.js} +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.html +2 -2
- package/dist/index.js +13514 -8528
- package/dist/index.js.map +1 -1
- package/dist/styles/tailwind-preset.d.ts +5 -0
- package/dist/styles/tailwind-preset.js +8 -1
- package/dist/styles/tailwind-preset.js.map +1 -1
- package/package.json +7 -7
- package/src/App.tsx +3 -3
- package/src/components/DesignPanelPromoteProvider.tsx +15 -2
- package/src/components/StudioRightPanel.tsx +29 -51
- package/src/components/editor/AnimationCard.test.tsx +134 -0
- package/src/components/editor/AnimationCard.tsx +19 -4
- package/src/components/editor/ArcPathControls.tsx +1 -0
- package/src/components/editor/GestureRecordControl.tsx +7 -1
- package/src/components/editor/GsapAnimationSection.tsx +109 -14
- package/src/components/editor/InspectorHeaderActions.tsx +42 -4
- package/src/components/editor/PropertyPanel.test.tsx +948 -0
- package/src/components/editor/PropertyPanel.tsx +144 -148
- package/src/components/editor/PropertyPanelEmptyState.test.tsx +74 -0
- package/src/components/editor/PropertyPanelEmptyState.tsx +179 -1
- package/src/components/editor/PropertyPanelFlat.tsx +580 -0
- package/src/components/editor/PropertyPanelFlatFooter.test.tsx +83 -0
- package/src/components/editor/PropertyPanelFlatFooter.tsx +73 -0
- package/src/components/editor/PropertyPanelFlatHeader.test.tsx +79 -0
- package/src/components/editor/PropertyPanelFlatHeader.tsx +112 -0
- package/src/components/editor/gsapAnimationCallbacks.ts +27 -0
- package/src/components/editor/gsapLivePreview.ts +34 -0
- package/src/components/editor/manualEditingAvailability.test.ts +10 -0
- package/src/components/editor/manualEditingAvailability.ts +9 -0
- package/src/components/editor/propertyPanel3dTransform.tsx +5 -0
- package/src/components/editor/propertyPanelColor.test.tsx +28 -0
- package/src/components/editor/propertyPanelColor.tsx +31 -1
- package/src/components/editor/propertyPanelColorGradingControls.tsx +11 -2
- package/src/components/editor/propertyPanelColorGradingSection.tsx +45 -365
- package/src/components/editor/propertyPanelColorGradingSlider.tsx +19 -5
- package/src/components/editor/propertyPanelFill.tsx +22 -5
- package/src/components/editor/propertyPanelFlatColorGradingSection.test.tsx +622 -0
- package/src/components/editor/propertyPanelFlatColorGradingSection.tsx +570 -0
- package/src/components/editor/propertyPanelFlatLayoutSection.test.tsx +293 -0
- package/src/components/editor/propertyPanelFlatLayoutSection.tsx +383 -0
- package/src/components/editor/propertyPanelFlatMaskInsetRows.tsx +102 -0
- package/src/components/editor/propertyPanelFlatMediaSection.test.tsx +436 -0
- package/src/components/editor/propertyPanelFlatMediaSection.tsx +286 -0
- package/src/components/editor/propertyPanelFlatMotionSection.test.tsx +272 -0
- package/src/components/editor/propertyPanelFlatMotionSection.tsx +315 -0
- package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +1174 -0
- package/src/components/editor/propertyPanelFlatPrimitives.tsx +563 -0
- package/src/components/editor/propertyPanelFlatSelectRow.tsx +101 -0
- package/src/components/editor/propertyPanelFlatStyleHelpers.test.ts +23 -0
- package/src/components/editor/propertyPanelFlatStyleHelpers.ts +27 -0
- package/src/components/editor/propertyPanelFlatStyleSections.test.tsx +598 -0
- package/src/components/editor/propertyPanelFlatStyleSections.tsx +516 -0
- package/src/components/editor/propertyPanelFlatTextSection.test.tsx +465 -0
- package/src/components/editor/propertyPanelFlatTextSection.tsx +407 -0
- package/src/components/editor/propertyPanelFlatTimingDerivation.test.ts +71 -0
- package/src/components/editor/propertyPanelFlatTimingDerivation.ts +59 -0
- package/src/components/editor/propertyPanelFlatToggle.test.tsx +63 -0
- package/src/components/editor/propertyPanelFlatToggle.tsx +53 -0
- package/src/components/editor/propertyPanelFont.test.tsx +30 -0
- package/src/components/editor/propertyPanelFont.tsx +136 -95
- package/src/components/editor/propertyPanelHelpers.ts +73 -0
- package/src/components/editor/propertyPanelInputCoverage.test.tsx +587 -0
- package/src/components/editor/propertyPanelMediaSection.tsx +10 -0
- package/src/components/editor/propertyPanelPrimitives.tsx +60 -29
- package/src/components/editor/propertyPanelSections.test.tsx +161 -0
- package/src/components/editor/propertyPanelSections.tsx +154 -90
- package/src/components/editor/propertyPanelStyleSections.tsx +12 -1
- package/src/components/editor/propertyPanelTimingSection.tsx +1 -1
- package/src/components/editor/propertyPanelTypes.ts +14 -1
- package/src/components/editor/propertyPanelValueTier.test.ts +32 -0
- package/src/components/editor/propertyPanelValueTier.ts +28 -0
- package/src/components/editor/useColorGradingController.test.ts +418 -0
- package/src/components/editor/useColorGradingController.ts +596 -0
- package/src/components/panels/VariablesPanel.tsx +4 -0
- package/src/components/sidebar/CompositionsTab.test.ts +28 -2
- package/src/components/sidebar/CompositionsTab.tsx +3 -1
- package/src/components/storyboard/FramePoster.tsx +24 -4
- package/src/components/storyboard/StoryboardFrameFocus.tsx +4 -0
- package/src/components/storyboard/StoryboardFrameTile.tsx +30 -1
- package/src/components/storyboard/StoryboardGrid.tsx +23 -1
- package/src/components/storyboard/StoryboardLoaded.tsx +58 -2
- package/src/components/storyboard/StoryboardView.tsx +9 -2
- package/src/components/storyboard/frameComments.test.ts +95 -0
- package/src/components/storyboard/frameComments.ts +115 -0
- package/src/components/storyboard/useFrameComments.ts +82 -0
- package/src/contexts/DesignPanelInputContext.test.tsx +81 -0
- package/src/contexts/DesignPanelInputContext.tsx +48 -0
- package/src/contexts/DomEditContext.tsx +4 -0
- package/src/contexts/VariablePromoteContext.test.tsx +67 -0
- package/src/contexts/VariablePromoteContext.tsx +10 -5
- package/src/hooks/domEditCommitRunner.ts +11 -0
- package/src/hooks/gsapScriptCommitTypes.ts +6 -4
- package/src/hooks/timelineTrackVisibility.test.ts +52 -0
- package/src/hooks/timelineTrackVisibility.ts +27 -10
- package/src/hooks/useAppHotkeys.ts +9 -0
- package/src/hooks/useDomEditAttributeCommits.ts +123 -1
- package/src/hooks/useDomEditCommits.ts +29 -175
- package/src/hooks/useDomEditCommitsHelpers.ts +158 -0
- package/src/hooks/useDomEditSession.ts +17 -5
- package/src/hooks/useDomEditTextCommits.ts +14 -9
- package/src/hooks/useDomEditWiring.ts +10 -9
- package/src/hooks/useElementLifecycleOps.ts +8 -3
- package/src/hooks/useFileManager.projectOwnership.test.tsx +98 -0
- package/src/hooks/useFileManager.ts +82 -60
- package/src/hooks/useGsapAnimationOps.ts +7 -6
- package/src/hooks/useGsapKeyframeOps.ts +6 -5
- package/src/hooks/useGsapPropertyDebounce.ts +43 -28
- package/src/hooks/useGsapPropertyDebounceFlush.test.ts +35 -0
- package/src/hooks/useGsapScriptCommits.test.tsx +48 -2
- package/src/hooks/useGsapScriptCommits.ts +150 -50
- package/src/hooks/useGsapSelectionHandlers.test.tsx +116 -0
- package/src/hooks/useGsapSelectionHandlers.ts +94 -31
- package/src/hooks/useInspectorSplitResize.ts +51 -0
- package/src/hooks/usePersistentEditHistory.projectOwnership.test.tsx +60 -0
- package/src/hooks/usePersistentEditHistory.test.ts +49 -1
- package/src/hooks/usePersistentEditHistory.ts +71 -31
- package/src/hooks/useProjectCompositionVariables.ts +10 -10
- package/src/hooks/useProjectSignaturePoll.test.tsx +135 -0
- package/src/hooks/useProjectSignaturePoll.ts +68 -0
- package/src/hooks/useSdkSession.lifecycle.test.tsx +137 -0
- package/src/hooks/useSdkSession.ts +155 -14
- package/src/hooks/useSlideshowPersist.ts +7 -1
- package/src/hooks/useStoryboard.ts +23 -4
- package/src/hooks/useTimelineEditing.test.tsx +4 -1
- package/src/hooks/useTimelineEditing.ts +16 -10
- package/src/hooks/useTimelineEditingTypes.ts +3 -0
- package/src/hooks/useTimelineGroupEditing.ts +16 -2
- package/src/hooks/useVariablesPersist.ts +9 -7
- package/src/icons/SystemIcons.tsx +2 -0
- package/src/styles/studio.css +22 -0
- package/src/styles/tailwind-preset.shared.js +7 -0
- package/src/utils/designInputTracking.test.ts +97 -0
- package/src/utils/designInputTracking.ts +80 -0
- package/src/utils/sdkCutover.gate.test.ts +7 -7
- package/src/utils/sdkCutover.test.ts +490 -57
- package/src/utils/sdkCutover.ts +181 -219
- package/src/utils/sdkEditTransaction.ts +292 -0
- package/src/utils/sdkResolverAttempts.ts +94 -0
- package/src/utils/sdkResolverShadow.test.ts +148 -0
- package/src/utils/sdkResolverShadow.ts +139 -106
- package/src/utils/setSlideshowManifest.test.ts +0 -9
- package/src/utils/setSlideshowManifest.ts +20 -27
- package/src/utils/studioFileHistory.test.ts +41 -0
- package/src/utils/studioFileHistory.ts +30 -27
- package/src/utils/studioFileMutationCoordinator.ts +45 -0
- package/src/utils/studioHelpers.test.ts +45 -0
- package/src/utils/studioHelpers.ts +45 -14
- package/src/utils/studioSaveDiagnostics.ts +17 -0
- package/dist/assets/index-B_UvTX3E.js +0 -423
- package/dist/assets/index-uahwWkgw.css +0 -1
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
// fallow-ignore-file code-duplication
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { isTextEditableSelection, type DomEditSelection } from "./domEditing";
|
|
4
|
+
import { buildDefaultGradientModel, serializeGradient } from "./gradientValue";
|
|
5
|
+
import { BorderRadiusEditor } from "./BorderRadiusEditor";
|
|
6
|
+
import {
|
|
7
|
+
formatStrokeSummary,
|
|
8
|
+
parseStrokeSummary,
|
|
9
|
+
STROKE_STYLE_OPTIONS,
|
|
10
|
+
} from "./propertyPanelFlatStyleHelpers";
|
|
11
|
+
import {
|
|
12
|
+
buildBoxShadowPresetValue,
|
|
13
|
+
buildClipPathValue,
|
|
14
|
+
buildStrokeStyleUpdates,
|
|
15
|
+
buildStrokeWidthStyleUpdates,
|
|
16
|
+
extractBackgroundImageUrl,
|
|
17
|
+
formatNumericValue,
|
|
18
|
+
formatPxMetricValue,
|
|
19
|
+
getCssFilterFunctionPx,
|
|
20
|
+
inferBoxShadowPreset,
|
|
21
|
+
inferClipPathPreset,
|
|
22
|
+
normalizePanelPxValue,
|
|
23
|
+
parseNumericValue,
|
|
24
|
+
parsePxMetricValue,
|
|
25
|
+
setCssFilterFunctionPx,
|
|
26
|
+
type BoxShadowPreset,
|
|
27
|
+
} from "./propertyPanelHelpers";
|
|
28
|
+
import {
|
|
29
|
+
FlatRow,
|
|
30
|
+
FlatSegmentedRow,
|
|
31
|
+
FlatSelectRow,
|
|
32
|
+
FlatSlider,
|
|
33
|
+
} from "./propertyPanelFlatPrimitives";
|
|
34
|
+
import { FlatMaskInsetRows } from "./propertyPanelFlatMaskInsetRows";
|
|
35
|
+
import { resolveValueTier } from "./propertyPanelValueTier";
|
|
36
|
+
import { ColorField } from "./propertyPanelColor";
|
|
37
|
+
import { GradientField, ImageFillField } from "./propertyPanelFill";
|
|
38
|
+
|
|
39
|
+
/* ------------------------------------------------------------------ */
|
|
40
|
+
/* Flat Fill sub-block (design_handoff_studio_inspector, #11a) */
|
|
41
|
+
/* ------------------------------------------------------------------ */
|
|
42
|
+
|
|
43
|
+
// fallow-ignore-next-line complexity
|
|
44
|
+
function FlatFillFields({
|
|
45
|
+
projectId,
|
|
46
|
+
element,
|
|
47
|
+
styles,
|
|
48
|
+
assets,
|
|
49
|
+
onSetStyle,
|
|
50
|
+
onImportAssets,
|
|
51
|
+
}: {
|
|
52
|
+
projectId: string;
|
|
53
|
+
element: DomEditSelection;
|
|
54
|
+
styles: Record<string, string>;
|
|
55
|
+
assets: string[];
|
|
56
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
57
|
+
onImportAssets?: (files: FileList) => Promise<string[]>;
|
|
58
|
+
}) {
|
|
59
|
+
const styleEditingDisabled = !element.capabilities.canEditStyles;
|
|
60
|
+
const backgroundImage = styles["background-image"] ?? "none";
|
|
61
|
+
const hasTextControls = isTextEditableSelection(element);
|
|
62
|
+
const fillMode =
|
|
63
|
+
backgroundImage && backgroundImage !== "none"
|
|
64
|
+
? backgroundImage.includes("gradient")
|
|
65
|
+
? "Gradient"
|
|
66
|
+
: "Image"
|
|
67
|
+
: "Solid";
|
|
68
|
+
const [preferredFillMode, setPreferredFillMode] = useState(fillMode);
|
|
69
|
+
const imageUrl = extractBackgroundImageUrl(backgroundImage);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setPreferredFillMode(fillMode);
|
|
73
|
+
}, [fillMode, element.id, element.selector, backgroundImage]);
|
|
74
|
+
|
|
75
|
+
const handleFillModeChange = (nextMode: string) => {
|
|
76
|
+
setPreferredFillMode(nextMode);
|
|
77
|
+
if (nextMode === "Solid") {
|
|
78
|
+
onSetStyle("background-image", "none");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (nextMode === "Gradient" && !backgroundImage.includes("gradient")) {
|
|
82
|
+
onSetStyle(
|
|
83
|
+
"background-image",
|
|
84
|
+
serializeGradient(buildDefaultGradientModel(styles["background-color"])),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<FlatSegmentedRow
|
|
92
|
+
label="Fill"
|
|
93
|
+
options={[
|
|
94
|
+
{ key: "Solid", node: "Solid", label: "Solid", active: preferredFillMode === "Solid" },
|
|
95
|
+
{
|
|
96
|
+
key: "Gradient",
|
|
97
|
+
node: "Gradient",
|
|
98
|
+
label: "Gradient",
|
|
99
|
+
active: preferredFillMode === "Gradient",
|
|
100
|
+
},
|
|
101
|
+
{ key: "Image", node: "Image", label: "Image", active: preferredFillMode === "Image" },
|
|
102
|
+
]}
|
|
103
|
+
disabled={styleEditingDisabled}
|
|
104
|
+
onChange={handleFillModeChange}
|
|
105
|
+
/>
|
|
106
|
+
{preferredFillMode === "Solid" ? (
|
|
107
|
+
<ColorField
|
|
108
|
+
flat
|
|
109
|
+
label="Color"
|
|
110
|
+
value={styles["background-color"] ?? "transparent"}
|
|
111
|
+
disabled={styleEditingDisabled}
|
|
112
|
+
onCommit={(next) => onSetStyle("background-color", next)}
|
|
113
|
+
/>
|
|
114
|
+
) : preferredFillMode === "Gradient" ? (
|
|
115
|
+
<GradientField
|
|
116
|
+
value={
|
|
117
|
+
backgroundImage !== "none"
|
|
118
|
+
? backgroundImage
|
|
119
|
+
: serializeGradient(buildDefaultGradientModel(styles["background-color"]))
|
|
120
|
+
}
|
|
121
|
+
fallbackColor={styles["background-color"]}
|
|
122
|
+
disabled={styleEditingDisabled}
|
|
123
|
+
onCommit={(next) => onSetStyle("background-image", next)}
|
|
124
|
+
/>
|
|
125
|
+
) : (
|
|
126
|
+
<ImageFillField
|
|
127
|
+
projectId={projectId}
|
|
128
|
+
sourceFile={element.sourceFile}
|
|
129
|
+
value={imageUrl}
|
|
130
|
+
assets={assets}
|
|
131
|
+
disabled={styleEditingDisabled}
|
|
132
|
+
onCommit={(next) => onSetStyle("background-image", next)}
|
|
133
|
+
onImportAssets={onImportAssets}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
{!hasTextControls && (
|
|
137
|
+
<ColorField
|
|
138
|
+
flat
|
|
139
|
+
label="Text color"
|
|
140
|
+
value={styles.color ?? "rgb(0, 0, 0)"}
|
|
141
|
+
disabled={styleEditingDisabled}
|
|
142
|
+
onCommit={(next) => onSetStyle("color", next)}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* ------------------------------------------------------------------ */
|
|
150
|
+
/* Flat Stroke row — combined width+style+color */
|
|
151
|
+
/* ------------------------------------------------------------------ */
|
|
152
|
+
|
|
153
|
+
// fallow-ignore-next-line complexity
|
|
154
|
+
function FlatStrokeRow({
|
|
155
|
+
styles,
|
|
156
|
+
disabled,
|
|
157
|
+
onSetStyle,
|
|
158
|
+
}: {
|
|
159
|
+
styles: Record<string, string>;
|
|
160
|
+
disabled: boolean;
|
|
161
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
162
|
+
}) {
|
|
163
|
+
const borderWidthValue =
|
|
164
|
+
parsePxMetricValue(styles["border-width"] ?? "") ??
|
|
165
|
+
parsePxMetricValue(styles["border-top-width"] ?? "") ??
|
|
166
|
+
0;
|
|
167
|
+
const borderStyleValue = styles["border-style"] || styles["border-top-style"] || "none";
|
|
168
|
+
const borderColorValue =
|
|
169
|
+
styles["border-color"] || styles["border-top-color"] || "rgba(255, 255, 255, 0.18)";
|
|
170
|
+
const summary = formatStrokeSummary(borderWidthValue, borderStyleValue);
|
|
171
|
+
const tier = resolveValueTier(
|
|
172
|
+
styles["border-width"] != null || styles["border-style"] != null ? summary : undefined,
|
|
173
|
+
formatStrokeSummary(0, "none"),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<>
|
|
178
|
+
<FlatRow
|
|
179
|
+
label="Stroke"
|
|
180
|
+
value={summary}
|
|
181
|
+
tier={tier}
|
|
182
|
+
disabled={disabled}
|
|
183
|
+
onCommit={async (next) => {
|
|
184
|
+
const parsed = parseStrokeSummary(next);
|
|
185
|
+
if (!parsed) return;
|
|
186
|
+
if (!STROKE_STYLE_OPTIONS.includes(parsed.style)) return;
|
|
187
|
+
const normalizedWidth = normalizePanelPxValue(`${parsed.widthPx}px`, {
|
|
188
|
+
min: 0,
|
|
189
|
+
max: 200,
|
|
190
|
+
fallback: borderWidthValue,
|
|
191
|
+
});
|
|
192
|
+
if (!normalizedWidth) return;
|
|
193
|
+
for (const [property, value] of buildStrokeWidthStyleUpdates(
|
|
194
|
+
normalizedWidth,
|
|
195
|
+
parsed.style,
|
|
196
|
+
)) {
|
|
197
|
+
await onSetStyle(property, value);
|
|
198
|
+
}
|
|
199
|
+
for (const [property, value] of buildStrokeStyleUpdates(parsed.style, normalizedWidth)) {
|
|
200
|
+
await onSetStyle(property, value);
|
|
201
|
+
}
|
|
202
|
+
}}
|
|
203
|
+
suffix={
|
|
204
|
+
<>
|
|
205
|
+
<span
|
|
206
|
+
className="h-4 w-4 flex-shrink-0 rounded border border-panel-border-input"
|
|
207
|
+
style={{ backgroundColor: borderColorValue }}
|
|
208
|
+
/>
|
|
209
|
+
<span className="font-mono text-[10px] text-panel-text-3">{borderColorValue}</span>
|
|
210
|
+
</>
|
|
211
|
+
}
|
|
212
|
+
/>
|
|
213
|
+
<FlatSelectRow
|
|
214
|
+
label="Stroke style"
|
|
215
|
+
value={borderStyleValue}
|
|
216
|
+
options={STROKE_STYLE_OPTIONS}
|
|
217
|
+
tier={resolveValueTier(styles["border-style"], "none")}
|
|
218
|
+
disabled={disabled}
|
|
219
|
+
onChange={async (next) => {
|
|
220
|
+
for (const [property, value] of buildStrokeStyleUpdates(
|
|
221
|
+
next,
|
|
222
|
+
formatPxMetricValue(borderWidthValue),
|
|
223
|
+
)) {
|
|
224
|
+
await onSetStyle(property, value);
|
|
225
|
+
}
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
228
|
+
<ColorField
|
|
229
|
+
flat
|
|
230
|
+
label="Stroke color"
|
|
231
|
+
value={borderColorValue}
|
|
232
|
+
disabled={disabled}
|
|
233
|
+
onCommit={(next) => onSetStyle("border-color", next)}
|
|
234
|
+
/>
|
|
235
|
+
</>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* ------------------------------------------------------------------ */
|
|
240
|
+
/* Flat Radius row — always delegates to BorderRadiusEditor */
|
|
241
|
+
/* ------------------------------------------------------------------ */
|
|
242
|
+
|
|
243
|
+
// fallow-ignore-next-line complexity
|
|
244
|
+
function FlatRadiusRow({
|
|
245
|
+
styles,
|
|
246
|
+
gsapBorderRadius,
|
|
247
|
+
disabled,
|
|
248
|
+
onSetStyle,
|
|
249
|
+
}: {
|
|
250
|
+
styles: Record<string, string>;
|
|
251
|
+
gsapBorderRadius?: { tl: number; tr: number; br: number; bl: number } | null;
|
|
252
|
+
disabled: boolean;
|
|
253
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
254
|
+
}) {
|
|
255
|
+
const radiusValue = parseNumericValue(styles["border-radius"]) ?? 0;
|
|
256
|
+
const radiusTL =
|
|
257
|
+
gsapBorderRadius?.tl ?? parseNumericValue(styles["border-top-left-radius"]) ?? radiusValue;
|
|
258
|
+
const radiusTR =
|
|
259
|
+
gsapBorderRadius?.tr ?? parseNumericValue(styles["border-top-right-radius"]) ?? radiusValue;
|
|
260
|
+
const radiusBR =
|
|
261
|
+
gsapBorderRadius?.br ?? parseNumericValue(styles["border-bottom-right-radius"]) ?? radiusValue;
|
|
262
|
+
const radiusBL =
|
|
263
|
+
gsapBorderRadius?.bl ?? parseNumericValue(styles["border-bottom-left-radius"]) ?? radiusValue;
|
|
264
|
+
|
|
265
|
+
const commit = (corner: "all" | "tl" | "tr" | "br" | "bl", value: number) => {
|
|
266
|
+
const px = `${formatNumericValue(value)}px`;
|
|
267
|
+
if (corner === "all") {
|
|
268
|
+
void onSetStyle("border-radius", px);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const prop = {
|
|
272
|
+
tl: "border-top-left-radius",
|
|
273
|
+
tr: "border-top-right-radius",
|
|
274
|
+
br: "border-bottom-right-radius",
|
|
275
|
+
bl: "border-bottom-left-radius",
|
|
276
|
+
}[corner];
|
|
277
|
+
void onSetStyle(prop, px);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<BorderRadiusEditor
|
|
282
|
+
tl={radiusTL}
|
|
283
|
+
tr={radiusTR}
|
|
284
|
+
br={radiusBR}
|
|
285
|
+
bl={radiusBL}
|
|
286
|
+
disabled={disabled}
|
|
287
|
+
onCommit={commit}
|
|
288
|
+
/>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/* ------------------------------------------------------------------ */
|
|
293
|
+
/* Flat Shadow + Blend rows */
|
|
294
|
+
/* ------------------------------------------------------------------ */
|
|
295
|
+
|
|
296
|
+
function FlatShadowBlendRows({
|
|
297
|
+
styles,
|
|
298
|
+
disabled,
|
|
299
|
+
onSetStyle,
|
|
300
|
+
}: {
|
|
301
|
+
styles: Record<string, string>;
|
|
302
|
+
disabled: boolean;
|
|
303
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
304
|
+
}) {
|
|
305
|
+
const boxShadowPreset = inferBoxShadowPreset(styles["box-shadow"]);
|
|
306
|
+
const blendValue = styles["mix-blend-mode"] || "normal";
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<>
|
|
310
|
+
<FlatSelectRow
|
|
311
|
+
label="Shadow"
|
|
312
|
+
value={boxShadowPreset}
|
|
313
|
+
options={["none", "soft", "lift", "glow", "custom"]}
|
|
314
|
+
tier={resolveValueTier(boxShadowPreset === "none" ? undefined : boxShadowPreset, "none")}
|
|
315
|
+
disabled={disabled}
|
|
316
|
+
onChange={(next) => {
|
|
317
|
+
if (next === "custom") return;
|
|
318
|
+
void onSetStyle(
|
|
319
|
+
"box-shadow",
|
|
320
|
+
buildBoxShadowPresetValue(next as BoxShadowPreset, styles["box-shadow"]),
|
|
321
|
+
);
|
|
322
|
+
}}
|
|
323
|
+
onReset={() => void onSetStyle("box-shadow", "none")}
|
|
324
|
+
/>
|
|
325
|
+
<FlatSelectRow
|
|
326
|
+
label="Blend"
|
|
327
|
+
value={blendValue}
|
|
328
|
+
options={["normal", "multiply", "screen", "overlay", "darken", "lighten"]}
|
|
329
|
+
tier={resolveValueTier(styles["mix-blend-mode"], "normal")}
|
|
330
|
+
disabled={disabled}
|
|
331
|
+
onChange={(next) => void onSetStyle("mix-blend-mode", next)}
|
|
332
|
+
onReset={() => void onSetStyle("mix-blend-mode", "normal")}
|
|
333
|
+
/>
|
|
334
|
+
</>
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* ------------------------------------------------------------------ */
|
|
339
|
+
/* Flat Layer blur + Backdrop sliders */
|
|
340
|
+
/* ------------------------------------------------------------------ */
|
|
341
|
+
|
|
342
|
+
function FlatBlurSliders({
|
|
343
|
+
styles,
|
|
344
|
+
disabled,
|
|
345
|
+
onSetStyle,
|
|
346
|
+
}: {
|
|
347
|
+
styles: Record<string, string>;
|
|
348
|
+
disabled: boolean;
|
|
349
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
350
|
+
}) {
|
|
351
|
+
const filterBlurValue = getCssFilterFunctionPx(styles.filter, "blur");
|
|
352
|
+
const backdropBlurValue = getCssFilterFunctionPx(styles["backdrop-filter"], "blur");
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<>
|
|
356
|
+
<FlatSlider
|
|
357
|
+
label="Layer blur"
|
|
358
|
+
value={filterBlurValue}
|
|
359
|
+
min={0}
|
|
360
|
+
max={Math.max(40, Math.ceil(filterBlurValue))}
|
|
361
|
+
tier={filterBlurValue > 0 ? "explicitCustom" : "default"}
|
|
362
|
+
displayValue={`${formatNumericValue(filterBlurValue)}px`}
|
|
363
|
+
disabled={disabled}
|
|
364
|
+
onCommit={(next) =>
|
|
365
|
+
void onSetStyle("filter", setCssFilterFunctionPx(styles.filter, "blur", next))
|
|
366
|
+
}
|
|
367
|
+
/>
|
|
368
|
+
<FlatSlider
|
|
369
|
+
label="Backdrop"
|
|
370
|
+
value={backdropBlurValue}
|
|
371
|
+
min={0}
|
|
372
|
+
max={Math.max(60, Math.ceil(backdropBlurValue))}
|
|
373
|
+
tier={backdropBlurValue > 0 ? "explicitCustom" : "default"}
|
|
374
|
+
displayValue={`${formatNumericValue(backdropBlurValue)}px`}
|
|
375
|
+
disabled={disabled}
|
|
376
|
+
onCommit={(next) =>
|
|
377
|
+
void onSetStyle(
|
|
378
|
+
"backdrop-filter",
|
|
379
|
+
setCssFilterFunctionPx(styles["backdrop-filter"], "blur", next),
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
/>
|
|
383
|
+
</>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Flat Overflow + Mask rows (+ inset sides).
|
|
388
|
+
function FlatOverflowMaskRows({
|
|
389
|
+
styles,
|
|
390
|
+
disabled,
|
|
391
|
+
onSetStyle,
|
|
392
|
+
}: {
|
|
393
|
+
styles: Record<string, string>;
|
|
394
|
+
disabled: boolean;
|
|
395
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
396
|
+
}) {
|
|
397
|
+
const radiusValue = parseNumericValue(styles["border-radius"]) ?? 0;
|
|
398
|
+
const clipPathValue = styles["clip-path"] || "none";
|
|
399
|
+
const clipPathPreset = inferClipPathPreset(clipPathValue);
|
|
400
|
+
|
|
401
|
+
return (
|
|
402
|
+
<>
|
|
403
|
+
<FlatSelectRow
|
|
404
|
+
label="Overflow"
|
|
405
|
+
value={styles.overflow || "visible"}
|
|
406
|
+
options={["visible", "hidden", "clip", "auto", "scroll"]}
|
|
407
|
+
tier={resolveValueTier(styles.overflow, "visible")}
|
|
408
|
+
disabled={disabled}
|
|
409
|
+
onChange={(next) => void onSetStyle("overflow", next)}
|
|
410
|
+
onReset={() => void onSetStyle("overflow", "visible")}
|
|
411
|
+
/>
|
|
412
|
+
<FlatSelectRow
|
|
413
|
+
label="Mask"
|
|
414
|
+
value={clipPathPreset}
|
|
415
|
+
// "custom" = authored clip-path; showing "none" invites destroying it.
|
|
416
|
+
options={[...(clipPathPreset === "custom" ? ["custom"] : []), "none", "inset", "circle"]}
|
|
417
|
+
tier={resolveValueTier(clipPathPreset === "none" ? undefined : clipPathPreset, "none")}
|
|
418
|
+
disabled={disabled}
|
|
419
|
+
onChange={(next) => {
|
|
420
|
+
if (next === "custom") return;
|
|
421
|
+
void onSetStyle(
|
|
422
|
+
"clip-path",
|
|
423
|
+
buildClipPathValue(next as "none" | "inset" | "circle", radiusValue, clipPathValue),
|
|
424
|
+
);
|
|
425
|
+
}}
|
|
426
|
+
onReset={() => void onSetStyle("clip-path", "none")}
|
|
427
|
+
/>
|
|
428
|
+
<FlatMaskInsetRows
|
|
429
|
+
clipPathValue={clipPathValue}
|
|
430
|
+
radiusValue={radiusValue}
|
|
431
|
+
disabled={disabled}
|
|
432
|
+
onSetStyle={onSetStyle}
|
|
433
|
+
/>
|
|
434
|
+
</>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/* ------------------------------------------------------------------ */
|
|
439
|
+
/* Flat Opacity slider */
|
|
440
|
+
/* ------------------------------------------------------------------ */
|
|
441
|
+
|
|
442
|
+
function FlatOpacitySlider({
|
|
443
|
+
styles,
|
|
444
|
+
disabled,
|
|
445
|
+
onSetStyle,
|
|
446
|
+
}: {
|
|
447
|
+
styles: Record<string, string>;
|
|
448
|
+
disabled: boolean;
|
|
449
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
450
|
+
}) {
|
|
451
|
+
const opacityValue = Math.round((parseNumericValue(styles.opacity) ?? 1) * 100);
|
|
452
|
+
|
|
453
|
+
return (
|
|
454
|
+
<FlatSlider
|
|
455
|
+
label="Opacity"
|
|
456
|
+
value={opacityValue}
|
|
457
|
+
min={0}
|
|
458
|
+
max={100}
|
|
459
|
+
tier="explicitCustom"
|
|
460
|
+
displayValue={`${opacityValue}%`}
|
|
461
|
+
disabled={disabled}
|
|
462
|
+
onCommit={(next) => void onSetStyle("opacity", formatNumericValue(next / 100))}
|
|
463
|
+
/>
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function FlatStyleSection({
|
|
468
|
+
projectId,
|
|
469
|
+
element,
|
|
470
|
+
styles,
|
|
471
|
+
assets,
|
|
472
|
+
onSetStyle,
|
|
473
|
+
onImportAssets,
|
|
474
|
+
gsapBorderRadius,
|
|
475
|
+
}: {
|
|
476
|
+
projectId: string;
|
|
477
|
+
element: DomEditSelection;
|
|
478
|
+
styles: Record<string, string>;
|
|
479
|
+
assets: string[];
|
|
480
|
+
onSetStyle: (prop: string, value: string) => void | Promise<void>;
|
|
481
|
+
onImportAssets?: (files: FileList) => Promise<string[]>;
|
|
482
|
+
gsapBorderRadius?: { tl: number; tr: number; br: number; bl: number } | null;
|
|
483
|
+
}) {
|
|
484
|
+
const styleEditingDisabled = !element.capabilities.canEditStyles;
|
|
485
|
+
return (
|
|
486
|
+
<div className="space-y-1.5">
|
|
487
|
+
<FlatFillFields
|
|
488
|
+
projectId={projectId}
|
|
489
|
+
element={element}
|
|
490
|
+
styles={styles}
|
|
491
|
+
assets={assets}
|
|
492
|
+
onSetStyle={onSetStyle}
|
|
493
|
+
onImportAssets={onImportAssets}
|
|
494
|
+
/>
|
|
495
|
+
<FlatStrokeRow styles={styles} disabled={styleEditingDisabled} onSetStyle={onSetStyle} />
|
|
496
|
+
<FlatRadiusRow
|
|
497
|
+
styles={styles}
|
|
498
|
+
gsapBorderRadius={gsapBorderRadius}
|
|
499
|
+
disabled={styleEditingDisabled}
|
|
500
|
+
onSetStyle={onSetStyle}
|
|
501
|
+
/>
|
|
502
|
+
<FlatShadowBlendRows
|
|
503
|
+
styles={styles}
|
|
504
|
+
disabled={styleEditingDisabled}
|
|
505
|
+
onSetStyle={onSetStyle}
|
|
506
|
+
/>
|
|
507
|
+
<FlatBlurSliders styles={styles} disabled={styleEditingDisabled} onSetStyle={onSetStyle} />
|
|
508
|
+
<FlatOverflowMaskRows
|
|
509
|
+
styles={styles}
|
|
510
|
+
disabled={styleEditingDisabled}
|
|
511
|
+
onSetStyle={onSetStyle}
|
|
512
|
+
/>
|
|
513
|
+
<FlatOpacitySlider styles={styles} disabled={styleEditingDisabled} onSetStyle={onSetStyle} />
|
|
514
|
+
</div>
|
|
515
|
+
);
|
|
516
|
+
}
|