Skip to content

Commit

Permalink
Mobile breadcrumbs interactive (#199)
Browse files Browse the repository at this point in the history
make mobile breadcrumbs interactive
  • Loading branch information
ChcJohnie authored Aug 8, 2023
1 parent 8598662 commit f3ef140
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/docs/components/MobileDocsNav/MobileDocsNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import React, { useEffect } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
Sheet,
Expand Down Expand Up @@ -42,9 +43,13 @@ export const MobileDocsNav = ({ items }: { items: DocItems }) => {
</Sheet>
{currentDocItem && (
<p className="flex gap-3">
<span className="text-neutral-500">{currentDocItem.groupLabel}</span>
<Link href={currentDocItem.group.href} className="text-neutral-500">
{currentDocItem.group.label}
</Link>
<span>{">"}</span>
<span className="font-semibold">{currentDocItem.itemLabel}</span>
<Link href={currentDocItem.item.href} className="font-semibold">
{currentDocItem.item.label}
</Link>
</p>
)}
</nav>
Expand All @@ -56,9 +61,8 @@ function findCurrentItem(items: DocItems, pathname: string) {
for (const item of group.items) {
if (item.href === pathname) {
return {
groupLabel: group.label,
itemLabel: item.label,
href: item.href,
group,
item,
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/docs/constants/docsItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { templates } from "@templates";
export type DocItems = DocItemGroup[];
export type DocItemGroup = {
label: string;
href: string;
items: DocItem[];
};
export type DocItem = {
Expand All @@ -15,6 +16,7 @@ export type DocItem = {
export const docsItems: DocItems = [
{
label: "Getting Started",
href: "/docs/installation",
items: [
{
href: "/docs/installation",
Expand All @@ -25,6 +27,7 @@ export const docsItems: DocItems = [
},
{
label: "Components",
href: "/docs/components",
items: [
{
href: "/docs/components",
Expand All @@ -42,6 +45,7 @@ export const docsItems: DocItems = [
},
{
label: "Templates",
href: "/docs/templates",
items: templates.map((template) => ({
href: `/docs/templates/${template.id}`,
label: template.name,
Expand Down

1 comment on commit f3ef140

@vercel
Copy link

@vercel vercel bot commented on f3ef140 Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.