Introduce prettier

This commit is contained in:
Takeshi Kimata
2024-05-19 21:06:49 +09:00
parent 75eeebefda
commit c5ba3b9a00
52 changed files with 884 additions and 1509 deletions

View File

@@ -1,18 +1,12 @@
"use client";
import {
Button,
DropdownTrigger,
Dropdown,
DropdownMenu,
DropdownItem,
} from "@nextui-org/react";
import { Globe, ChevronDown } from "lucide-react";
import { usePathname } from "next/navigation";
import { useRouter } from "@/src/navigation";
'use client';
import { Button, DropdownTrigger, Dropdown, DropdownMenu, DropdownItem } from '@nextui-org/react';
import { Globe, ChevronDown } from 'lucide-react';
import { usePathname } from 'next/navigation';
import { useRouter } from '@/src/navigation';
const locales = [
{ code: "en", name: "English" },
{ code: "ja", name: "日本語" },
{ code: 'en', name: 'English' },
{ code: 'ja', name: '日本語' },
];
export default function DropdownLanguage(params: { locale: string }) {
@@ -23,7 +17,7 @@ export default function DropdownLanguage(params: { locale: string }) {
let newPathname;
if (pathname.length < 4) {
// when root path
router.push("/", { locale: nextLocale });
router.push('/', { locale: nextLocale });
} else {
// when not root path, trim first "/en" from pathname = "/en/projects"
newPathname = pathname.slice(params.locale.length + 1);
@@ -34,22 +28,13 @@ export default function DropdownLanguage(params: { locale: string }) {
return (
<Dropdown>
<DropdownTrigger>
<Button
size="sm"
variant="light"
startContent={<Globe size={16} />}
endContent={<ChevronDown size={16} />}
>
{locales.find((locale) => locale.code === params.locale)?.name ||
params.locale}
<Button size="sm" variant="light" startContent={<Globe size={16} />} endContent={<ChevronDown size={16} />}>
{locales.find((locale) => locale.code === params.locale)?.name || params.locale}
</Button>
</DropdownTrigger>
<DropdownMenu aria-label="lacales">
{locales.map((entry) => (
<DropdownItem
key={entry.code}
onClick={() => changeLocale(entry.code)}
>
<DropdownItem key={entry.code} onClick={() => changeLocale(entry.code)}>
{entry.name}
</DropdownItem>
))}