From d7fa87e962f627c784d01b53c2594f7bddc399e2 Mon Sep 17 00:00:00 2001 From: salamca Date: Wed, 23 Oct 2024 18:57:14 +0200 Subject: [PATCH] Add disabled option to tab-menu and update sandbox page. --- .../components/crag-header/crag-tab-menu.tsx | 4 +- .../sandbox/tab-menu/[selectedTab]/page.tsx | 15 +++--- src/components/ui/tab-menu.tsx | 52 ++++++++++++------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/app/[lang]/crag/[cragSlug]/(crag)/components/crag-header/crag-tab-menu.tsx b/src/app/[lang]/crag/[cragSlug]/(crag)/components/crag-header/crag-tab-menu.tsx index fbc8bbdb..6199a0fa 100644 --- a/src/app/[lang]/crag/[cragSlug]/(crag)/components/crag-header/crag-tab-menu.tsx +++ b/src/app/[lang]/crag/[cragSlug]/(crag)/components/crag-header/crag-tab-menu.tsx @@ -6,7 +6,7 @@ import IconComment from "@/components/ui/icons/comment"; import IconGallery from "@/components/ui/icons/gallery"; import IconInfo from "@/components/ui/icons/info"; import IconRoutes from "@/components/ui/icons/routes"; -import TabMenu, { TabMenuItem } from "@/components/ui/tab-menu"; +import TabMenu, { TTabMenuItem } from "@/components/ui/tab-menu"; import { IconSize } from "@/components/ui/icons/icon-size"; interface Props { @@ -16,7 +16,7 @@ interface Props { function CragTabMenu({ crag }: Props) { const i18nPathname = useI18nPathname(); - const menuItems: TabMenuItem[] = [ + const menuItems: TTabMenuItem[] = [ { label: "Info", link: `/plezalisce/${crag.slug}/info`, diff --git a/src/app/sandbox/tab-menu/[selectedTab]/page.tsx b/src/app/sandbox/tab-menu/[selectedTab]/page.tsx index ef00b777..e832adf6 100644 --- a/src/app/sandbox/tab-menu/[selectedTab]/page.tsx +++ b/src/app/sandbox/tab-menu/[selectedTab]/page.tsx @@ -1,12 +1,13 @@ "use client"; -import TabMenu, { TabMenuItem } from "@/components/ui/tab-menu"; -interface Params { +import TabMenu, { TTabMenuItem } from "@/components/ui/tab-menu"; + +type TTabMenuPageParams = { params: { selectedTab?: string }; -} +}; -function TabMenuPage({ params }: Params) { - const menuItems: TabMenuItem[] = [ +function TabMenuPage({ params }: TTabMenuPageParams) { + const menuItems: TTabMenuItem[] = [ { label: "Informacije", link: "/sandbox/tab-menu/info", @@ -25,9 +26,11 @@ function TabMenuPage({ params }: Params) { { label: "Galerija", link: "/sandbox/tab-menu/galerija", - isActive: params.selectedTab === "galerija", + isActive: false, + isDisabled: true, }, ]; + return (

Tab menu demo

diff --git a/src/components/ui/tab-menu.tsx b/src/components/ui/tab-menu.tsx index e4b3f016..ce7051ce 100644 --- a/src/components/ui/tab-menu.tsx +++ b/src/components/ui/tab-menu.tsx @@ -1,18 +1,19 @@ import Link from "next/link"; import { ReactNode } from "react"; -export interface TabMenuItem { +type TTabMenuItem = { label: string; link: string; isActive: boolean; icon?: ReactNode; -} + isDisabled?: boolean; +}; -interface TabMenuProps { - items: TabMenuItem[]; -} +type TTabMenuProps = { + items: TTabMenuItem[]; +}; -function TabMenu({ items }: TabMenuProps) { +function TabMenu({ items }: TTabMenuProps) { return ( @@ -46,3 +60,5 @@ function TabMenu({ items }: TabMenuProps) { } export default TabMenu; + +export type { TTabMenuItem };