@morphika/andami 0.4.2 → 0.5.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/README.md +151 -36
- package/app/admin/layout.tsx +145 -152
- package/components/blocks/AudioBlockRenderer.tsx +286 -0
- package/components/blocks/BeforeAfterBlockRenderer.tsx +274 -0
- package/components/builder/BlockCardIcons.tsx +89 -0
- package/components/builder/BlockTypePicker.tsx +2 -0
- package/components/builder/ColumnDragContext.tsx +5 -0
- package/components/builder/ColumnDragOverlay.tsx +38 -11
- package/components/builder/CoverSectionCanvas.tsx +90 -2
- package/components/builder/InsertionLines.tsx +9 -1
- package/components/builder/SectionV2Canvas.tsx +32 -6
- package/components/builder/SectionV2Column.tsx +5 -1
- package/components/builder/asset-browser/R2BrowserContent.tsx +23 -6
- package/components/builder/asset-browser/helpers.ts +4 -0
- package/components/builder/asset-browser/types.ts +2 -1
- package/components/builder/blockStyles.tsx +12 -0
- package/components/builder/editors/AudioBlockEditor.tsx +242 -0
- package/components/builder/editors/BeforeAfterBlockEditor.tsx +360 -0
- package/components/builder/editors/shared.tsx +1 -1
- package/components/builder/hooks/useColumnDrag.ts +206 -132
- package/components/builder/live-preview/LiveAudioPreview.tsx +120 -0
- package/components/builder/live-preview/LiveBeforeAfterPreview.tsx +176 -0
- package/lib/animation/enter-types.ts +2 -0
- package/lib/animation/hover-effect-types.ts +2 -0
- package/lib/builder/block-registrations.ts +83 -1
- package/lib/builder/store-helpers.ts +302 -1
- package/lib/builder/store-sections.ts +60 -0
- package/lib/builder/types-slices.ts +27 -0
- package/lib/builder/types.ts +2 -0
- package/lib/sanity/types.ts +75 -0
- package/lib/version.ts +1 -1
- package/package.json +1 -1
- package/sanity/schemas/blocks/audioBlock.ts +69 -0
- package/sanity/schemas/blocks/beforeAfterBlock.ts +121 -0
- package/sanity/schemas/blocks/index.ts +3 -1
- package/sanity/schemas/index.ts +7 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useBuilderStore } from "../../../lib/builder/store";
|
|
4
|
+
import { getEffectiveValue, setResponsiveOverride } from "../../../lib/builder/responsive";
|
|
5
|
+
import type { AudioBlock, ContentBlock } from "../../../lib/sanity/types";
|
|
6
|
+
import ColorSwatchPicker, { usePaletteSwatches } from "../ColorSwatchPicker";
|
|
7
|
+
import { resolveColorHex } from "../../../lib/color-utils";
|
|
8
|
+
import {
|
|
9
|
+
SourceIcon,
|
|
10
|
+
LayoutIcon,
|
|
11
|
+
AppearanceIcon,
|
|
12
|
+
PlaybackIcon,
|
|
13
|
+
OptionsIcon,
|
|
14
|
+
} from "./section-icons";
|
|
15
|
+
import {
|
|
16
|
+
SettingsField,
|
|
17
|
+
SettingsSection,
|
|
18
|
+
StyledCheckbox,
|
|
19
|
+
AssetPathInput,
|
|
20
|
+
ViewportBadge,
|
|
21
|
+
ResponsiveField,
|
|
22
|
+
useActiveViewport,
|
|
23
|
+
INPUT_CLASS,
|
|
24
|
+
} from "./shared";
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
block: AudioBlock;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function AudioBlockEditor({ block }: Props) {
|
|
31
|
+
const store = useBuilderStore();
|
|
32
|
+
const viewport = useActiveViewport();
|
|
33
|
+
const paletteSwatches = usePaletteSwatches();
|
|
34
|
+
|
|
35
|
+
const snapshotOnFocus = () => store._pushSnapshot();
|
|
36
|
+
|
|
37
|
+
const updateResponsive = (property: string, value: unknown) => {
|
|
38
|
+
if (viewport === "desktop") {
|
|
39
|
+
store.updateBlock(block._key, { [property]: value } as Partial<ContentBlock>);
|
|
40
|
+
} else {
|
|
41
|
+
const overrides = setResponsiveOverride(block as ContentBlock, viewport, property, value);
|
|
42
|
+
store.updateBlock(block._key, overrides as Partial<ContentBlock>);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const resetOverride = (property: string) => {
|
|
47
|
+
const overrides = setResponsiveOverride(block as ContentBlock, viewport, property, undefined);
|
|
48
|
+
store.updateBlock(block._key, overrides as Partial<ContentBlock>);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const update = (updates: Partial<AudioBlock>) => {
|
|
52
|
+
store.updateBlock(block._key, updates as Partial<ContentBlock>);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const updateDebounced = (updates: Partial<AudioBlock>) => {
|
|
56
|
+
store.updateBlockDebounced(block._key, updates as Partial<ContentBlock>);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const effectiveWidth = getEffectiveValue<string>(
|
|
60
|
+
block as ContentBlock, viewport, "width", block.width || "contained"
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<ViewportBadge />
|
|
66
|
+
|
|
67
|
+
{/* ── Source ── */}
|
|
68
|
+
<SettingsSection title="Audio" defaultOpen icon={<SourceIcon />}>
|
|
69
|
+
<SettingsField label="Audio File" hint="mp3, wav, ogg, m4a, aac, flac">
|
|
70
|
+
<AssetPathInput
|
|
71
|
+
value={block.asset_path || ""}
|
|
72
|
+
onFocus={snapshotOnFocus}
|
|
73
|
+
onChange={(v) => updateDebounced({ asset_path: v })}
|
|
74
|
+
placeholder="projects/slug/track.mp3"
|
|
75
|
+
filterType="audio"
|
|
76
|
+
/>
|
|
77
|
+
</SettingsField>
|
|
78
|
+
|
|
79
|
+
<SettingsField label="Alt Text">
|
|
80
|
+
<input
|
|
81
|
+
type="text"
|
|
82
|
+
value={block.alt || ""}
|
|
83
|
+
onFocus={snapshotOnFocus}
|
|
84
|
+
onChange={(e) => updateDebounced({ alt: e.target.value })}
|
|
85
|
+
className={INPUT_CLASS}
|
|
86
|
+
placeholder="Describe the audio for accessibility"
|
|
87
|
+
/>
|
|
88
|
+
</SettingsField>
|
|
89
|
+
</SettingsSection>
|
|
90
|
+
|
|
91
|
+
{/* ── Metadata ── */}
|
|
92
|
+
<SettingsSection title="Metadata" icon={<OptionsIcon />}>
|
|
93
|
+
<SettingsField label="Title">
|
|
94
|
+
<input
|
|
95
|
+
type="text"
|
|
96
|
+
value={block.title || ""}
|
|
97
|
+
onFocus={snapshotOnFocus}
|
|
98
|
+
onChange={(e) => updateDebounced({ title: e.target.value })}
|
|
99
|
+
className={INPUT_CLASS}
|
|
100
|
+
placeholder="Track title"
|
|
101
|
+
/>
|
|
102
|
+
</SettingsField>
|
|
103
|
+
|
|
104
|
+
<SettingsField label="Artist">
|
|
105
|
+
<input
|
|
106
|
+
type="text"
|
|
107
|
+
value={block.artist || ""}
|
|
108
|
+
onFocus={snapshotOnFocus}
|
|
109
|
+
onChange={(e) => updateDebounced({ artist: e.target.value })}
|
|
110
|
+
className={INPUT_CLASS}
|
|
111
|
+
placeholder="Artist name"
|
|
112
|
+
/>
|
|
113
|
+
</SettingsField>
|
|
114
|
+
|
|
115
|
+
<SettingsField label="Cover Art" hint="Optional relative path to an image">
|
|
116
|
+
<AssetPathInput
|
|
117
|
+
value={block.cover_path || ""}
|
|
118
|
+
onFocus={snapshotOnFocus}
|
|
119
|
+
onChange={(v) => updateDebounced({ cover_path: v })}
|
|
120
|
+
placeholder="projects/slug/cover.jpg"
|
|
121
|
+
filterType="image"
|
|
122
|
+
/>
|
|
123
|
+
</SettingsField>
|
|
124
|
+
</SettingsSection>
|
|
125
|
+
|
|
126
|
+
{/* ── Layout ── */}
|
|
127
|
+
<SettingsSection title="Layout" icon={<LayoutIcon />}>
|
|
128
|
+
<ResponsiveField
|
|
129
|
+
label="Width"
|
|
130
|
+
block={block as ContentBlock}
|
|
131
|
+
property="width"
|
|
132
|
+
onReset={() => resetOverride("width")}
|
|
133
|
+
>
|
|
134
|
+
<div className="flex gap-1">
|
|
135
|
+
{(
|
|
136
|
+
[
|
|
137
|
+
{ value: "full", label: "Full" },
|
|
138
|
+
{ value: "contained", label: "Contained" },
|
|
139
|
+
{ value: "small", label: "Small" },
|
|
140
|
+
{ value: "fill", label: "Fill" },
|
|
141
|
+
] as const
|
|
142
|
+
).map((opt) => (
|
|
143
|
+
<button
|
|
144
|
+
key={opt.value}
|
|
145
|
+
onClick={() => updateResponsive("width", opt.value)}
|
|
146
|
+
className={`flex-1 rounded border py-1 text-xs transition-colors ${
|
|
147
|
+
effectiveWidth === opt.value
|
|
148
|
+
? "border-[#076bff] bg-[#076bff]/20 text-neutral-900"
|
|
149
|
+
: "border-neutral-200 bg-white text-neutral-500 hover:border-neutral-600"
|
|
150
|
+
}`}
|
|
151
|
+
>
|
|
152
|
+
{opt.label}
|
|
153
|
+
</button>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
156
|
+
</ResponsiveField>
|
|
157
|
+
</SettingsSection>
|
|
158
|
+
|
|
159
|
+
{/* ── Appearance ── */}
|
|
160
|
+
<SettingsSection title="Appearance" icon={<AppearanceIcon />}>
|
|
161
|
+
<SettingsField label="Accent Color" hint="Play button + progress fill">
|
|
162
|
+
<ColorSwatchPicker
|
|
163
|
+
value={block.accent_color || "#4794E2"}
|
|
164
|
+
onChange={(value) => {
|
|
165
|
+
const hex = resolveColorHex(value) || "#4794E2";
|
|
166
|
+
update({ accent_color: hex });
|
|
167
|
+
}}
|
|
168
|
+
swatches={paletteSwatches}
|
|
169
|
+
/>
|
|
170
|
+
</SettingsField>
|
|
171
|
+
|
|
172
|
+
<ResponsiveField
|
|
173
|
+
label="Border Radius"
|
|
174
|
+
block={block as ContentBlock}
|
|
175
|
+
property="border_radius"
|
|
176
|
+
onReset={() => resetOverride("border_radius")}
|
|
177
|
+
>
|
|
178
|
+
<div className="flex items-center gap-1.5">
|
|
179
|
+
<input
|
|
180
|
+
type="number"
|
|
181
|
+
value={String(getEffectiveValue<string>(block as ContentBlock, viewport, "border_radius", block.border_radius || "")).replace(/px$/i, "")}
|
|
182
|
+
onFocus={snapshotOnFocus}
|
|
183
|
+
onChange={(e) => {
|
|
184
|
+
store._pushSnapshot();
|
|
185
|
+
updateResponsive("border_radius", e.target.value.replace(/[^0-9]/g, ""));
|
|
186
|
+
}}
|
|
187
|
+
className={INPUT_CLASS}
|
|
188
|
+
placeholder="12"
|
|
189
|
+
min={0}
|
|
190
|
+
/>
|
|
191
|
+
<span className="text-[10px] text-neutral-400 shrink-0">px</span>
|
|
192
|
+
</div>
|
|
193
|
+
</ResponsiveField>
|
|
194
|
+
|
|
195
|
+
<ResponsiveField
|
|
196
|
+
label="Shadow"
|
|
197
|
+
block={block as ContentBlock}
|
|
198
|
+
property="shadow"
|
|
199
|
+
onReset={() => resetOverride("shadow")}
|
|
200
|
+
>
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={() => {
|
|
204
|
+
const effectiveShadow = getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false);
|
|
205
|
+
updateResponsive("shadow", !effectiveShadow);
|
|
206
|
+
}}
|
|
207
|
+
className={`relative w-8 h-[18px] rounded-full transition-colors ${
|
|
208
|
+
getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false) ? "bg-[#076bff]" : "bg-neutral-200 hover:bg-neutral-300"
|
|
209
|
+
}`}
|
|
210
|
+
>
|
|
211
|
+
<span
|
|
212
|
+
className={`absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white shadow-sm transition-transform ${
|
|
213
|
+
getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false) ? "left-[16px]" : "left-[2px]"
|
|
214
|
+
}`}
|
|
215
|
+
/>
|
|
216
|
+
</button>
|
|
217
|
+
</ResponsiveField>
|
|
218
|
+
</SettingsSection>
|
|
219
|
+
|
|
220
|
+
{/* ── Playback ── */}
|
|
221
|
+
<SettingsSection title="Playback" icon={<PlaybackIcon />}>
|
|
222
|
+
<div className="space-y-1.5">
|
|
223
|
+
<StyledCheckbox
|
|
224
|
+
label="Autoplay"
|
|
225
|
+
checked={block.autoplay === true}
|
|
226
|
+
onChange={(checked) => update({ autoplay: checked })}
|
|
227
|
+
/>
|
|
228
|
+
<StyledCheckbox
|
|
229
|
+
label="Loop"
|
|
230
|
+
checked={block.loop === true}
|
|
231
|
+
onChange={(checked) => update({ loop: checked })}
|
|
232
|
+
/>
|
|
233
|
+
<StyledCheckbox
|
|
234
|
+
label="Muted"
|
|
235
|
+
checked={block.muted === true}
|
|
236
|
+
onChange={(checked) => update({ muted: checked })}
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
</SettingsSection>
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useBuilderStore } from "../../../lib/builder/store";
|
|
4
|
+
import { getEffectiveValue, setResponsiveOverride } from "../../../lib/builder/responsive";
|
|
5
|
+
import type { BeforeAfterBlock, ContentBlock } from "../../../lib/sanity/types";
|
|
6
|
+
import ColorSwatchPicker, { usePaletteSwatches } from "../ColorSwatchPicker";
|
|
7
|
+
import { resolveColorHex } from "../../../lib/color-utils";
|
|
8
|
+
import {
|
|
9
|
+
SourceIcon,
|
|
10
|
+
LayoutIcon,
|
|
11
|
+
AppearanceIcon,
|
|
12
|
+
PlaybackIcon,
|
|
13
|
+
OptionsIcon,
|
|
14
|
+
} from "./section-icons";
|
|
15
|
+
import {
|
|
16
|
+
SettingsField,
|
|
17
|
+
SettingsSection,
|
|
18
|
+
StyledCheckbox,
|
|
19
|
+
AssetPathInput,
|
|
20
|
+
ViewportBadge,
|
|
21
|
+
ResponsiveField,
|
|
22
|
+
useActiveViewport,
|
|
23
|
+
INPUT_CLASS,
|
|
24
|
+
SELECT_CLASS,
|
|
25
|
+
} from "./shared";
|
|
26
|
+
|
|
27
|
+
interface Props {
|
|
28
|
+
block: BeforeAfterBlock;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function BeforeAfterBlockEditor({ block }: Props) {
|
|
32
|
+
const store = useBuilderStore();
|
|
33
|
+
const viewport = useActiveViewport();
|
|
34
|
+
const paletteSwatches = usePaletteSwatches();
|
|
35
|
+
|
|
36
|
+
const snapshotOnFocus = () => store._pushSnapshot();
|
|
37
|
+
|
|
38
|
+
const updateResponsive = (property: string, value: unknown) => {
|
|
39
|
+
if (viewport === "desktop") {
|
|
40
|
+
store.updateBlock(block._key, { [property]: value } as Partial<ContentBlock>);
|
|
41
|
+
} else {
|
|
42
|
+
const overrides = setResponsiveOverride(block as ContentBlock, viewport, property, value);
|
|
43
|
+
store.updateBlock(block._key, overrides as Partial<ContentBlock>);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const resetOverride = (property: string) => {
|
|
48
|
+
const overrides = setResponsiveOverride(block as ContentBlock, viewport, property, undefined);
|
|
49
|
+
store.updateBlock(block._key, overrides as Partial<ContentBlock>);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const update = (updates: Partial<BeforeAfterBlock>) => {
|
|
53
|
+
store.updateBlock(block._key, updates as Partial<ContentBlock>);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const updateDebounced = (updates: Partial<BeforeAfterBlock>) => {
|
|
57
|
+
store.updateBlockDebounced(block._key, updates as Partial<ContentBlock>);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const beforeType = block.before_media_type || "image";
|
|
61
|
+
const afterType = block.after_media_type || "image";
|
|
62
|
+
|
|
63
|
+
const effectiveWidth = getEffectiveValue<string>(
|
|
64
|
+
block as ContentBlock, viewport, "width", block.width || "full"
|
|
65
|
+
);
|
|
66
|
+
const effectiveAspect = getEffectiveValue<string>(
|
|
67
|
+
block as ContentBlock, viewport, "aspect_ratio", block.aspect_ratio || "16:9"
|
|
68
|
+
);
|
|
69
|
+
const effectiveOrientation = getEffectiveValue<string>(
|
|
70
|
+
block as ContentBlock, viewport, "orientation", block.orientation || "horizontal"
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const eitherIsVideo = beforeType === "video" || afterType === "video";
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<>
|
|
77
|
+
<ViewportBadge />
|
|
78
|
+
|
|
79
|
+
{/* ── Before source ── */}
|
|
80
|
+
<SettingsSection title="Before" defaultOpen icon={<SourceIcon />}>
|
|
81
|
+
<SettingsField label="Media Type">
|
|
82
|
+
<div className="flex gap-1">
|
|
83
|
+
{(
|
|
84
|
+
[
|
|
85
|
+
{ value: "image", label: "Image" },
|
|
86
|
+
{ value: "video", label: "Video" },
|
|
87
|
+
] as const
|
|
88
|
+
).map((opt) => (
|
|
89
|
+
<button
|
|
90
|
+
key={opt.value}
|
|
91
|
+
onClick={() => update({ before_media_type: opt.value })}
|
|
92
|
+
className={`flex-1 rounded border py-1 text-xs transition-colors ${
|
|
93
|
+
beforeType === opt.value
|
|
94
|
+
? "border-[#076bff] bg-[#076bff]/20 text-neutral-900"
|
|
95
|
+
: "border-neutral-200 bg-white text-neutral-500 hover:border-neutral-600"
|
|
96
|
+
}`}
|
|
97
|
+
>
|
|
98
|
+
{opt.label}
|
|
99
|
+
</button>
|
|
100
|
+
))}
|
|
101
|
+
</div>
|
|
102
|
+
</SettingsField>
|
|
103
|
+
|
|
104
|
+
<SettingsField label="Asset Path" hint="Relative path from seed URL">
|
|
105
|
+
<AssetPathInput
|
|
106
|
+
value={block.before_asset_path || ""}
|
|
107
|
+
onFocus={snapshotOnFocus}
|
|
108
|
+
onChange={(v) => updateDebounced({ before_asset_path: v })}
|
|
109
|
+
placeholder={beforeType === "video" ? "projects/slug/before.mp4" : "projects/slug/before.jpg"}
|
|
110
|
+
filterType={beforeType}
|
|
111
|
+
/>
|
|
112
|
+
</SettingsField>
|
|
113
|
+
|
|
114
|
+
<SettingsField label="Alt Text">
|
|
115
|
+
<input
|
|
116
|
+
type="text"
|
|
117
|
+
value={block.before_alt || ""}
|
|
118
|
+
onFocus={snapshotOnFocus}
|
|
119
|
+
onChange={(e) => updateDebounced({ before_alt: e.target.value })}
|
|
120
|
+
className={INPUT_CLASS}
|
|
121
|
+
placeholder="Describe the before media"
|
|
122
|
+
/>
|
|
123
|
+
</SettingsField>
|
|
124
|
+
</SettingsSection>
|
|
125
|
+
|
|
126
|
+
{/* ── After source ── */}
|
|
127
|
+
<SettingsSection title="After" icon={<SourceIcon />}>
|
|
128
|
+
<SettingsField label="Media Type">
|
|
129
|
+
<div className="flex gap-1">
|
|
130
|
+
{(
|
|
131
|
+
[
|
|
132
|
+
{ value: "image", label: "Image" },
|
|
133
|
+
{ value: "video", label: "Video" },
|
|
134
|
+
] as const
|
|
135
|
+
).map((opt) => (
|
|
136
|
+
<button
|
|
137
|
+
key={opt.value}
|
|
138
|
+
onClick={() => update({ after_media_type: opt.value })}
|
|
139
|
+
className={`flex-1 rounded border py-1 text-xs transition-colors ${
|
|
140
|
+
afterType === opt.value
|
|
141
|
+
? "border-[#076bff] bg-[#076bff]/20 text-neutral-900"
|
|
142
|
+
: "border-neutral-200 bg-white text-neutral-500 hover:border-neutral-600"
|
|
143
|
+
}`}
|
|
144
|
+
>
|
|
145
|
+
{opt.label}
|
|
146
|
+
</button>
|
|
147
|
+
))}
|
|
148
|
+
</div>
|
|
149
|
+
</SettingsField>
|
|
150
|
+
|
|
151
|
+
<SettingsField label="Asset Path" hint="Relative path from seed URL">
|
|
152
|
+
<AssetPathInput
|
|
153
|
+
value={block.after_asset_path || ""}
|
|
154
|
+
onFocus={snapshotOnFocus}
|
|
155
|
+
onChange={(v) => updateDebounced({ after_asset_path: v })}
|
|
156
|
+
placeholder={afterType === "video" ? "projects/slug/after.mp4" : "projects/slug/after.jpg"}
|
|
157
|
+
filterType={afterType}
|
|
158
|
+
/>
|
|
159
|
+
</SettingsField>
|
|
160
|
+
|
|
161
|
+
<SettingsField label="Alt Text">
|
|
162
|
+
<input
|
|
163
|
+
type="text"
|
|
164
|
+
value={block.after_alt || ""}
|
|
165
|
+
onFocus={snapshotOnFocus}
|
|
166
|
+
onChange={(e) => updateDebounced({ after_alt: e.target.value })}
|
|
167
|
+
className={INPUT_CLASS}
|
|
168
|
+
placeholder="Describe the after media"
|
|
169
|
+
/>
|
|
170
|
+
</SettingsField>
|
|
171
|
+
</SettingsSection>
|
|
172
|
+
|
|
173
|
+
{/* ── Slider options ── */}
|
|
174
|
+
<SettingsSection title="Slider" icon={<OptionsIcon />}>
|
|
175
|
+
<ResponsiveField
|
|
176
|
+
label="Orientation"
|
|
177
|
+
block={block as ContentBlock}
|
|
178
|
+
property="orientation"
|
|
179
|
+
onReset={() => resetOverride("orientation")}
|
|
180
|
+
>
|
|
181
|
+
<div className="flex gap-1">
|
|
182
|
+
{(
|
|
183
|
+
[
|
|
184
|
+
{ value: "horizontal", label: "Horizontal" },
|
|
185
|
+
{ value: "vertical", label: "Vertical" },
|
|
186
|
+
] as const
|
|
187
|
+
).map((opt) => (
|
|
188
|
+
<button
|
|
189
|
+
key={opt.value}
|
|
190
|
+
onClick={() => updateResponsive("orientation", opt.value)}
|
|
191
|
+
className={`flex-1 rounded border py-1 text-xs transition-colors ${
|
|
192
|
+
effectiveOrientation === opt.value
|
|
193
|
+
? "border-[#076bff] bg-[#076bff]/20 text-neutral-900"
|
|
194
|
+
: "border-neutral-200 bg-white text-neutral-500 hover:border-neutral-600"
|
|
195
|
+
}`}
|
|
196
|
+
>
|
|
197
|
+
{opt.label}
|
|
198
|
+
</button>
|
|
199
|
+
))}
|
|
200
|
+
</div>
|
|
201
|
+
</ResponsiveField>
|
|
202
|
+
|
|
203
|
+
<SettingsField label="Initial Position" hint="0–100%">
|
|
204
|
+
<div className="flex items-center gap-1.5">
|
|
205
|
+
<input
|
|
206
|
+
type="number"
|
|
207
|
+
min={0}
|
|
208
|
+
max={100}
|
|
209
|
+
value={block.initial_position ?? 50}
|
|
210
|
+
onFocus={snapshotOnFocus}
|
|
211
|
+
onChange={(e) => {
|
|
212
|
+
const n = Math.max(0, Math.min(100, Number(e.target.value) || 0));
|
|
213
|
+
updateDebounced({ initial_position: n });
|
|
214
|
+
}}
|
|
215
|
+
className={INPUT_CLASS}
|
|
216
|
+
placeholder="50"
|
|
217
|
+
/>
|
|
218
|
+
<span className="text-[10px] text-neutral-400 shrink-0">%</span>
|
|
219
|
+
</div>
|
|
220
|
+
</SettingsField>
|
|
221
|
+
|
|
222
|
+
<SettingsField label="Handle Color">
|
|
223
|
+
<ColorSwatchPicker
|
|
224
|
+
value={block.handle_color || "#FFFFFF"}
|
|
225
|
+
onChange={(value) => {
|
|
226
|
+
const hex = resolveColorHex(value) || "#FFFFFF";
|
|
227
|
+
update({ handle_color: hex });
|
|
228
|
+
}}
|
|
229
|
+
swatches={paletteSwatches}
|
|
230
|
+
/>
|
|
231
|
+
</SettingsField>
|
|
232
|
+
</SettingsSection>
|
|
233
|
+
|
|
234
|
+
{/* ── Layout ── */}
|
|
235
|
+
<SettingsSection title="Layout" icon={<LayoutIcon />}>
|
|
236
|
+
<ResponsiveField
|
|
237
|
+
label="Width"
|
|
238
|
+
block={block as ContentBlock}
|
|
239
|
+
property="width"
|
|
240
|
+
onReset={() => resetOverride("width")}
|
|
241
|
+
>
|
|
242
|
+
<div className="flex gap-1">
|
|
243
|
+
{(
|
|
244
|
+
[
|
|
245
|
+
{ value: "full", label: "Full" },
|
|
246
|
+
{ value: "contained", label: "Contained" },
|
|
247
|
+
{ value: "small", label: "Small" },
|
|
248
|
+
{ value: "fill", label: "Fill" },
|
|
249
|
+
] as const
|
|
250
|
+
).map((opt) => (
|
|
251
|
+
<button
|
|
252
|
+
key={opt.value}
|
|
253
|
+
onClick={() => updateResponsive("width", opt.value)}
|
|
254
|
+
className={`flex-1 rounded border py-1 text-xs transition-colors ${
|
|
255
|
+
effectiveWidth === opt.value
|
|
256
|
+
? "border-[#076bff] bg-[#076bff]/20 text-neutral-900"
|
|
257
|
+
: "border-neutral-200 bg-white text-neutral-500 hover:border-neutral-600"
|
|
258
|
+
}`}
|
|
259
|
+
>
|
|
260
|
+
{opt.label}
|
|
261
|
+
</button>
|
|
262
|
+
))}
|
|
263
|
+
</div>
|
|
264
|
+
</ResponsiveField>
|
|
265
|
+
|
|
266
|
+
<ResponsiveField
|
|
267
|
+
label="Aspect Ratio"
|
|
268
|
+
block={block as ContentBlock}
|
|
269
|
+
property="aspect_ratio"
|
|
270
|
+
onReset={() => resetOverride("aspect_ratio")}
|
|
271
|
+
>
|
|
272
|
+
<select
|
|
273
|
+
value={effectiveAspect}
|
|
274
|
+
onChange={(e) => updateResponsive("aspect_ratio", e.target.value)}
|
|
275
|
+
className={SELECT_CLASS}
|
|
276
|
+
>
|
|
277
|
+
<option value="auto">Auto</option>
|
|
278
|
+
<option value="16:9">16:9</option>
|
|
279
|
+
<option value="4:3">4:3</option>
|
|
280
|
+
<option value="1:1">1:1</option>
|
|
281
|
+
<option value="21:9">21:9</option>
|
|
282
|
+
</select>
|
|
283
|
+
</ResponsiveField>
|
|
284
|
+
</SettingsSection>
|
|
285
|
+
|
|
286
|
+
{/* ── Appearance ── */}
|
|
287
|
+
<SettingsSection title="Appearance" icon={<AppearanceIcon />}>
|
|
288
|
+
<ResponsiveField
|
|
289
|
+
label="Border Radius"
|
|
290
|
+
block={block as ContentBlock}
|
|
291
|
+
property="border_radius"
|
|
292
|
+
onReset={() => resetOverride("border_radius")}
|
|
293
|
+
>
|
|
294
|
+
<div className="flex items-center gap-1.5">
|
|
295
|
+
<input
|
|
296
|
+
type="number"
|
|
297
|
+
value={String(getEffectiveValue<string>(block as ContentBlock, viewport, "border_radius", block.border_radius || "")).replace(/px$/i, "")}
|
|
298
|
+
onFocus={snapshotOnFocus}
|
|
299
|
+
onChange={(e) => {
|
|
300
|
+
store._pushSnapshot();
|
|
301
|
+
updateResponsive("border_radius", e.target.value.replace(/[^0-9]/g, ""));
|
|
302
|
+
}}
|
|
303
|
+
className={INPUT_CLASS}
|
|
304
|
+
placeholder="0"
|
|
305
|
+
min={0}
|
|
306
|
+
/>
|
|
307
|
+
<span className="text-[10px] text-neutral-400 shrink-0">px</span>
|
|
308
|
+
</div>
|
|
309
|
+
</ResponsiveField>
|
|
310
|
+
|
|
311
|
+
<ResponsiveField
|
|
312
|
+
label="Shadow"
|
|
313
|
+
block={block as ContentBlock}
|
|
314
|
+
property="shadow"
|
|
315
|
+
onReset={() => resetOverride("shadow")}
|
|
316
|
+
>
|
|
317
|
+
<button
|
|
318
|
+
type="button"
|
|
319
|
+
onClick={() => {
|
|
320
|
+
const effectiveShadow = getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false);
|
|
321
|
+
updateResponsive("shadow", !effectiveShadow);
|
|
322
|
+
}}
|
|
323
|
+
className={`relative w-8 h-[18px] rounded-full transition-colors ${
|
|
324
|
+
getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false) ? "bg-[#076bff]" : "bg-neutral-200 hover:bg-neutral-300"
|
|
325
|
+
}`}
|
|
326
|
+
>
|
|
327
|
+
<span
|
|
328
|
+
className={`absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white shadow-sm transition-transform ${
|
|
329
|
+
getEffectiveValue<boolean>(block as ContentBlock, viewport, "shadow", block.shadow || false) ? "left-[16px]" : "left-[2px]"
|
|
330
|
+
}`}
|
|
331
|
+
/>
|
|
332
|
+
</button>
|
|
333
|
+
</ResponsiveField>
|
|
334
|
+
</SettingsSection>
|
|
335
|
+
|
|
336
|
+
{/* ── Video playback (only shown when at least one side is video) ── */}
|
|
337
|
+
{eitherIsVideo && (
|
|
338
|
+
<SettingsSection title="Playback" icon={<PlaybackIcon />}>
|
|
339
|
+
<div className="space-y-1.5">
|
|
340
|
+
<StyledCheckbox
|
|
341
|
+
label="Autoplay"
|
|
342
|
+
checked={block.video_autoplay !== false}
|
|
343
|
+
onChange={(checked) => update({ video_autoplay: checked })}
|
|
344
|
+
/>
|
|
345
|
+
<StyledCheckbox
|
|
346
|
+
label="Loop"
|
|
347
|
+
checked={block.video_loop !== false}
|
|
348
|
+
onChange={(checked) => update({ video_loop: checked })}
|
|
349
|
+
/>
|
|
350
|
+
<StyledCheckbox
|
|
351
|
+
label="Muted"
|
|
352
|
+
checked={block.video_muted !== false}
|
|
353
|
+
onChange={(checked) => update({ video_muted: checked })}
|
|
354
|
+
/>
|
|
355
|
+
</div>
|
|
356
|
+
</SettingsSection>
|
|
357
|
+
)}
|
|
358
|
+
</>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
@@ -320,7 +320,7 @@ export function AssetPathInput({
|
|
|
320
320
|
onChange: (value: string) => void;
|
|
321
321
|
onFocus?: () => void;
|
|
322
322
|
placeholder?: string;
|
|
323
|
-
filterType?: "image" | "video" | "all";
|
|
323
|
+
filterType?: "image" | "video" | "audio" | "all";
|
|
324
324
|
}) {
|
|
325
325
|
const [browserOpen, setBrowserOpen] = useState(false);
|
|
326
326
|
|