import { AnimatePresence, motion } from "motion/react"; import { useRef, useState } from "react"; type TabValue = "free" | "monthly" | "yearly"; const DEFAULT_THEME = { selectedBgColor: "black", unselectedColor: "var(--color-gray-200)", nestedSelectedBgColor: "white", nestedSelectedColor: "black", nestedColor: "white", selectedColor: "white", baseBgColor: "var(--color-gray-50)", borderColor: "var(--color-gray-200)", }; const Tab = (props: { value: TabValue; onChange: (value: TabValue) => void; theme?: { selectedBgColor: string; unselectedColor: string; nestedSelectedBgColor: string; nestedSelectedColor: string; nestedColor: string; selectedColor: string; baseBgColor: string; borderColor: string; }; }) => { const { value, onChange, theme = DEFAULT_THEME } = props; const selectedTab = value === "free" ? "free" : "premium"; const refMonthly = useRef(null); const refYearly = useRef(null); return (
onChange("free")} style={{ zIndex: 3, }} > Free
<> onChange("monthly")} > Premium
Monthly
Yearly
{selectedTab === "premium" && (
onChange("monthly")} ref={refMonthly} > Monthly
onChange("yearly")} ref={refYearly} > Yearly
)}
); };