diff --git a/package.json b/package.json index 0134d58..332f68a 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,10 @@ { "name": "alpha", "prerelease": true + }, + { + "name": "prerelease_navbar", + "prerelease": true } ] }, diff --git a/src/custom/docs/components/navmenu/NavigationMenu.tsx b/src/custom/docs/components/navmenu/NavigationMenu.tsx index 0a6a731..638679b 100644 --- a/src/custom/docs/components/navmenu/NavigationMenu.tsx +++ b/src/custom/docs/components/navmenu/NavigationMenu.tsx @@ -3,16 +3,19 @@ import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, + NavigationMenuTrigger, NavigationMenuList, - navigationMenuTriggerStyle, + NavigationMenuContent, } from 'src' -import { Link } from './config' +import { RegularLink } from './config' import { NavConfig } from './schema' +import NextLink from 'next/link' + export const Navigation = (props: { activePath: string - linkComponent: Link + linkComponent: typeof NextLink | typeof RegularLink } & Pick) => { const isActivePath = (activePath: string, path: string) => { return activePath.startsWith(path) @@ -23,15 +26,37 @@ export const Navigation = (props: { { props.navTextLinks.map((item) => { return ( - - - {item.title} - - + {item.title} + +
    +
  • + + + {item.logo} +

    + {item.description} +

    +
    +
    +
  • + { item.dropDown.map((subtitle) => { + return ( +
  • + + +
    {subtitle.title}
    +
    +
    +
  • + )})} +
+
) })} diff --git a/src/custom/docs/components/navmenu/config.tsx b/src/custom/docs/components/navmenu/config.tsx index 40c266c..d632011 100644 --- a/src/custom/docs/components/navmenu/config.tsx +++ b/src/custom/docs/components/navmenu/config.tsx @@ -16,5 +16,4 @@ export const navConfigSchema = z.object({ export type ActivePaths = (z.infer['navTextLinks'])[number]['href'] -const defaultLink = (props: ComponentProps<'a'>) => -export type Link = typeof defaultLink +export const RegularLink = (props: ComponentProps<'a'>) => diff --git a/src/custom/docs/components/navmenu/index.tsx b/src/custom/docs/components/navmenu/index.tsx index 02226ec..ba2ba4a 100644 --- a/src/custom/docs/components/navmenu/index.tsx +++ b/src/custom/docs/components/navmenu/index.tsx @@ -1,57 +1,166 @@ 'use client' import { Navigation } from './NavigationMenu' -import { ComponentProps } from 'react' -import { Link } from './config' +import NextLink from 'next/link' import { QuantinuumLogo } from './QuantinuumLogo' import { MobileMenu } from './MobileMenu' import { QuantinuumIdent } from './QuantinuumIdent' import { ModeSelector } from './ModeSelector' -import { NavConfig } from './schema' +import { RegularLink } from './config' +import React from 'react' +import { HSeriesLogo } from '../logos/HSeriesLogo' +import { NexusLogo } from '../logos/NexusLogo' +import { TKETLogo } from '../logos/TKETLogo' +import { InquantoLogo } from '../logos/InQuantoLogo' +import { LambeqLogo } from '../logos/LambeqLogo' + + +const navConfig = { + navTextLinks: [ + { + title: 'H-Series', + href: '/h-series/index.html', + pathMatch: 'somewhere', + logo: , + description: "Quantinuum's QCCD ion-trap hardware, the world's highest peforming quantum computer.", + dropDown: [{ + title: "Guides", + href: "/h-series/guides.html", + },{ + title: "Getting Started", + href: "/h-series/trainings/getting_started/getting_started_index.html", + },{ + title: "Knowledge Articles", + href: "/h-series/trainings/knowledge_articles/ka_index.html", + },{ + title: "Support", + href: "/h-series/support.html", + }] + }, { + title: 'Nexus', + href: '/nexus/index.html', + pathMatch: 'somewhere', + logo: , + description: "Cloud platform connecting users with hardware and compilation services, alongside associated data.", + dropDown: [{ + title: 'Guides', + href: '/nexus/guides.html', + }, + { + title: 'Trainings', + href: '/nexus/trainings/getting_started.html', + }, + { + title: 'API Reference', + href: '/nexus/api_index.html', + }, + { + title: 'Support', + href: '/nexus/support_index.html', + },] + }, { + title: "TKET", + href: "/tket/index.html", + pathMatch: "", + logo: , + description: "Quantum computing toolkit and optimizing compiler", + dropDown: [{ + title: 'API Docs', + href: '/tket/api-docs', + },{ + title: 'User Guide', + href: '/tket/user-guide', + },{ + title: 'Blog', + href: '/tket/blog/', + },] + }, { + title: "InQuanto", + href: "/inquanto/index.html", + pathMatch: "", + logo: , + description: "Toolkit for complex molecular and materials simulations", + dropDown: [{ + title: 'Introduction', + href: '/inquanto/introduction/overview.html', + }, + { + title: 'User Guide', + href: '/inquanto/manual/howto.html', + }, + { + title: 'Tutorials', + href: '/inquanto/tutorials/tutorial_overview.html', + }, + { + title: 'Examples', + href: '/inquanto/tutorials/examples_overview.html', + }, + { + title: 'API Reference', + href: '/inquanto/api/inquanto_api_intro.html', + },] + }, { + title: "\u03BBambeq", + href: "/lambeq/index.html", + logo: , + description: "A Python toolkit for quantum natural language processing", + dropDown: [{ + title: 'Getting Started', + href: '/lambeq/intro.html', + }, + { + title: 'User Guide', + href: '/lambeq/pipeline.html', + }, + { + title: 'Tutorials', + href: '/lambeq/tutorials/sentence-input.html', + }, + { + title: 'Code Examples', + href: '/lambeq/notebooks.html', + }, + { + title: 'API Reference', + href: '/lambeq/root-api.html', + },] + } + ], +} + export const NavBar = (props: { - linkComponent?: Link + linkComponent: typeof NextLink | typeof RegularLink activePath: string enableModeSelector?: boolean -} & NavConfig) => { - const Link = props.linkComponent - ? props.linkComponent - : (props: ComponentProps<'a'>) => +}) => { return (
- +
- +
- {props.navProductName !== '' ?
-
|
{props.navProductName}
-
: null} +
+
|
Documentation
+
- + Quantinuum - +
- - -
- {props.navIconLinks.map(link => { - return - - - })} -
- - {props.enableModeSelector ? <>
: null} + + {props.enableModeSelector ? <>
: null}
diff --git a/src/custom/docs/components/navmenu/schema.tsx b/src/custom/docs/components/navmenu/schema.tsx index 139dfe9..58f759a 100644 --- a/src/custom/docs/components/navmenu/schema.tsx +++ b/src/custom/docs/components/navmenu/schema.tsx @@ -1,18 +1,25 @@ import { ComponentProps } from 'react' +import React from 'react'; import { z } from 'zod'; - +const dropDownSchema = z.object({ + href: z.string(), + title: z.string(), +}); const linkSchema = z.object({ href: z.string(), title: z.string(), + logo: z.custom( + e => (e as any)?.$$typeof === Symbol.for("react.element"), + "value must be a React Element" + ), + description: z.string(), external: z.boolean().optional(), + dropDown: z.array(dropDownSchema), }); export const navConfigSchema = z.object({ navTextLinks: z.array(linkSchema), - navIconLinks: z.array(z.intersection(linkSchema, z.object({iconImageURL: z.string()}))), - navProductName: z.string() }) export type NavConfig = z.infer export type ActivePaths = (NavConfig['navTextLinks'])[number]['href'] -const defaultLink = (props: ComponentProps<'a'>) => -export type Link = typeof defaultLink +export const RegularLink = (props: ComponentProps<'a'>) => diff --git a/src/custom/docs/scripts/nav/index.tsx b/src/custom/docs/scripts/nav/index.tsx index cf0922d..7463de7 100644 --- a/src/custom/docs/scripts/nav/index.tsx +++ b/src/custom/docs/scripts/nav/index.tsx @@ -1,5 +1,6 @@ import {createRoot} from "react-dom/client" +import { ComponentProps } from "react"; import { NavBar } from "../../components/navmenu"; import { navConfigSchema } from '../../components/navmenu/schema'; @@ -17,6 +18,6 @@ import { navConfigSchema } from '../../components/navmenu/schema'; navProductName: typeof navProductName !== "undefined" ? navProductName : null }) root.render( -
+
) => }>
) })() diff --git a/stories/custom/docs-nav.stories.tsx b/stories/custom/docs-nav.stories.tsx index 29f9380..9d973ad 100644 --- a/stories/custom/docs-nav.stories.tsx +++ b/stories/custom/docs-nav.stories.tsx @@ -1,58 +1,9 @@ import { Meta, StoryObj } from "@storybook/react"; +import { ComponentProps } from "react"; import {DocsNavBar } from "src"; -const navConfig = { - navTextLinks: [ - { - title: 'Nexus Concepts', - href: 'concepts/projects.html', - pathMatch: 'somewhere', - }, - { - title: 'User Guide', - href: 'user_guide/sign_up.html', - pathMatch: 'somewhere', - }, - { - title: 'Admin Guide', - href: 'admin_guide/quotas.html', - pathMatch: 'somewhere', - }, - { - title: 'Code Examples', - href: 'examples/overview.html', - pathMatch: 'somewhere', - }, - { - title: 'API Reference', - href: '"qnexus_api/auth.html', - pathMatch: 'somewhere', - }, - ], - navProductName: 'Nexus', - navIconLinks: [ - { - title: 'TKET Github', - href: 'https://github.com/CQCL/tket', - pathMatch: 'somewhere', - iconImageURL: '/github.svg', - }, - { - title: 'TKET Slack Channel', - href: 'https://tketusers.slack.com/', - pathMatch: 'somewhere', - iconImageURL: '/slack.svg', - }, - { - title: 'TKET Stack Exchange', - href: 'https://quantumcomputing.stackexchange.com/questions/tagged/pytket', - pathMatch: 'somewhere', - iconImageURL: '/stack.svg', - }, - ], - } export function DocsNavDemo() { - return ; + return ) => } />; } const meta: Meta = {