"use client"; import { useState, type ReactNode } from "react"; import { usePathname } from "next/navigation"; import { Check, ChevronsUpDown } from "lucide-react"; import { Popover, PopoverContent, PopoverTrigger, } from "fumadocs-ui/components/ui/popover"; import { useLanguage } from "@/components/lang/language-provider"; import type { Language } from "@/lib/lang/terms"; import styles from "./language-selector.module.scss"; function badge(id: Language, src: string, label: string) { return ( ); } interface LanguageOption { id: Language; label: string; icon: ReactNode; description?: string; disabled?: boolean; } const OPTIONS: LanguageOption[] = [ { id: "python", label: "Python", icon: badge("python", "/icons/python.svg", "Python"), description: "First class support", }, { id: "typescript", label: "TypeScript", icon: badge("typescript", "/icons/typescript.svg", "TypeScript"), description: "Coming soon on July 20th", disabled: true, }, ]; export default function LanguageSelector() { const { language, setLanguage } = useLanguage(); const pathname = usePathname(); const [open, setOpen] = useState(false); const showSelector = pathname === "/docs" || pathname.startsWith("/docs/") || pathname === "/integrations" || pathname.startsWith("/integrations/"); if (!showSelector) { return null; } const active = OPTIONS.find((o) => o.id === language) ?? OPTIONS[0]; // TypeScript (and any disabled option) is a no-op for now. const select = (option: LanguageOption) => { if (option.disabled) return; setLanguage(option.id); setOpen(false); }; return ( {active.icon} {active.label} {OPTIONS.map((option) => ( select(option)} aria-disabled={option.disabled} className={`${styles.item} ${ option.disabled ? styles.disabled : "" }`} > {option.icon} {option.label} {option.description ? ( {option.description} ) : null} ))} ); }