@morphika/andami 0.5.0 → 0.5.2
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/assets/page.tsx +6 -6
- package/app/admin/database/page.tsx +302 -302
- package/app/admin/error.tsx +53 -53
- package/app/admin/layout.tsx +320 -327
- package/app/admin/navigation/page.tsx +255 -255
- package/app/admin/pages/[slug]/page.tsx +6 -6
- package/app/admin/pages/page.tsx +11 -11
- package/app/admin/projects/page.tsx +14 -14
- package/app/admin/setup/page.tsx +1 -1
- package/app/admin/styles/page.tsx +1 -1
- package/components/admin/MetadataEditor.tsx +6 -6
- package/components/admin/nav-builder/NavBuilder.tsx +1 -1
- package/components/admin/nav-builder/NavBuilderGrid.tsx +3 -3
- package/components/admin/nav-builder/NavGridCell.tsx +48 -48
- package/components/admin/nav-builder/NavGridItem.tsx +4 -4
- package/components/admin/nav-builder/NavItemSettings.tsx +331 -331
- package/components/admin/nav-builder/NavItemTypePicker.tsx +102 -102
- package/components/admin/nav-builder/NavLivePreview.tsx +1 -1
- package/components/admin/nav-builder/NavMobileLivePreview.tsx +226 -226
- package/components/admin/nav-builder/NavMobileSettings.tsx +242 -242
- package/components/admin/nav-builder/NavSettingsFields.tsx +514 -514
- package/components/admin/setup-wizard/BrandingStep.tsx +3 -3
- package/components/admin/setup-wizard/DatabaseStep.tsx +2 -2
- package/components/admin/setup-wizard/DoneStep.tsx +1 -1
- package/components/admin/setup-wizard/SetupWizard.tsx +4 -4
- package/components/admin/setup-wizard/StorageStep.tsx +2 -2
- package/components/admin/setup-wizard/WelcomeStep.tsx +2 -2
- package/components/admin/styles/ColorsEditor.tsx +2 -2
- package/components/admin/styles/FontsEditor.tsx +6 -6
- package/components/admin/styles/GridLayoutEditor.tsx +9 -9
- package/components/admin/styles/LinksButtonsEditor.tsx +5 -5
- package/components/admin/styles/TypographyEditor.tsx +6 -6
- package/components/admin/styles/shared.tsx +68 -68
- package/components/blocks/AudioBlockRenderer.tsx +286 -0
- package/components/blocks/BeforeAfterBlockRenderer.tsx +274 -0
- package/components/blocks/MarqueeBlockRenderer.tsx +316 -0
- package/components/blocks/ProjectCarouselBlockRenderer.tsx +1 -1
- package/components/builder/BlockCardIcons.tsx +316 -227
- package/components/builder/BlockTypePicker.tsx +3 -1
- package/components/builder/BubbleIcons.tsx +90 -0
- package/components/builder/BuilderCanvas.tsx +2 -0
- package/components/builder/CanvasMinimap.tsx +2 -2
- package/components/builder/CoverSectionCanvas.tsx +363 -275
- package/components/builder/DeviceFrame.tsx +1 -1
- package/components/builder/DndWrapper.tsx +3 -3
- package/components/builder/InsertionLines.tsx +1 -1
- package/components/builder/SectionCardIcons.tsx +421 -320
- package/components/builder/SectionEditorBar.tsx +1 -1
- package/components/builder/SectionTypePicker.tsx +4 -4
- package/components/builder/SectionV2Canvas.tsx +20 -4
- package/components/builder/SectionV2Column.tsx +74 -68
- package/components/builder/SortableBlock.tsx +93 -73
- package/components/builder/SortableRow.tsx +27 -26
- package/components/builder/VirtualAssetGrid.tsx +2 -2
- package/components/builder/asset-browser/R2BrowserContent.tsx +34 -17
- package/components/builder/asset-browser/helpers.ts +4 -0
- package/components/builder/asset-browser/types.ts +2 -1
- package/components/builder/blockStyles.tsx +192 -173
- package/components/builder/color-picker/AlphaSlider.tsx +141 -141
- package/components/builder/color-picker/ColorInputs.tsx +105 -105
- package/components/builder/color-picker/EyedropperButton.tsx +74 -74
- package/components/builder/color-picker/HueSlider.tsx +124 -124
- package/components/builder/color-picker/SaturationCanvas.tsx +142 -142
- package/components/builder/color-picker/SwatchBar.tsx +93 -93
- package/components/builder/editors/AudioBlockEditor.tsx +242 -0
- package/components/builder/editors/BeforeAfterBlockEditor.tsx +360 -0
- package/components/builder/editors/ButtonBlockEditor.tsx +4 -4
- package/components/builder/editors/EnterAnimationPicker.tsx +2 -2
- package/components/builder/editors/HoverEffectPicker.tsx +2 -2
- package/components/builder/editors/ImageBlockEditor.tsx +2 -2
- package/components/builder/editors/ImageGridBlockEditor.tsx +4 -4
- package/components/builder/editors/MarqueeBlockEditor.tsx +621 -0
- package/components/builder/editors/ProjectCarouselBlockEditor.tsx +443 -443
- package/components/builder/editors/ProjectGridEditor.tsx +9 -9
- package/components/builder/editors/SpacerBlockEditor.tsx +5 -5
- package/components/builder/editors/StaggerSettings.tsx +109 -109
- package/components/builder/editors/TextBlockEditor.tsx +3 -3
- package/components/builder/editors/TextStylePicker.tsx +1 -1
- package/components/builder/editors/VideoBlockEditor.tsx +2 -2
- package/components/builder/editors/index.ts +11 -10
- package/components/builder/editors/shared.tsx +7 -7
- package/components/builder/live-preview/LiveAudioPreview.tsx +120 -0
- package/components/builder/live-preview/LiveBeforeAfterPreview.tsx +176 -0
- package/components/builder/live-preview/LiveImageGridPreview.tsx +10 -2
- package/components/builder/live-preview/LiveImagePreview.tsx +1 -1
- package/components/builder/live-preview/LiveMarqueePreview.tsx +39 -0
- package/components/builder/live-preview/LiveProjectCarouselPreview.tsx +1 -1
- package/components/builder/live-preview/LiveVideoPreview.tsx +1 -1
- package/components/builder/live-preview/ProjectCardWrapper.tsx +291 -291
- package/components/builder/settings-panel/AnimationTab.tsx +138 -138
- package/components/builder/settings-panel/BlockLayoutTab.tsx +7 -7
- package/components/builder/settings-panel/CardEntranceSection.tsx +114 -114
- package/components/builder/settings-panel/ColumnV2Settings.tsx +5 -5
- package/components/builder/settings-panel/CoverSectionLayoutTab.tsx +71 -71
- package/components/builder/settings-panel/CoverSectionSettings.tsx +335 -335
- package/components/builder/settings-panel/PageSettings.tsx +3 -3
- package/components/builder/settings-panel/ParallaxSlideSettings.tsx +2 -2
- package/components/builder/settings-panel/SectionV2AnimationTab.tsx +4 -4
- package/components/builder/settings-panel/SectionV2LayoutTab.tsx +356 -356
- package/components/builder/settings-panel/SectionV2Settings.tsx +14 -14
- package/components/builder/settings-panel/TRBLInputs.tsx +1 -1
- package/lib/animation/enter-types.ts +3 -0
- package/lib/animation/hover-effect-presets.ts +210 -210
- package/lib/animation/hover-effect-types.ts +3 -0
- package/lib/builder/block-registrations.ts +468 -335
- package/lib/builder/constants.ts +111 -111
- package/lib/builder/store-sections.ts +2 -2
- package/lib/builder/types-slices.ts +414 -414
- package/lib/builder/types.ts +6 -1
- package/lib/config/index.ts +27 -27
- package/lib/sanity/types.ts +156 -1
- 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 +12 -9
- package/sanity/schemas/blocks/marqueeBlock.ts +292 -0
- package/sanity/schemas/index.ts +120 -111
- package/styles/admin.css +85 -85
- package/styles/animations.css +237 -237
- package/styles/base.css +114 -114
|
@@ -1,331 +1,331 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import type { NavItem, PageListItem } from "../../../lib/sanity/types";
|
|
5
|
-
import { TOTAL_COLUMNS, getMaxSpan } from "./nav-builder-utils";
|
|
6
|
-
import ColorSwatchPicker, { usePaletteSwatches } from "../../builder/ColorSwatchPicker";
|
|
7
|
-
import {
|
|
8
|
-
Field,
|
|
9
|
-
TextInput,
|
|
10
|
-
SelectInput,
|
|
11
|
-
SegmentedControl,
|
|
12
|
-
CardSection,
|
|
13
|
-
Divider,
|
|
14
|
-
ContentIcon,
|
|
15
|
-
LinkIcon,
|
|
16
|
-
GridIcon,
|
|
17
|
-
StyleIcon,
|
|
18
|
-
} from "./NavSettingsFields";
|
|
19
|
-
import AssetBrowser from "../../../components/builder/AssetBrowser";
|
|
20
|
-
|
|
21
|
-
interface NavItemSettingsProps {
|
|
22
|
-
item: NavItem;
|
|
23
|
-
items: NavItem[];
|
|
24
|
-
activeTab: "settings" | "layout";
|
|
25
|
-
onUpdate: (updated: NavItem) => void;
|
|
26
|
-
pages: PageListItem[];
|
|
27
|
-
fonts: string[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default function NavItemSettings({
|
|
31
|
-
item,
|
|
32
|
-
items,
|
|
33
|
-
activeTab,
|
|
34
|
-
onUpdate,
|
|
35
|
-
pages,
|
|
36
|
-
fonts,
|
|
37
|
-
}: NavItemSettingsProps) {
|
|
38
|
-
const isLogo = item.type === "logo";
|
|
39
|
-
const maxSpan = getMaxSpan(items, item.grid_column, item._key);
|
|
40
|
-
const [showAssetBrowser, setShowAssetBrowser] = useState(false);
|
|
41
|
-
const [showLogoAssetBrowser, setShowLogoAssetBrowser] = useState(false);
|
|
42
|
-
const swatches = usePaletteSwatches();
|
|
43
|
-
|
|
44
|
-
const update = (partial: Partial<NavItem>) =>
|
|
45
|
-
onUpdate({ ...item, ...partial });
|
|
46
|
-
|
|
47
|
-
const updateOverride = (key: string, value: unknown) => {
|
|
48
|
-
const overrides = { ...item.style_overrides };
|
|
49
|
-
if (value === "" || value === undefined || value === null) {
|
|
50
|
-
delete (overrides as Record<string, unknown>)[key];
|
|
51
|
-
} else {
|
|
52
|
-
(overrides as Record<string, unknown>)[key] = value;
|
|
53
|
-
}
|
|
54
|
-
update({ style_overrides: overrides });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
if (activeTab === "settings") {
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
{/* Content / Logo card */}
|
|
61
|
-
<CardSection
|
|
62
|
-
title={isLogo ? "Logo" : "Content"}
|
|
63
|
-
icon={<ContentIcon />}
|
|
64
|
-
iconBg="#cffafe"
|
|
65
|
-
>
|
|
66
|
-
<Field label={isLogo ? "Text" : "Label"}>
|
|
67
|
-
<TextInput
|
|
68
|
-
value={item.label}
|
|
69
|
-
onChange={(v) => update({ label: v })}
|
|
70
|
-
placeholder={isLogo ? "Brand name" : "Link text"}
|
|
71
|
-
/>
|
|
72
|
-
</Field>
|
|
73
|
-
{isLogo && (
|
|
74
|
-
<Field label="Image">
|
|
75
|
-
<button
|
|
76
|
-
onClick={() => setShowLogoAssetBrowser(true)}
|
|
77
|
-
className="w-full py-4 px-2.5 bg-white border border-dashed border-neutral-200 rounded-lg text-neutral-400 text-[11px] cursor-pointer flex flex-col items-center gap-1 hover:border-[#
|
|
78
|
-
>
|
|
79
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
80
|
-
<rect x="2" y="4" width="16" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
|
81
|
-
<circle cx="10" cy="7.5" r="1.5" stroke="currentColor" strokeWidth="1.2" />
|
|
82
|
-
<path d="M6 13h4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" />
|
|
83
|
-
</svg>
|
|
84
|
-
{item.logo_image ? (
|
|
85
|
-
<span className="text-[#
|
|
86
|
-
{item.logo_image.split("/").pop()}
|
|
87
|
-
</span>
|
|
88
|
-
) : (
|
|
89
|
-
"Browse image..."
|
|
90
|
-
)}
|
|
91
|
-
</button>
|
|
92
|
-
{item.logo_image && (
|
|
93
|
-
<button
|
|
94
|
-
onClick={() => update({ logo_image: undefined })}
|
|
95
|
-
className="mt-1 text-[10px] text-red-400 hover:text-red-600 transition-colors"
|
|
96
|
-
>
|
|
97
|
-
Remove image
|
|
98
|
-
</button>
|
|
99
|
-
)}
|
|
100
|
-
</Field>
|
|
101
|
-
)}
|
|
102
|
-
</CardSection>
|
|
103
|
-
|
|
104
|
-
{/* Link card */}
|
|
105
|
-
<CardSection title="Link" icon={<LinkIcon />} iconBg="#ede9fe">
|
|
106
|
-
<Field label="Type">
|
|
107
|
-
<SegmentedControl
|
|
108
|
-
value={item.link_type}
|
|
109
|
-
onChange={(v) => update({ link_type: v as "internal" | "external" | "content" })}
|
|
110
|
-
options={[
|
|
111
|
-
{ value: "internal", label: "Page" },
|
|
112
|
-
{ value: "external", label: "URL" },
|
|
113
|
-
{ value: "content", label: "Content" },
|
|
114
|
-
]}
|
|
115
|
-
/>
|
|
116
|
-
</Field>
|
|
117
|
-
{item.link_type === "internal" ? (
|
|
118
|
-
<Field label="Page">
|
|
119
|
-
<SelectInput
|
|
120
|
-
value={item.internal_page?._id || ""}
|
|
121
|
-
onChange={(v) => {
|
|
122
|
-
const page = pages.find((p) => p._id === v);
|
|
123
|
-
update({
|
|
124
|
-
internal_page: page
|
|
125
|
-
? { _id: page._id, title: page.title, slug: page.slug, page_type: page.page_type }
|
|
126
|
-
: undefined,
|
|
127
|
-
});
|
|
128
|
-
}}
|
|
129
|
-
options={[
|
|
130
|
-
{ value: "", label: "— Select page —" },
|
|
131
|
-
...pages.map((p) => ({
|
|
132
|
-
value: p._id,
|
|
133
|
-
label: p.title || (typeof p.slug === "string" ? p.slug : p.slug.current),
|
|
134
|
-
})),
|
|
135
|
-
]}
|
|
136
|
-
/>
|
|
137
|
-
</Field>
|
|
138
|
-
) : item.link_type === "external" ? (
|
|
139
|
-
<Field label="URL">
|
|
140
|
-
<TextInput
|
|
141
|
-
value={item.external_url || ""}
|
|
142
|
-
onChange={(v) => update({ external_url: v })}
|
|
143
|
-
placeholder="https://..."
|
|
144
|
-
/>
|
|
145
|
-
</Field>
|
|
146
|
-
) : (
|
|
147
|
-
<>
|
|
148
|
-
<Field label="Media">
|
|
149
|
-
<SegmentedControl
|
|
150
|
-
value={item.content_type || "image"}
|
|
151
|
-
onChange={(v) => update({ content_type: v as "image" | "video-file" | "video-embed" })}
|
|
152
|
-
options={[
|
|
153
|
-
{ value: "image", label: "Image" },
|
|
154
|
-
{ value: "video-file", label: "Video" },
|
|
155
|
-
{ value: "video-embed", label: "Embed" },
|
|
156
|
-
]}
|
|
157
|
-
/>
|
|
158
|
-
</Field>
|
|
159
|
-
{(item.content_type || "image") !== "video-embed" ? (
|
|
160
|
-
<Field label="Asset">
|
|
161
|
-
<button
|
|
162
|
-
onClick={() => setShowAssetBrowser(true)}
|
|
163
|
-
className="w-full py-3 px-2.5 bg-white border border-dashed border-neutral-200 rounded-lg text-neutral-400 text-[11px] cursor-pointer flex flex-col items-center gap-1 hover:border-[#
|
|
164
|
-
>
|
|
165
|
-
<svg width="18" height="18" viewBox="0 0 20 20" fill="none">
|
|
166
|
-
<rect x="2" y="4" width="16" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
|
167
|
-
<circle cx="10" cy="7.5" r="1.5" stroke="currentColor" strokeWidth="1.2" />
|
|
168
|
-
<path d="M6 13h4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" />
|
|
169
|
-
</svg>
|
|
170
|
-
{item.content_asset ? (
|
|
171
|
-
<span className="text-[#
|
|
172
|
-
{item.content_asset.split("/").pop()}
|
|
173
|
-
</span>
|
|
174
|
-
) : (
|
|
175
|
-
"Browse asset..."
|
|
176
|
-
)}
|
|
177
|
-
</button>
|
|
178
|
-
</Field>
|
|
179
|
-
) : (
|
|
180
|
-
<Field label="URL">
|
|
181
|
-
<TextInput
|
|
182
|
-
value={item.content_url || ""}
|
|
183
|
-
onChange={(v) => update({ content_url: v })}
|
|
184
|
-
placeholder="https://youtube.com/watch?v=... or vimeo.com/..."
|
|
185
|
-
/>
|
|
186
|
-
</Field>
|
|
187
|
-
)}
|
|
188
|
-
</>
|
|
189
|
-
)}
|
|
190
|
-
</CardSection>
|
|
191
|
-
|
|
192
|
-
<AssetBrowser
|
|
193
|
-
open={showAssetBrowser}
|
|
194
|
-
onSelect={(path) => {
|
|
195
|
-
update({ content_asset: path });
|
|
196
|
-
setShowAssetBrowser(false);
|
|
197
|
-
}}
|
|
198
|
-
onClose={() => setShowAssetBrowser(false)}
|
|
199
|
-
filterType={item.content_type === "video-file" ? "video" : item.content_type === "image" ? "image" : "all"}
|
|
200
|
-
/>
|
|
201
|
-
|
|
202
|
-
{/* Logo image asset browser */}
|
|
203
|
-
<AssetBrowser
|
|
204
|
-
open={showLogoAssetBrowser}
|
|
205
|
-
onSelect={(path) => {
|
|
206
|
-
update({ logo_image: path });
|
|
207
|
-
setShowLogoAssetBrowser(false);
|
|
208
|
-
}}
|
|
209
|
-
onClose={() => setShowLogoAssetBrowser(false)}
|
|
210
|
-
filterType="image"
|
|
211
|
-
/>
|
|
212
|
-
|
|
213
|
-
<div className="h-2" />
|
|
214
|
-
</>
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// ── Layout tab ──
|
|
219
|
-
return (
|
|
220
|
-
<>
|
|
221
|
-
{/* Grid placement card */}
|
|
222
|
-
<CardSection title="Grid Placement" icon={<GridIcon />} iconBg="#dbeafe">
|
|
223
|
-
<Field label="Column">
|
|
224
|
-
<TextInput
|
|
225
|
-
value={item.grid_column}
|
|
226
|
-
onChange={(v) => {
|
|
227
|
-
const col = Math.max(1, Math.min(TOTAL_COLUMNS, parseInt(v) || 1));
|
|
228
|
-
update({ grid_column: col });
|
|
229
|
-
}}
|
|
230
|
-
type="number"
|
|
231
|
-
/>
|
|
232
|
-
</Field>
|
|
233
|
-
<Field label="Span">
|
|
234
|
-
<TextInput
|
|
235
|
-
value={item.column_span}
|
|
236
|
-
onChange={(v) => {
|
|
237
|
-
const span = Math.max(1, Math.min(maxSpan, parseInt(v) || 1));
|
|
238
|
-
update({ column_span: span });
|
|
239
|
-
}}
|
|
240
|
-
type="number"
|
|
241
|
-
/>
|
|
242
|
-
</Field>
|
|
243
|
-
<p className="text-[10px] text-neutral-400 mt-0.5 ml-[66px]">
|
|
244
|
-
Max available: {maxSpan} columns
|
|
245
|
-
</p>
|
|
246
|
-
</CardSection>
|
|
247
|
-
|
|
248
|
-
{/* Alignment card */}
|
|
249
|
-
<CardSection title="Alignment" icon={<GridIcon />} iconBg="#dbeafe">
|
|
250
|
-
<Field label="V. Align">
|
|
251
|
-
<SegmentedControl
|
|
252
|
-
value={item.style_overrides?.vertical_align || ""}
|
|
253
|
-
onChange={(v) => updateOverride("vertical_align", v || undefined)}
|
|
254
|
-
options={[
|
|
255
|
-
{ value: "", label: "Inherit" },
|
|
256
|
-
{ value: "top", label: "Top" },
|
|
257
|
-
{ value: "middle", label: "Mid" },
|
|
258
|
-
{ value: "bottom", label: "Bot" },
|
|
259
|
-
]}
|
|
260
|
-
/>
|
|
261
|
-
</Field>
|
|
262
|
-
</CardSection>
|
|
263
|
-
|
|
264
|
-
{/* Style overrides card */}
|
|
265
|
-
<CardSection title="Style Overrides" icon={<StyleIcon />} iconBg="#fef3c7">
|
|
266
|
-
<p className="text-[10px] text-neutral-400 italic mb-1.5">
|
|
267
|
-
Override general nav settings for this item
|
|
268
|
-
</p>
|
|
269
|
-
<Field label="Size">
|
|
270
|
-
<TextInput
|
|
271
|
-
value={item.style_overrides?.font_size ?? ""}
|
|
272
|
-
onChange={(v) => updateOverride("font_size", v ? parseInt(v) : undefined)}
|
|
273
|
-
placeholder="Inherit"
|
|
274
|
-
type="number"
|
|
275
|
-
/>
|
|
276
|
-
</Field>
|
|
277
|
-
<Field label="Weight">
|
|
278
|
-
<SelectInput
|
|
279
|
-
value={item.style_overrides?.font_weight || ""}
|
|
280
|
-
onChange={(v) => updateOverride("font_weight", v || undefined)}
|
|
281
|
-
options={[
|
|
282
|
-
{ value: "", label: "Inherit" },
|
|
283
|
-
{ value: "100", label: "100 · Thin" },
|
|
284
|
-
{ value: "200", label: "200 · Extra Light" },
|
|
285
|
-
{ value: "300", label: "300 · Light" },
|
|
286
|
-
{ value: "400", label: "400 · Normal" },
|
|
287
|
-
{ value: "500", label: "500 · Medium" },
|
|
288
|
-
{ value: "600", label: "600 · Semi Bold" },
|
|
289
|
-
{ value: "700", label: "700 · Bold" },
|
|
290
|
-
{ value: "800", label: "800 · Extra Bold" },
|
|
291
|
-
{ value: "900", label: "900 · Black" },
|
|
292
|
-
]}
|
|
293
|
-
/>
|
|
294
|
-
</Field>
|
|
295
|
-
<Field label="Font">
|
|
296
|
-
<SelectInput
|
|
297
|
-
value={item.style_overrides?.font_family || ""}
|
|
298
|
-
onChange={(v) => updateOverride("font_family", v || undefined)}
|
|
299
|
-
options={[
|
|
300
|
-
{ value: "", label: "Inherit" },
|
|
301
|
-
...fonts.map((f) => ({ value: f, label: f })),
|
|
302
|
-
]}
|
|
303
|
-
/>
|
|
304
|
-
</Field>
|
|
305
|
-
<Divider />
|
|
306
|
-
<Field label="Color">
|
|
307
|
-
<ColorSwatchPicker
|
|
308
|
-
value={item.style_overrides?.color || ""}
|
|
309
|
-
onChange={(v) => updateOverride("color", (typeof v === "string" ? v : "") || undefined)}
|
|
310
|
-
swatches={swatches}
|
|
311
|
-
/>
|
|
312
|
-
</Field>
|
|
313
|
-
<Field label="Case">
|
|
314
|
-
<SelectInput
|
|
315
|
-
value={item.style_overrides?.text_transform || ""}
|
|
316
|
-
onChange={(v) => updateOverride("text_transform", v || undefined)}
|
|
317
|
-
options={[
|
|
318
|
-
{ value: "", label: "Inherit" },
|
|
319
|
-
{ value: "uppercase", label: "UPPERCASE" },
|
|
320
|
-
{ value: "none", label: "None" },
|
|
321
|
-
{ value: "lowercase", label: "lowercase" },
|
|
322
|
-
{ value: "capitalize", label: "Capitalize" },
|
|
323
|
-
]}
|
|
324
|
-
/>
|
|
325
|
-
</Field>
|
|
326
|
-
</CardSection>
|
|
327
|
-
|
|
328
|
-
<div className="h-2" />
|
|
329
|
-
</>
|
|
330
|
-
);
|
|
331
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import type { NavItem, PageListItem } from "../../../lib/sanity/types";
|
|
5
|
+
import { TOTAL_COLUMNS, getMaxSpan } from "./nav-builder-utils";
|
|
6
|
+
import ColorSwatchPicker, { usePaletteSwatches } from "../../builder/ColorSwatchPicker";
|
|
7
|
+
import {
|
|
8
|
+
Field,
|
|
9
|
+
TextInput,
|
|
10
|
+
SelectInput,
|
|
11
|
+
SegmentedControl,
|
|
12
|
+
CardSection,
|
|
13
|
+
Divider,
|
|
14
|
+
ContentIcon,
|
|
15
|
+
LinkIcon,
|
|
16
|
+
GridIcon,
|
|
17
|
+
StyleIcon,
|
|
18
|
+
} from "./NavSettingsFields";
|
|
19
|
+
import AssetBrowser from "../../../components/builder/AssetBrowser";
|
|
20
|
+
|
|
21
|
+
interface NavItemSettingsProps {
|
|
22
|
+
item: NavItem;
|
|
23
|
+
items: NavItem[];
|
|
24
|
+
activeTab: "settings" | "layout";
|
|
25
|
+
onUpdate: (updated: NavItem) => void;
|
|
26
|
+
pages: PageListItem[];
|
|
27
|
+
fonts: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function NavItemSettings({
|
|
31
|
+
item,
|
|
32
|
+
items,
|
|
33
|
+
activeTab,
|
|
34
|
+
onUpdate,
|
|
35
|
+
pages,
|
|
36
|
+
fonts,
|
|
37
|
+
}: NavItemSettingsProps) {
|
|
38
|
+
const isLogo = item.type === "logo";
|
|
39
|
+
const maxSpan = getMaxSpan(items, item.grid_column, item._key);
|
|
40
|
+
const [showAssetBrowser, setShowAssetBrowser] = useState(false);
|
|
41
|
+
const [showLogoAssetBrowser, setShowLogoAssetBrowser] = useState(false);
|
|
42
|
+
const swatches = usePaletteSwatches();
|
|
43
|
+
|
|
44
|
+
const update = (partial: Partial<NavItem>) =>
|
|
45
|
+
onUpdate({ ...item, ...partial });
|
|
46
|
+
|
|
47
|
+
const updateOverride = (key: string, value: unknown) => {
|
|
48
|
+
const overrides = { ...item.style_overrides };
|
|
49
|
+
if (value === "" || value === undefined || value === null) {
|
|
50
|
+
delete (overrides as Record<string, unknown>)[key];
|
|
51
|
+
} else {
|
|
52
|
+
(overrides as Record<string, unknown>)[key] = value;
|
|
53
|
+
}
|
|
54
|
+
update({ style_overrides: overrides });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (activeTab === "settings") {
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{/* Content / Logo card */}
|
|
61
|
+
<CardSection
|
|
62
|
+
title={isLogo ? "Logo" : "Content"}
|
|
63
|
+
icon={<ContentIcon />}
|
|
64
|
+
iconBg="#cffafe"
|
|
65
|
+
>
|
|
66
|
+
<Field label={isLogo ? "Text" : "Label"}>
|
|
67
|
+
<TextInput
|
|
68
|
+
value={item.label}
|
|
69
|
+
onChange={(v) => update({ label: v })}
|
|
70
|
+
placeholder={isLogo ? "Brand name" : "Link text"}
|
|
71
|
+
/>
|
|
72
|
+
</Field>
|
|
73
|
+
{isLogo && (
|
|
74
|
+
<Field label="Image">
|
|
75
|
+
<button
|
|
76
|
+
onClick={() => setShowLogoAssetBrowser(true)}
|
|
77
|
+
className="w-full py-4 px-2.5 bg-white border border-dashed border-neutral-200 rounded-lg text-neutral-400 text-[11px] cursor-pointer flex flex-col items-center gap-1 hover:border-[#3580f9]/40 hover:bg-[#3580f9]/[0.02] transition-colors"
|
|
78
|
+
>
|
|
79
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
80
|
+
<rect x="2" y="4" width="16" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
|
81
|
+
<circle cx="10" cy="7.5" r="1.5" stroke="currentColor" strokeWidth="1.2" />
|
|
82
|
+
<path d="M6 13h4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" />
|
|
83
|
+
</svg>
|
|
84
|
+
{item.logo_image ? (
|
|
85
|
+
<span className="text-[#3580f9] truncate max-w-full">
|
|
86
|
+
{item.logo_image.split("/").pop()}
|
|
87
|
+
</span>
|
|
88
|
+
) : (
|
|
89
|
+
"Browse image..."
|
|
90
|
+
)}
|
|
91
|
+
</button>
|
|
92
|
+
{item.logo_image && (
|
|
93
|
+
<button
|
|
94
|
+
onClick={() => update({ logo_image: undefined })}
|
|
95
|
+
className="mt-1 text-[10px] text-red-400 hover:text-red-600 transition-colors"
|
|
96
|
+
>
|
|
97
|
+
Remove image
|
|
98
|
+
</button>
|
|
99
|
+
)}
|
|
100
|
+
</Field>
|
|
101
|
+
)}
|
|
102
|
+
</CardSection>
|
|
103
|
+
|
|
104
|
+
{/* Link card */}
|
|
105
|
+
<CardSection title="Link" icon={<LinkIcon />} iconBg="#ede9fe">
|
|
106
|
+
<Field label="Type">
|
|
107
|
+
<SegmentedControl
|
|
108
|
+
value={item.link_type}
|
|
109
|
+
onChange={(v) => update({ link_type: v as "internal" | "external" | "content" })}
|
|
110
|
+
options={[
|
|
111
|
+
{ value: "internal", label: "Page" },
|
|
112
|
+
{ value: "external", label: "URL" },
|
|
113
|
+
{ value: "content", label: "Content" },
|
|
114
|
+
]}
|
|
115
|
+
/>
|
|
116
|
+
</Field>
|
|
117
|
+
{item.link_type === "internal" ? (
|
|
118
|
+
<Field label="Page">
|
|
119
|
+
<SelectInput
|
|
120
|
+
value={item.internal_page?._id || ""}
|
|
121
|
+
onChange={(v) => {
|
|
122
|
+
const page = pages.find((p) => p._id === v);
|
|
123
|
+
update({
|
|
124
|
+
internal_page: page
|
|
125
|
+
? { _id: page._id, title: page.title, slug: page.slug, page_type: page.page_type }
|
|
126
|
+
: undefined,
|
|
127
|
+
});
|
|
128
|
+
}}
|
|
129
|
+
options={[
|
|
130
|
+
{ value: "", label: "— Select page —" },
|
|
131
|
+
...pages.map((p) => ({
|
|
132
|
+
value: p._id,
|
|
133
|
+
label: p.title || (typeof p.slug === "string" ? p.slug : p.slug.current),
|
|
134
|
+
})),
|
|
135
|
+
]}
|
|
136
|
+
/>
|
|
137
|
+
</Field>
|
|
138
|
+
) : item.link_type === "external" ? (
|
|
139
|
+
<Field label="URL">
|
|
140
|
+
<TextInput
|
|
141
|
+
value={item.external_url || ""}
|
|
142
|
+
onChange={(v) => update({ external_url: v })}
|
|
143
|
+
placeholder="https://..."
|
|
144
|
+
/>
|
|
145
|
+
</Field>
|
|
146
|
+
) : (
|
|
147
|
+
<>
|
|
148
|
+
<Field label="Media">
|
|
149
|
+
<SegmentedControl
|
|
150
|
+
value={item.content_type || "image"}
|
|
151
|
+
onChange={(v) => update({ content_type: v as "image" | "video-file" | "video-embed" })}
|
|
152
|
+
options={[
|
|
153
|
+
{ value: "image", label: "Image" },
|
|
154
|
+
{ value: "video-file", label: "Video" },
|
|
155
|
+
{ value: "video-embed", label: "Embed" },
|
|
156
|
+
]}
|
|
157
|
+
/>
|
|
158
|
+
</Field>
|
|
159
|
+
{(item.content_type || "image") !== "video-embed" ? (
|
|
160
|
+
<Field label="Asset">
|
|
161
|
+
<button
|
|
162
|
+
onClick={() => setShowAssetBrowser(true)}
|
|
163
|
+
className="w-full py-3 px-2.5 bg-white border border-dashed border-neutral-200 rounded-lg text-neutral-400 text-[11px] cursor-pointer flex flex-col items-center gap-1 hover:border-[#3580f9]/40 hover:bg-[#3580f9]/[0.02] transition-colors"
|
|
164
|
+
>
|
|
165
|
+
<svg width="18" height="18" viewBox="0 0 20 20" fill="none">
|
|
166
|
+
<rect x="2" y="4" width="16" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
|
167
|
+
<circle cx="10" cy="7.5" r="1.5" stroke="currentColor" strokeWidth="1.2" />
|
|
168
|
+
<path d="M6 13h4" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" />
|
|
169
|
+
</svg>
|
|
170
|
+
{item.content_asset ? (
|
|
171
|
+
<span className="text-[#3580f9] truncate max-w-full">
|
|
172
|
+
{item.content_asset.split("/").pop()}
|
|
173
|
+
</span>
|
|
174
|
+
) : (
|
|
175
|
+
"Browse asset..."
|
|
176
|
+
)}
|
|
177
|
+
</button>
|
|
178
|
+
</Field>
|
|
179
|
+
) : (
|
|
180
|
+
<Field label="URL">
|
|
181
|
+
<TextInput
|
|
182
|
+
value={item.content_url || ""}
|
|
183
|
+
onChange={(v) => update({ content_url: v })}
|
|
184
|
+
placeholder="https://youtube.com/watch?v=... or vimeo.com/..."
|
|
185
|
+
/>
|
|
186
|
+
</Field>
|
|
187
|
+
)}
|
|
188
|
+
</>
|
|
189
|
+
)}
|
|
190
|
+
</CardSection>
|
|
191
|
+
|
|
192
|
+
<AssetBrowser
|
|
193
|
+
open={showAssetBrowser}
|
|
194
|
+
onSelect={(path) => {
|
|
195
|
+
update({ content_asset: path });
|
|
196
|
+
setShowAssetBrowser(false);
|
|
197
|
+
}}
|
|
198
|
+
onClose={() => setShowAssetBrowser(false)}
|
|
199
|
+
filterType={item.content_type === "video-file" ? "video" : item.content_type === "image" ? "image" : "all"}
|
|
200
|
+
/>
|
|
201
|
+
|
|
202
|
+
{/* Logo image asset browser */}
|
|
203
|
+
<AssetBrowser
|
|
204
|
+
open={showLogoAssetBrowser}
|
|
205
|
+
onSelect={(path) => {
|
|
206
|
+
update({ logo_image: path });
|
|
207
|
+
setShowLogoAssetBrowser(false);
|
|
208
|
+
}}
|
|
209
|
+
onClose={() => setShowLogoAssetBrowser(false)}
|
|
210
|
+
filterType="image"
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<div className="h-2" />
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ── Layout tab ──
|
|
219
|
+
return (
|
|
220
|
+
<>
|
|
221
|
+
{/* Grid placement card */}
|
|
222
|
+
<CardSection title="Grid Placement" icon={<GridIcon />} iconBg="#dbeafe">
|
|
223
|
+
<Field label="Column">
|
|
224
|
+
<TextInput
|
|
225
|
+
value={item.grid_column}
|
|
226
|
+
onChange={(v) => {
|
|
227
|
+
const col = Math.max(1, Math.min(TOTAL_COLUMNS, parseInt(v) || 1));
|
|
228
|
+
update({ grid_column: col });
|
|
229
|
+
}}
|
|
230
|
+
type="number"
|
|
231
|
+
/>
|
|
232
|
+
</Field>
|
|
233
|
+
<Field label="Span">
|
|
234
|
+
<TextInput
|
|
235
|
+
value={item.column_span}
|
|
236
|
+
onChange={(v) => {
|
|
237
|
+
const span = Math.max(1, Math.min(maxSpan, parseInt(v) || 1));
|
|
238
|
+
update({ column_span: span });
|
|
239
|
+
}}
|
|
240
|
+
type="number"
|
|
241
|
+
/>
|
|
242
|
+
</Field>
|
|
243
|
+
<p className="text-[10px] text-neutral-400 mt-0.5 ml-[66px]">
|
|
244
|
+
Max available: {maxSpan} columns
|
|
245
|
+
</p>
|
|
246
|
+
</CardSection>
|
|
247
|
+
|
|
248
|
+
{/* Alignment card */}
|
|
249
|
+
<CardSection title="Alignment" icon={<GridIcon />} iconBg="#dbeafe">
|
|
250
|
+
<Field label="V. Align">
|
|
251
|
+
<SegmentedControl
|
|
252
|
+
value={item.style_overrides?.vertical_align || ""}
|
|
253
|
+
onChange={(v) => updateOverride("vertical_align", v || undefined)}
|
|
254
|
+
options={[
|
|
255
|
+
{ value: "", label: "Inherit" },
|
|
256
|
+
{ value: "top", label: "Top" },
|
|
257
|
+
{ value: "middle", label: "Mid" },
|
|
258
|
+
{ value: "bottom", label: "Bot" },
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
</Field>
|
|
262
|
+
</CardSection>
|
|
263
|
+
|
|
264
|
+
{/* Style overrides card */}
|
|
265
|
+
<CardSection title="Style Overrides" icon={<StyleIcon />} iconBg="#fef3c7">
|
|
266
|
+
<p className="text-[10px] text-neutral-400 italic mb-1.5">
|
|
267
|
+
Override general nav settings for this item
|
|
268
|
+
</p>
|
|
269
|
+
<Field label="Size">
|
|
270
|
+
<TextInput
|
|
271
|
+
value={item.style_overrides?.font_size ?? ""}
|
|
272
|
+
onChange={(v) => updateOverride("font_size", v ? parseInt(v) : undefined)}
|
|
273
|
+
placeholder="Inherit"
|
|
274
|
+
type="number"
|
|
275
|
+
/>
|
|
276
|
+
</Field>
|
|
277
|
+
<Field label="Weight">
|
|
278
|
+
<SelectInput
|
|
279
|
+
value={item.style_overrides?.font_weight || ""}
|
|
280
|
+
onChange={(v) => updateOverride("font_weight", v || undefined)}
|
|
281
|
+
options={[
|
|
282
|
+
{ value: "", label: "Inherit" },
|
|
283
|
+
{ value: "100", label: "100 · Thin" },
|
|
284
|
+
{ value: "200", label: "200 · Extra Light" },
|
|
285
|
+
{ value: "300", label: "300 · Light" },
|
|
286
|
+
{ value: "400", label: "400 · Normal" },
|
|
287
|
+
{ value: "500", label: "500 · Medium" },
|
|
288
|
+
{ value: "600", label: "600 · Semi Bold" },
|
|
289
|
+
{ value: "700", label: "700 · Bold" },
|
|
290
|
+
{ value: "800", label: "800 · Extra Bold" },
|
|
291
|
+
{ value: "900", label: "900 · Black" },
|
|
292
|
+
]}
|
|
293
|
+
/>
|
|
294
|
+
</Field>
|
|
295
|
+
<Field label="Font">
|
|
296
|
+
<SelectInput
|
|
297
|
+
value={item.style_overrides?.font_family || ""}
|
|
298
|
+
onChange={(v) => updateOverride("font_family", v || undefined)}
|
|
299
|
+
options={[
|
|
300
|
+
{ value: "", label: "Inherit" },
|
|
301
|
+
...fonts.map((f) => ({ value: f, label: f })),
|
|
302
|
+
]}
|
|
303
|
+
/>
|
|
304
|
+
</Field>
|
|
305
|
+
<Divider />
|
|
306
|
+
<Field label="Color">
|
|
307
|
+
<ColorSwatchPicker
|
|
308
|
+
value={item.style_overrides?.color || ""}
|
|
309
|
+
onChange={(v) => updateOverride("color", (typeof v === "string" ? v : "") || undefined)}
|
|
310
|
+
swatches={swatches}
|
|
311
|
+
/>
|
|
312
|
+
</Field>
|
|
313
|
+
<Field label="Case">
|
|
314
|
+
<SelectInput
|
|
315
|
+
value={item.style_overrides?.text_transform || ""}
|
|
316
|
+
onChange={(v) => updateOverride("text_transform", v || undefined)}
|
|
317
|
+
options={[
|
|
318
|
+
{ value: "", label: "Inherit" },
|
|
319
|
+
{ value: "uppercase", label: "UPPERCASE" },
|
|
320
|
+
{ value: "none", label: "None" },
|
|
321
|
+
{ value: "lowercase", label: "lowercase" },
|
|
322
|
+
{ value: "capitalize", label: "Capitalize" },
|
|
323
|
+
]}
|
|
324
|
+
/>
|
|
325
|
+
</Field>
|
|
326
|
+
</CardSection>
|
|
327
|
+
|
|
328
|
+
<div className="h-2" />
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
}
|