import React, { useEffect, useRef, useState } from "react"; import { DUMMY_RESUME_DATA, resumeTemplates, themeColorPalette, } from "../../utils/data"; import { LuCircleCheckBig } from "react-icons/lu"; import Tabs from "../../components/Tabs"; import TemplateCard from "../../components/Cards/TemplateCard"; import RenderResume from "../../components/ResumeTemplates/RenderResume"; const TAB_DATA = [{ label: "Templates" }, { label: "Color Palettes" }]; const ThemeSelector = ({ selectedTheme, setSelectedTheme, resumeData, onClose, }) => { const resumeRef = useRef(null); const [baseWidth, setBaseWidth] = useState(800); const [tabValue, setTabValue] = useState("Templates"); const [selectedColorPalette, setSelectedColorPalette] = useState({ colors: selectedTheme?.colorPalette, index: -1, }); const [selectedTemplate, setSelectedTemplate] = useState({ theme: selectedTheme?.theme || "", index: -1, }); // Handle Theme Change const handleThemeSelection = () => { setSelectedTheme({ colorPalette: selectedColorPalette?.colors, theme: selectedTemplate?.theme, }); onClose(); }; const updateBaseWidth = () => { if (resumeRef.current) { setBaseWidth(resumeRef.current.offsetWidth); } }; useEffect(() => { updateBaseWidth(); window.addEventListener("resize", updateBaseWidth); return () => { window.removeEventListener("resize", updateBaseWidth); }; }, []); return
{tabValue === "Templates" && resumeTemplates.map((template, index) => ( setSelectedTemplate({ theme: template.id, index }) } /> ))} {tabValue === "Color Palettes" && themeColorPalette.themeOne.map((colors, index) => ( setSelectedColorPalette({ colors, index })} /> ))}
}; export default ThemeSelector; const ColorPalette = ({ colors, isSelected, onSelect }) => { return (
{colors.map((color, index) => (
))}
); };