Implement slider when screen width is small
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
Navbar as NextUINavbar,
|
Navbar as NextUINavbar,
|
||||||
NavbarContent,
|
NavbarContent,
|
||||||
|
NavbarMenu,
|
||||||
|
NavbarMenuToggle,
|
||||||
NavbarBrand,
|
NavbarBrand,
|
||||||
NavbarItem,
|
NavbarItem,
|
||||||
|
NavbarMenuItem,
|
||||||
Chip,
|
Chip,
|
||||||
Link as NextUiLink,
|
Link as NextUiLink,
|
||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
@@ -17,6 +20,22 @@ import Image from "next/image";
|
|||||||
export default function Header(params: { locale: string }) {
|
export default function Header(params: { locale: string }) {
|
||||||
const t = useTranslations("Header");
|
const t = useTranslations("Header");
|
||||||
|
|
||||||
|
// Links shown Header or slider
|
||||||
|
const commonLinks = [
|
||||||
|
{
|
||||||
|
uid: "projects",
|
||||||
|
href: "/projects",
|
||||||
|
label: t("projects"),
|
||||||
|
isExternal: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
uid: "docs",
|
||||||
|
href: "https://kimatata.github.io/TestPlat/docs/getstarted/selfhost",
|
||||||
|
label: t("docs"),
|
||||||
|
isExternal: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NextUINavbar maxWidth="full" position="sticky" className="bg-inherit">
|
<NextUINavbar maxWidth="full" position="sticky" className="bg-inherit">
|
||||||
<NavbarContent className="basis-1/5 sm:basis-full" justify="start">
|
<NavbarContent className="basis-1/5 sm:basis-full" justify="start">
|
||||||
@@ -35,7 +54,7 @@ export default function Header(params: { locale: string }) {
|
|||||||
<p className="font-bold text-inherit">TestPlat</p>
|
<p className="font-bold text-inherit">TestPlat</p>
|
||||||
</Link>
|
</Link>
|
||||||
</NavbarBrand>
|
</NavbarBrand>
|
||||||
<NavbarItem className="hidden sm:block">
|
<NavbarItem className="hidden md:block">
|
||||||
<Chip size="sm" variant="flat">
|
<Chip size="sm" variant="flat">
|
||||||
<Link
|
<Link
|
||||||
className="data-[active=true]:text-primary data-[active=true]:font-medium"
|
className="data-[active=true]:text-primary data-[active=true]:font-medium"
|
||||||
@@ -46,16 +65,9 @@ export default function Header(params: { locale: string }) {
|
|||||||
</Link>
|
</Link>
|
||||||
</Chip>
|
</Chip>
|
||||||
</NavbarItem>
|
</NavbarItem>
|
||||||
<NavbarItem className="hidden sm:block">
|
{commonLinks.map((link) =>
|
||||||
<Link
|
link.isExternal ? (
|
||||||
className="data-[active=true]:text-primary data-[active=true]:font-medium"
|
<NavbarItem key={link.uid} className="hidden md:block">
|
||||||
href="/projects"
|
|
||||||
locale={params.locale}
|
|
||||||
>
|
|
||||||
{t("projects")}
|
|
||||||
</Link>
|
|
||||||
</NavbarItem>
|
|
||||||
<NavbarItem className="hidden sm:block">
|
|
||||||
<NextUiLink
|
<NextUiLink
|
||||||
isExternal
|
isExternal
|
||||||
href="https://kimatata.github.io/TestPlat/docs/getstarted/selfhost"
|
href="https://kimatata.github.io/TestPlat/docs/getstarted/selfhost"
|
||||||
@@ -66,6 +78,18 @@ export default function Header(params: { locale: string }) {
|
|||||||
{t("docs")}
|
{t("docs")}
|
||||||
</NextUiLink>
|
</NextUiLink>
|
||||||
</NavbarItem>
|
</NavbarItem>
|
||||||
|
) : (
|
||||||
|
<NavbarItem key={link.uid} className="hidden md:block">
|
||||||
|
<Link
|
||||||
|
className="data-[active=true]:text-primary data-[active=true]:font-medium"
|
||||||
|
href={link.href}
|
||||||
|
locale={params.locale}
|
||||||
|
>
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
</NavbarItem>
|
||||||
|
)
|
||||||
|
)}
|
||||||
</NavbarContent>
|
</NavbarContent>
|
||||||
|
|
||||||
<NavbarContent className="basis-1 pl-4" justify="end">
|
<NavbarContent className="basis-1 pl-4" justify="end">
|
||||||
@@ -73,12 +97,42 @@ export default function Header(params: { locale: string }) {
|
|||||||
isExternal
|
isExternal
|
||||||
href="https://github.com/kimatata/TestPlat"
|
href="https://github.com/kimatata/TestPlat"
|
||||||
aria-label="Github"
|
aria-label="Github"
|
||||||
|
className="hidden md:flex"
|
||||||
>
|
>
|
||||||
<GithubIcon className="text-default-500" />
|
<GithubIcon className="text-default-500" />
|
||||||
</NextUiLink>
|
</NextUiLink>
|
||||||
<ThemeSwitch />
|
<ThemeSwitch className="hidden md:flex" />
|
||||||
<LangSwitch locale={params.locale} />
|
<LangSwitch locale={params.locale} />
|
||||||
|
<NavbarMenuToggle className="md:hidden" />
|
||||||
</NavbarContent>
|
</NavbarContent>
|
||||||
|
|
||||||
|
<NavbarMenu>
|
||||||
|
<div className="mx-4 mt-2 flex flex-col gap-2">
|
||||||
|
{commonLinks.map((link) =>
|
||||||
|
link.isExternal ? (
|
||||||
|
<NavbarMenuItem key={link.uid}>
|
||||||
|
<NextUiLink
|
||||||
|
href={link.href}
|
||||||
|
showAnchorIcon
|
||||||
|
anchorIcon={<MoveUpRight size={12} className="ms-1" />}
|
||||||
|
>
|
||||||
|
{t("docs")}
|
||||||
|
</NextUiLink>
|
||||||
|
</NavbarMenuItem>
|
||||||
|
) : (
|
||||||
|
<NavbarMenuItem key={link.uid}>
|
||||||
|
<Link
|
||||||
|
className="data-[active=true]:text-primary data-[active=true]:font-medium"
|
||||||
|
href={link.href}
|
||||||
|
locale={params.locale}
|
||||||
|
>
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
</NavbarMenuItem>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</NavbarMenu>
|
||||||
</NextUINavbar>
|
</NextUINavbar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user