From f45adf53e017638af98f707517d4a1f756a90549 Mon Sep 17 00:00:00 2001 From: swve Date: Wed, 5 Mar 2025 12:03:24 +0100 Subject: [PATCH] feat: enhance hero section editor with tabbed interface and improved content management --- .../Org/OrgEditLanding/OrgEditLanding.tsx | 1085 +++++++++-------- 1 file changed, 556 insertions(+), 529 deletions(-) diff --git a/apps/web/components/Dashboard/Pages/Org/OrgEditLanding/OrgEditLanding.tsx b/apps/web/components/Dashboard/Pages/Org/OrgEditLanding/OrgEditLanding.tsx index a2dc2026..8e9d6b53 100644 --- a/apps/web/components/Dashboard/Pages/Org/OrgEditLanding/OrgEditLanding.tsx +++ b/apps/web/components/Dashboard/Pages/Org/OrgEditLanding/OrgEditLanding.tsx @@ -1,7 +1,7 @@ 'use client' import React from 'react' import { LandingObject, LandingSection, LandingHeroSection, LandingTextAndImageSection, LandingLogos, LandingPeople, LandingBackground, LandingButton, LandingHeading, LandingImage, LandingFeaturedCourses } from './landing_types' -import { Plus, Eye, ArrowUpDown, Trash2, GripVertical, LayoutTemplate, ImageIcon, Users, Award, ArrowRight, Edit, Link, Upload, Save, BookOpen } from 'lucide-react' +import { Plus, Eye, ArrowUpDown, Trash2, GripVertical, LayoutTemplate, ImageIcon, Users, Award, ArrowRight, Edit, Link, Upload, Save, BookOpen, TextIcon } from 'lucide-react' import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd' import { Input } from "@components/ui/input" import { Textarea } from "@components/ui/textarea" @@ -15,6 +15,7 @@ import { getOrgLandingMediaDirectory } from '@services/media/media' import { getOrgCourses } from '@services/courses/courses' import toast from 'react-hot-toast' import useSWR from 'swr' +import { Tabs, TabsList, TabsTrigger, TabsContent } from "@components/ui/tabs" const SECTION_TYPES = { hero: { @@ -504,7 +505,7 @@ const HeroSectionEditor: React.FC<{
{/* Title */}
- +
- {/* Background */} -
-
- - -
+ + + + + Content + + + + Background + + + - +
- {section.background.image && ( -
- Background preview + )} + + {section.background.type === 'image' && ( +
+
+ +
+ +
- )} + {section.background.image && ( +
+ Background preview +
+ )} +
-
- )} -
+ )} + - {/* Heading */} -
-
- - onChange({ - ...section, - heading: { ...section.heading, text: e.target.value } - })} - placeholder="Enter heading text" - /> -
-
- -
- onChange({ - ...section, - heading: { ...section.heading, color: e.target.value } - })} - className="w-20 h-10 p-1" - /> - onChange({ - ...section, - heading: { ...section.heading, color: e.target.value } - })} - placeholder="#000000" - className="font-mono" - /> -
-
-
- - {/* Subheading */} -
-
- - onChange({ - ...section, - subheading: { ...section.subheading, text: e.target.value } - })} - placeholder="Enter subheading text" - /> -
-
- -
- onChange({ - ...section, - subheading: { ...section.subheading, color: e.target.value } - })} - className="w-20 h-10 p-1" - /> - onChange({ - ...section, - subheading: { ...section.subheading, color: e.target.value } - })} - placeholder="#666666" - className="font-mono" - /> -
-
-
- - {/* Buttons */} -
- -
- {section.buttons.map((button, index) => ( -
-
- { - const newButtons = [...section.buttons] - newButtons[index] = { ...button, text: e.target.value } + +
+ {section.buttons.map((button, index) => ( +
+
+ + { + const newButtons = [...section.buttons] + newButtons[index] = { ...button, text: e.target.value } + onChange({ ...section, buttons: newButtons }) + }} + placeholder="Button text" + /> +
+
+ + { + const newButtons = [...section.buttons] + newButtons[index] = { ...button, color: e.target.value } + onChange({ ...section, buttons: newButtons }) + }} + className="w-full h-8 p-1" + /> +
+
+ + { + const newButtons = [...section.buttons] + newButtons[index] = { ...button, background: e.target.value } + onChange({ ...section, buttons: newButtons }) + }} + className="w-full h-8 p-1" + /> +
+
+
+
+ +
+ + { + const newButtons = [...section.buttons] + newButtons[index] = { ...button, link: e.target.value } + onChange({ ...section, buttons: newButtons }) + }} + placeholder="Button link" + /> +
+
+
-
-
- - { - const newButtons = [...section.buttons] - newButtons[index] = { ...button, link: e.target.value } - onChange({ ...section, buttons: newButtons }) - }} - placeholder="Button link" - /> -
+ className="text-red-500 hover:text-red-600 hover:bg-red-50 self-start mt-8" + > + +
+ ))} + {section.buttons.length < 2 && ( -
- ))} - {section.buttons.length < 2 && ( - - )} -
-
- - {/* Illustration */} -
- -
-
- - { - if (e.target.value) { + const newButton: LandingButton = { + text: 'New Button', + link: '#', + color: '#ffffff', + background: '#000000' + } onChange({ ...section, - illustration: { - image: { url: e.target.value, alt: section.illustration?.image.alt || '' }, - position: 'left', - verticalAlign: 'center', - size: 'medium' - } + buttons: [...section.buttons, newButton] }) - } - }} - placeholder="Illustration URL" - /> - { - if (section.illustration?.image.url) { - onChange({ + }} + className="w-full" + > + + Add Button + + )} +
+ + + +
+
+ + { + if (e.target.value) { + onChange({ + ...section, + illustration: { + image: { url: e.target.value, alt: section.illustration?.image.alt || '' }, + position: 'left', + verticalAlign: 'center', + size: 'medium' + } + }) + } + }} + placeholder="Illustration URL" + /> + { + if (section.illustration?.image.url) { + onChange({ + ...section, + illustration: { + ...section.illustration, + image: { ...section.illustration.image, alt: e.target.value } + } + }) + } + }} + placeholder="Alt text" + /> + onChange({ + ...section, + illustration: { + image: { url, alt: section.illustration?.image.alt || '' }, + position: 'left', + verticalAlign: 'center', + size: 'medium' + } + })} + buttonText="Upload Illustration" + /> + {section.illustration?.image.url && ( + {section.illustration?.image.alt} + )} +
+ +
+
+ + +
+ +
+ + +
+
+ {section.illustration?.image.url && ( - {section.illustration?.image.alt} + )}
- -
-
- - -
- -
- - -
-
- - {section.illustration?.image.url && ( - - )} -
-
+ +
)