From 54a3a15f686e7633fdfc6aa9a69f6b25f650eb39 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Thu, 4 Jun 2026 15:10:37 +0700 Subject: [PATCH] feat(pages): Page Editor module fixing and improvements --- .../components/SectionBackgroundRenderer.tsx | 26 ++ .../Pages/components/CanvasRenderer.tsx | 4 +- .../Pages/components/CanvasSection.tsx | 4 +- .../src/routes/Appearance/Pages/index.tsx | 63 +++-- .../Appearance/Pages/schema/sectionSchema.ts | 2 + .../Pages/store/usePageEditorStore.ts | 111 ++++++++- .../components/SectionBackgroundRenderer.tsx | 26 ++ .../src/components/SharedContentLayout.tsx | 228 ++++++------------ customer-spa/src/pages/DynamicPage/index.tsx | 74 ++++-- .../sections/BentoCategoryGrid.tsx | 10 +- .../DynamicPage/sections/CTABannerSection.tsx | 47 +--- .../sections/ContactFormSection.tsx | 35 +-- .../DynamicPage/sections/ContentSection.tsx | 28 +-- .../sections/FeatureGridSection.tsx | 45 ++-- .../DynamicPage/sections/HeroSection.tsx | 34 ++- .../DynamicPage/sections/ImageTextSection.tsx | 30 +-- .../DynamicPage/sections/MarqueeBanner.tsx | 18 +- .../DynamicPage/sections/ProductCarousel.tsx | 49 +++- .../DynamicPage/sections/ShoppableImage.tsx | 14 +- customer-spa/tailwind.config.js | 5 + includes/Api/PagesController.php | 4 + 21 files changed, 489 insertions(+), 368 deletions(-) create mode 100644 admin-spa/src/components/SectionBackgroundRenderer.tsx create mode 100644 customer-spa/src/components/SectionBackgroundRenderer.tsx diff --git a/admin-spa/src/components/SectionBackgroundRenderer.tsx b/admin-spa/src/components/SectionBackgroundRenderer.tsx new file mode 100644 index 0000000..6b74b4f --- /dev/null +++ b/admin-spa/src/components/SectionBackgroundRenderer.tsx @@ -0,0 +1,26 @@ +import { SectionStyleResult } from '@/lib/sectionStyles'; + +interface SectionBackgroundRendererProps { + bg: SectionStyleResult; +} + +export function SectionBackgroundRenderer({ bg }: SectionBackgroundRendererProps) { + if (!bg.backgroundImage) return null; + + return ( +
+ + {bg.hasOverlay && ( +
+ )} +
+ ); +} diff --git a/admin-spa/src/routes/Appearance/Pages/components/CanvasRenderer.tsx b/admin-spa/src/routes/Appearance/Pages/components/CanvasRenderer.tsx index ac1fe63..f3911c1 100644 --- a/admin-spa/src/routes/Appearance/Pages/components/CanvasRenderer.tsx +++ b/admin-spa/src/routes/Appearance/Pages/components/CanvasRenderer.tsx @@ -207,10 +207,10 @@ export function CanvasRenderer({ >
{sections.length === 0 ? ( diff --git a/admin-spa/src/routes/Appearance/Pages/components/CanvasSection.tsx b/admin-spa/src/routes/Appearance/Pages/components/CanvasSection.tsx index 529db7b..e85f77a 100644 --- a/admin-spa/src/routes/Appearance/Pages/components/CanvasSection.tsx +++ b/admin-spa/src/routes/Appearance/Pages/components/CanvasSection.tsx @@ -159,8 +159,8 @@ export function CanvasSection({
) : (
{children}
diff --git a/admin-spa/src/routes/Appearance/Pages/index.tsx b/admin-spa/src/routes/Appearance/Pages/index.tsx index 4430f5f..383250f 100644 --- a/admin-spa/src/routes/Appearance/Pages/index.tsx +++ b/admin-spa/src/routes/Appearance/Pages/index.tsx @@ -3,7 +3,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { api } from '@/lib/api'; import { __ } from '@/lib/i18n'; import { Button } from '@/components/ui/button'; -import { Plus, Layout, Undo2, Save, Maximize2, Minimize2 } from 'lucide-react'; +import { Plus, Layout, Undo2, Redo2, Save, Maximize2, Minimize2 } from 'lucide-react'; import { toast } from 'sonner'; import { AlertDialog, @@ -50,6 +50,11 @@ export default function AppearancePages() { setInspectorCollapsed, setAvailableSources, setIsLoading, + undo, + redo, + past, + future, + updateCurrentPage, addSection, deleteSection, duplicateSection, @@ -61,6 +66,7 @@ export default function AppearancePages() { updateSectionStyles, updateElementStyles, markAsSaved, + markAsChanged, setAsSpaLanding, unsetSpaLanding, } = usePageEditorStore(); @@ -160,7 +166,10 @@ export default function AppearancePages() { const endpoint = currentPage.type === 'page' ? `/pages/${currentPage.slug}` : `/templates/${currentPage.cpt}`; - return api.post(endpoint, { sections }); + return api.post(endpoint, { + sections, + container_width: currentPage.containerWidth + }); }, onSuccess: () => { toast.success(__('Page saved successfully')); @@ -332,17 +341,40 @@ export default function AppearancePages() { {isFullscreen ? : } {hasUnsavedChanges && ( - <> - {__('Unsaved changes')} - - + {__('Unsaved changes')} + )} + +
+ + +
+ + {hasUnsavedChanges && ( + )}