From 3f9df63fd9949ef455a1b91eb5b4b61401d047ea Mon Sep 17 00:00:00 2001 From: Neil de Carteret Date: Wed, 5 Jun 2024 19:13:08 +0100 Subject: [PATCH] second nav level --- .../settings/RouterExperiment/Link.tsx | 10 +++- .../RouterExperiment/RouterExperiment.tsx | 60 ++++++++++++++----- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/components/settings/RouterExperiment/Link.tsx b/src/components/settings/RouterExperiment/Link.tsx index c0a16b8b..248280d4 100644 --- a/src/components/settings/RouterExperiment/Link.tsx +++ b/src/components/settings/RouterExperiment/Link.tsx @@ -1,10 +1,14 @@ import React, { ComponentPropsWithRef } from "react"; import { Link as RouterLink } from "react-router-dom"; -export const Link: React.FC> = ( +export const MyLink: React.FC> = ( props, ) => { - return e.stopPropagation()} />; + const title = + typeof props.to === "string" ? props.to : props.to.pathname ?? ""; + return ( + e.stopPropagation()} title={title} /> + ); }; -Link.displayName = "Link"; +MyLink.displayName = "MyLink"; diff --git a/src/components/settings/RouterExperiment/RouterExperiment.tsx b/src/components/settings/RouterExperiment/RouterExperiment.tsx index 1309f27b..3e948c8e 100644 --- a/src/components/settings/RouterExperiment/RouterExperiment.tsx +++ b/src/components/settings/RouterExperiment/RouterExperiment.tsx @@ -11,13 +11,12 @@ import { Route, Routes, useLocation, - useMatch, useParams, } from "react-router-dom"; import { ThemeContext } from "../../../themes/ThemeContext"; import { absoluteCover } from "../../absoluteCover"; -import { Link } from "./Link"; +import { MyLink } from "./Link"; function CardCategoryList() { return ( @@ -25,16 +24,16 @@ function CardCategoryList() {

Card categories

- Card 1 + Card 1
- Card 2 + Card 2
- Card 3 + Card 3
- Card 4 + Card 4

{/* Card 5 */}
@@ -53,11 +52,32 @@ function CardDetails() { }, [id]); return ( <> -

Card details

+

Card {id}

setText(e.target.value)} />
-
Card id is {id}
+

Widgets

+
+ Widget 1{" "} +
+
+ Widget 2{" "} +
+
+ Widget 3{" "} +
+
+ Widget 4{" "} +
+ + ); +} + +function WidgetsDetail() { + const { widgetIid } = useParams(); + return ( + <> +

Widget {widgetIid}

); } @@ -71,7 +91,7 @@ function Layout() { }} >
- {pathname} {pathname !== "/" && Home} + {pathname} {pathname !== "/" && Home}

@@ -118,16 +138,17 @@ function PanelWrapper({ children }: PropsWithChildren) { }} >
- + Back - + + , Current path: {pathname}, Parent path: {parentPath}
{children}
+ + +
- - - ); } @@ -149,7 +170,16 @@ export function RouterExperiment() { } - /> + > + + + + } + /> +