updated docs
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
'use server';
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from "@/components/mutual/shadcnui/dropdown-menu";
|
||||
import { Button } from "@/components/mutual/shadcnui/button";
|
||||
import { languageSelectionTranslation } from "@/languages/mutual/languageSelection";
|
||||
import { langGetKey, langGet } from "@/lib/langGet";
|
||||
import { LanguageTypes } from "@/validations/mutual/language/validations";
|
||||
|
||||
import LanguageSelectionItem from "./languageItem";
|
||||
|
||||
const LanguageSelectionComponent: React.FC<{ lang: LanguageTypes, activePage: string }> = ({ lang, activePage }) => {
|
||||
const translations = langGet(lang, languageSelectionTranslation);
|
||||
const getPageWithLocale = (locale: LanguageTypes): string => { return `/${locale}/${activePage}` }
|
||||
|
||||
const englishButtonProps = {
|
||||
activeLang: lang,
|
||||
buttonsLang: "en",
|
||||
refUrl: getPageWithLocale("en"),
|
||||
innerText: langGetKey(translations, "english")
|
||||
}
|
||||
const turkishButtonProps = {
|
||||
activeLang: lang,
|
||||
buttonsLang: "tr",
|
||||
refUrl: getPageWithLocale("tr"),
|
||||
innerText: langGetKey(translations, "turkish")
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-end justify-end">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button className="w-48 h-12 text-center text-md">{langGetKey(translations, "title")}</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<LanguageSelectionItem {...englishButtonProps} />
|
||||
<LanguageSelectionItem {...turkishButtonProps} />
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageSelectionComponent;
|
||||
@@ -0,0 +1,38 @@
|
||||
'use client';
|
||||
import { useState, FC } from "react";
|
||||
import { DropdownMenuContent, DropdownMenuLabel } from "@/components/mutual/shadcnui/dropdown-menu";
|
||||
import Link from "next/link";
|
||||
import LoadingContent from "@/components/mutual/loader/component";
|
||||
|
||||
const RenderLinkComponent: FC<{ refUrl: string, innerText: string, setisL: (isLoading: boolean) => void }> = ({ refUrl, innerText, setisL }) => {
|
||||
return (
|
||||
<Link replace href={refUrl} onClick={() => setisL(true)}>
|
||||
<DropdownMenuContent className="flex w-48 h-12 align-center justify-center text-center text-md overflow-y-hidden">
|
||||
<DropdownMenuLabel className="flex items-center justify-center">{innerText}</DropdownMenuLabel>
|
||||
</DropdownMenuContent>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
const RenderLoadingComponent: FC<{ setisL: (isLoading: boolean) => void }> = ({ setisL }) => {
|
||||
return (
|
||||
<DropdownMenuContent className="flex w-48 h-12 align-center justify-center text-center text-md overflow-y-hidden">
|
||||
<DropdownMenuLabel className="flex items-center justify-center">
|
||||
<LoadingContent height="h-8" size="w-8 h-8" plane="" />
|
||||
</DropdownMenuLabel>
|
||||
</DropdownMenuContent>
|
||||
)
|
||||
}
|
||||
|
||||
const LanguageSelectionItem: React.FC<{
|
||||
activeLang: string, buttonsLang: string, refUrl: string, innerText: string
|
||||
}> = ({ activeLang, buttonsLang, refUrl, innerText }) => {
|
||||
const [isL, setisL] = useState<boolean>(false);
|
||||
const isC = buttonsLang !== activeLang
|
||||
const RenderLinkProp = { refUrl, innerText, setisL }
|
||||
return (
|
||||
<>{isC && <>{isL ? <RenderLoadingComponent setisL={setisL} /> : <RenderLinkComponent {...RenderLinkProp} />}</>}</>
|
||||
)
|
||||
}
|
||||
|
||||
export default LanguageSelectionItem
|
||||
Reference in New Issue
Block a user