From 0122caa168ed7da011551b6e9701c52455cbb911 Mon Sep 17 00:00:00 2001 From: JOYCEQL <1449239013@qq.com> Date: Tue, 24 Dec 2024 18:37:30 +0800 Subject: [PATCH] feat: preview click to section --- .../src/components/editor/EditorHeader.tsx | 20 ------------------- .../src/components/preview/BaseInfo.tsx | 13 ++++++++---- .../src/components/preview/CustomSection.tsx | 7 +++++++ .../components/preview/EducationSection.tsx | 12 +++++++++++ .../components/preview/ExperienceSection.tsx | 9 +++++++-- .../src/components/preview/ProjectSection.tsx | 7 ++++++- .../src/components/preview/SkillPanel.tsx | 9 ++++++--- 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/apps/fronted/src/components/editor/EditorHeader.tsx b/apps/fronted/src/components/editor/EditorHeader.tsx index 99b4909..d3dbe3f 100644 --- a/apps/fronted/src/components/editor/EditorHeader.tsx +++ b/apps/fronted/src/components/editor/EditorHeader.tsx @@ -52,26 +52,6 @@ export function EditorHeader({ isMobile }: EditorHeaderProps) { Magic Resume
- - {/* 在移动端隐藏导航按钮 */} -
- {visibleSections?.map((section) => ( - setActiveSection(section.id)} - > - {section.icon} - {section.title} - - ))} -
diff --git a/apps/fronted/src/components/preview/BaseInfo.tsx b/apps/fronted/src/components/preview/BaseInfo.tsx index 87905bd..73ddc8e 100644 --- a/apps/fronted/src/components/preview/BaseInfo.tsx +++ b/apps/fronted/src/components/preview/BaseInfo.tsx @@ -8,6 +8,7 @@ import { GlobalSettings, } from "@/types/resume"; import { ResumeTemplate } from "@/types/template"; +import { useResumeStore } from "@/store/useResumeStore"; interface BaseInfoProps { basic: BasicInfo | undefined; @@ -22,6 +23,7 @@ const BaseInfo = ({ layout, template, }: BaseInfoProps) => { + const { setActiveSection } = useResumeStore(); const useIconMode = globalSettings?.useIconMode ?? false; const getIcon = (iconName: string | undefined) => { @@ -271,11 +273,14 @@ const BaseInfo = ({
); - if (layout === "between") { - return BetweenContent; - } + const containerClass = + "hover:cursor-pointer hover:bg-gray-100 rounded-md transition-all duration-300 ease-in-out hover:shadow-md"; - return CenterContent; + return ( +
setActiveSection("basic")}> + {layout === "between" ? BetweenContent : CenterContent} +
+ ); }; export default BaseInfo; diff --git a/apps/fronted/src/components/preview/CustomSection.tsx b/apps/fronted/src/components/preview/CustomSection.tsx index bdf4947..d757e58 100644 --- a/apps/fronted/src/components/preview/CustomSection.tsx +++ b/apps/fronted/src/components/preview/CustomSection.tsx @@ -2,6 +2,7 @@ import { AnimatePresence, motion } from "framer-motion"; import SectionTitle from "./SectionTitle"; import { GlobalSettings, CustomItem } from "@/types/resume"; +import { useResumeStore } from "@/store/useResumeStore"; interface CustomSectionProps { sectionId: string; @@ -11,20 +12,26 @@ interface CustomSectionProps { } const CustomSection = ({ + sectionId, title, items, globalSettings, }: CustomSectionProps) => { + const { setActiveSection } = useResumeStore(); const visibleItems = items.filter((item) => { return item.visible && (item.title || item.description); }); return ( { + setActiveSection(sectionId); + }} > { + const { setActiveSection } = useResumeStore(); const visibleEducation = education?.filter((edu) => edu.visible); return ( { + setActiveSection("education"); + }} > = ({ experiences, globalSettings, }) => { - if (!experiences?.length) return null; + const { setActiveSection } = useResumeStore(); - const visibleExperiences = experiences.filter( + const visibleExperiences = experiences?.filter( (experience) => experience.visible ); return ( { + setActiveSection("experience"); + }} >
diff --git a/apps/fronted/src/components/preview/ProjectSection.tsx b/apps/fronted/src/components/preview/ProjectSection.tsx index 9334734..c8de416 100644 --- a/apps/fronted/src/components/preview/ProjectSection.tsx +++ b/apps/fronted/src/components/preview/ProjectSection.tsx @@ -4,6 +4,7 @@ import React from "react"; import { motion, AnimatePresence } from "framer-motion"; import SectionTitle from "./SectionTitle"; import { Project, GlobalSettings } from "@/types/resume"; +import { useResumeStore } from "@/store/useResumeStore"; interface ProjectItemProps { project: Project; @@ -57,16 +58,20 @@ const ProjectSection: React.FC = ({ projects, globalSettings, }) => { - if (!projects?.length) return null; + const { setActiveSection } = useResumeStore(); const visibleProjects = projects.filter((project) => project.visible); return ( { + setActiveSection("projects"); + }} > { - if (!skill) { - return null; - } + const { setActiveSection } = useResumeStore(); return ( { + setActiveSection("skills"); + }} >