-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
196 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Children, ReactNode } from "react"; | ||
|
||
interface SettingsItemProps { | ||
label: string; | ||
children: ReactNode; | ||
} | ||
|
||
export function SettingsItem({ label, children }: SettingsItemProps) { | ||
return ( | ||
<div className="border-base flex min-h-[6rem] flex-wrap justify-between gap-4 border-b-2 py-6 last:border-b-0"> | ||
<h3 className="text-xl font-bold">{label}</h3> | ||
{Children.only(children)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
InlayContainer, | ||
InlayContainerRoutes, | ||
} from "@/components/layout/InlayContainer"; | ||
import { useMemo } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export default function Settings() { | ||
const { t } = useTranslation(); | ||
|
||
const routes: InlayContainerRoutes[] = useMemo( | ||
() => [ | ||
{ | ||
icon: "i-heroicons:language", | ||
href: "/settings/lang", | ||
label: t("views.settings.languageSettings"), | ||
}, | ||
{ | ||
icon: "i-heroicons:moon", | ||
href: "/settings/themes", | ||
label: t("views.settings.theme"), | ||
}, | ||
{ | ||
icon: "i-heroicons:user", | ||
href: "/settings/user", | ||
label: t("views.settings.user"), | ||
}, | ||
{ | ||
icon: "i-heroicons:funnel", | ||
href: "/settings/homepage", | ||
label: t("views.settings.homepage"), | ||
}, | ||
{ | ||
icon: "i-heroicons:eye-slash", | ||
href: "/settings/blocked", | ||
label: t("views.settings.blockedChannels"), | ||
}, | ||
], | ||
[t], | ||
); | ||
|
||
return <InlayContainer routes={routes} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { SettingsItem } from "@/components/settings/SettingsItem"; | ||
import { TL_LANGS } from "@/lib/consts"; | ||
import { langs } from "@/lib/i18n"; | ||
import { cn } from "@/lib/utils"; | ||
import { Button } from "@/shadcn/ui/button"; | ||
import { Checkbox } from "@/shadcn/ui/checkbox"; | ||
import { | ||
Command, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
} from "@/shadcn/ui/command"; | ||
import { Label } from "@/shadcn/ui/label"; | ||
import { Popover, PopoverContent, PopoverTrigger } from "@/shadcn/ui/popover"; | ||
import { Switch } from "@/shadcn/ui/switch"; | ||
import { clipLanguageAtom, englishNameAtom } from "@/store/settings"; | ||
import { useAtom } from "jotai"; | ||
import { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export default function SettingsLang() { | ||
const [useENName, setUseENName] = useAtom(englishNameAtom); | ||
const [clipLangs, setClipLangs] = useAtom(clipLanguageAtom); | ||
const [langOpen, setLangOpen] = useState(false); | ||
const { i18n, t } = useTranslation(); | ||
|
||
return ( | ||
<div className="flex flex-col p-2 md:p-4"> | ||
<SettingsItem label={t("views.settings.languageSettings")}> | ||
<div className="flex flex-col gap-2"> | ||
<Popover open={langOpen} onOpenChange={setLangOpen}> | ||
<PopoverTrigger asChild> | ||
<Button | ||
size="lg" | ||
variant="outline" | ||
role="combobox" | ||
aria-expanded={langOpen} | ||
className="border-base w-fit min-w-[240px] justify-between px-4" | ||
> | ||
{langs.find(({ val }) => i18n.language === val)?.display} | ||
<div className="i-lucide:chevrons-up-down ml-2 h-4 w-4 shrink-0 opacity-50" /> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-fit min-w-[240px] p-0"> | ||
<Command> | ||
<CommandInput | ||
placeholder={t("views.settings.languageSearch")} | ||
/> | ||
<CommandEmpty> | ||
{t("views.settings.languageNotfound")} | ||
</CommandEmpty> | ||
<CommandGroup> | ||
{langs.map(({ val, display }) => ( | ||
<CommandItem | ||
key={val} | ||
onSelect={() => { | ||
i18n.changeLanguage(val); | ||
setLangOpen(false); | ||
}} | ||
> | ||
<div | ||
className={cn( | ||
"i-heroicons:check mr-2 h-4 w-4", | ||
val === i18n.language ? "opacity-100" : "opacity-0", | ||
)} | ||
/> | ||
{display} | ||
</CommandItem> | ||
))} | ||
</CommandGroup> | ||
</Command> | ||
</PopoverContent> | ||
</Popover> | ||
<div className="text-base-11 flex items-center gap-1 text-xs"> | ||
<div className="i-heroicons:heart" /> | ||
{langs.find(({ val }) => i18n.language === val)?.credit} | ||
</div> | ||
</div> | ||
</SettingsItem> | ||
<SettingsItem label={t("views.settings.useEnglishNameLabel")}> | ||
<div className="flex min-w-full items-center gap-4"> | ||
<Label htmlFor="use_english_names" className="text-base-11"> | ||
{t("views.settings.useEnglishNameMsg")} | ||
</Label> | ||
<div className="flex grow" /> | ||
<Switch | ||
id="use_english_names" | ||
checked={useENName} | ||
onCheckedChange={setUseENName} | ||
/> | ||
</div> | ||
</SettingsItem> | ||
<SettingsItem label={t("views.settings.clipLanguageSelection")}> | ||
<div className="flex w-full flex-col"> | ||
{TL_LANGS.map(({ text, value }, index) => ( | ||
<Label | ||
className={cn( | ||
"flex min-w-[18rem] w-full justify-between items-center gap-4 px-4 py-4", | ||
{ | ||
"bg-base-4": index % 2, | ||
}, | ||
)} | ||
htmlFor={`cliplang-${value}`} | ||
> | ||
{text} | ||
<Checkbox | ||
id={`cliplang-${value}`} | ||
checked={clipLangs.includes(value)} | ||
onCheckedChange={(checked) => | ||
setClipLangs((langs) => | ||
checked | ||
? [...langs, value] | ||
: langs.filter((lang) => lang !== value), | ||
) | ||
} | ||
/> | ||
</Label> | ||
))} | ||
</div> | ||
</SettingsItem> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters