mirror of
https://github.com/beilunyang/moemail.git
synced 2026-05-11 18:11:27 +08:00
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { useLocaleSwitcher } from "@/hooks/use-locale-switcher"
|
|
import { LOCALE_LABELS } from "@/i18n/config"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Languages } from "lucide-react"
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu"
|
|
|
|
export function FloatingLanguageSwitcher() {
|
|
const { locale, locales, switchLocale } = useLocaleSwitcher()
|
|
|
|
return (
|
|
<div className="fixed bottom-6 right-6 z-50">
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="outline"
|
|
size="icon"
|
|
className="bg-white dark:bg-background rounded-full shadow-lg group relative border-primary/20 hover:border-primary/40 transition-all"
|
|
aria-label="Switch language"
|
|
>
|
|
<Languages className="h-5 w-5 text-primary group-hover:scale-110 transition-transform" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" side="top" className="mb-2">
|
|
{locales.map((loc) => (
|
|
<DropdownMenuItem
|
|
key={loc}
|
|
onClick={() => switchLocale(loc)}
|
|
className={locale === loc ? "bg-accent" : ""}
|
|
>
|
|
{LOCALE_LABELS[loc]}
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
)
|
|
}
|