23 lines
675 B
TypeScript
23 lines
675 B
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
import { useApp } from "@/contexts/AppContext";
|
||
|
|
|
||
|
|
export default function LanguageSwitch() {
|
||
|
|
const { language, setLanguage } = useApp();
|
||
|
|
|
||
|
|
const toggleLanguage = () => {
|
||
|
|
setLanguage(language === "zh" ? "en" : "zh");
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<button
|
||
|
|
onClick={toggleLanguage}
|
||
|
|
className="bg-bg-surface dark:bg-gray-800 rounded-lg border border-border-normal dark:border-gray-700 px-3 py-2 flex items-center justify-center h-10 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"
|
||
|
|
>
|
||
|
|
<span className="text-sm font-medium text-text-primary dark:text-white">
|
||
|
|
{language === "zh" ? "中" : "EN"}
|
||
|
|
</span>
|
||
|
|
</button>
|
||
|
|
);
|
||
|
|
}
|