import type { RightSidebarSection } from "@/libs/resume/section"; import { Fragment, useCallback, useRef } from "react"; import { match } from "ts-pattern"; import { Button } from "@reactive-resume/ui/components/button"; import { ScrollArea } from "@reactive-resume/ui/components/scroll-area"; import { Separator } from "@reactive-resume/ui/components/separator"; import { Tooltip, TooltipContent, TooltipTrigger } from "@reactive-resume/ui/components/tooltip"; import { Copyright } from "@/components/ui/copyright"; import { getSectionIcon, getSectionTitle, rightSidebarSections } from "@/libs/resume/section"; import { BuilderSidebarEdge } from "../../-components/edge"; import { useBuilderSidebar } from "../../-store/sidebar"; import { CustomStylesSectionBuilder } from "./sections/custom-styles"; import { DesignSectionBuilder } from "./sections/design"; import { ExportSectionBuilder } from "./sections/export"; import { InformationSectionBuilder } from "./sections/information"; import { LayoutSectionBuilder } from "./sections/layout"; import { NotesSectionBuilder } from "./sections/notes"; import { PageSectionBuilder } from "./sections/page"; import { ResumeAnalysisSectionBuilder } from "./sections/resume-analysis"; import { SharingSectionBuilder } from "./sections/sharing"; import { StatisticsSectionBuilder } from "./sections/statistics"; import { TemplateSectionBuilder } from "./sections/template"; import { TypographySectionBuilder } from "./sections/typography"; function getSectionComponent(type: RightSidebarSection) { return match(type) .with("template", () => ) .with("layout", () => ) .with("typography", () => ) .with("design", () => ) .with("styles", () => ) .with("page", () => ) .with("notes", () => ) .with("sharing", () => ) .with("statistics", () => ) .with("analysis", () => ) .with("export", () => ) .with("information", () => ) .exhaustive(); } export function BuilderSidebarRight() { const scrollAreaRef = useRef(null); return ( <>
{rightSidebarSections.map((section) => ( {getSectionComponent(section)} ))}
); } function SidebarEdge() { const { toggleSidebar } = useBuilderSidebar(); const scrollToSection = useCallback( (section: RightSidebarSection) => { toggleSidebar("right", true); // Section ids are globally unique; document.getElementById reliably resolves the scroll target. document .getElementById(`sidebar-${section}`) ?.scrollIntoView({ block: "start", inline: "nearest", behavior: "smooth" }); }, [toggleSidebar], ); return (
{rightSidebarSections.map((section) => ( scrollToSection(section)} > {getSectionIcon(section)} } /> {getSectionTitle(section)} ))}
); }