Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor tweaks #13

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions components/content-types/Documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ const Documentation = ({ contentlet, sideNav }) => {
const documentation = cleanMarkdown(contentlet.documentation, contentlet.identifier);

return (
<div className="container mx-auto flex min-h-screen gap-12 py-8">
<div className="container flex min-h-svh py-4">
{/* Left Navigation */}
<div className="w-72 border-r pr-8">
<nav className="sticky top-8">
<h2 className="mb-4 text-lg font-semibold">Documentation</h2>
<div className="w-96 border-r pr-8">
<nav >
<NavTree
items={sideNav[0]?.dotcmsdocumentationchildren || []}
currentPath={currentPath}
Expand All @@ -45,7 +44,7 @@ const Documentation = ({ contentlet, sideNav }) => {
</div>

{/* Main Content */}
<div className="pl-8 flex-1 min-w-0 overflow-x-hidden" >
<div className="px-8 overflow-x-hidden" >
<Breadcrumbs
items={sideNav[0]?.dotcmsdocumentationchildren || []}
currentPath={currentPath}
Expand All @@ -57,9 +56,9 @@ const Documentation = ({ contentlet, sideNav }) => {
</div>

{/* Right Sidebar - Table of Contents */}
<div className="max-w-8">
<aside className="w-64" >
<OnThisPage />
</div>
</aside>
</div>
);
};
Expand Down
15 changes: 8 additions & 7 deletions components/navigation/NavTree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client"

import React, { useState, useCallback, useEffect } from 'react';
import Link from 'next/link';
import { ChevronRight } from 'lucide-react';
Expand All @@ -9,7 +9,7 @@ import {
CollapsibleTrigger,
} from "@/components/ui/collapsible";

const NavTree = React.memo(({ items, currentPath }) => {
const NavTree = React.memo(({ items, currentPath, level = 0 }) => {
const [openSections, setOpenSections] = useState([]);
const relevantPath = currentPath.replace(/^\/docs\/latest\//, '');

Expand Down Expand Up @@ -45,6 +45,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
const renderNavItem = useCallback((item) => {
const isCurrentPage = item.urlTitle === relevantPath;
const hasChildren = item.dotcmsdocumentationchildren && item.dotcmsdocumentationchildren.length > 0;
const paddingY = level === 0 ? 'py-3' : level === 1 ? 'py-2' : 'py-1';

if (hasChildren) {
return (
Expand All @@ -54,7 +55,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
>
<div className="flex flex-col">
<div className={cn(
"flex w-full items-center justify-between rounded-lg px-4 py-2 text-sm font-medium hover:bg-muted",
`flex w-full items-center justify-between rounded-lg px-4 ${paddingY} text-sm font-medium hover:bg-muted`,
isCurrentPage ? "bg-muted font-medium text-foreground" : "text-muted-foreground"
)}>
<Link
Expand All @@ -66,7 +67,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
>
{item.title}
</Link>
<CollapsibleTrigger className="p-1">
<CollapsibleTrigger className="p-0">
<ChevronRight
className={cn(
"h-4 w-4 transition-transform duration-200",
Expand All @@ -76,7 +77,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
</CollapsibleTrigger>
</div>
<CollapsibleContent className="pl-4">
<NavTree items={item.dotcmsdocumentationchildren} currentPath={currentPath} />
<NavTree items={item.dotcmsdocumentationchildren} currentPath={currentPath} level={level + 1}/>
</CollapsibleContent>
</div>
</Collapsible>
Expand All @@ -86,7 +87,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
<Link
href={`/docs/latest/${item.urlTitle}`}
className={cn(
"block rounded-lg px-4 py-2 text-sm hover:bg-muted hover:text-foreground",
`block rounded-lg px-4 ${paddingY} text-sm hover:bg-muted hover:text-foreground`,
isCurrentPage ? "bg-muted font-medium text-foreground" : "text-muted-foreground"
)}
>
Expand All @@ -97,7 +98,7 @@ const NavTree = React.memo(({ items, currentPath }) => {
}, [relevantPath, openSections, toggleSection]);

return (
<div className="space-y-2">
<div className="space-y-2 w-72">
{items.map((item) => (
<div key={item.title}>
{renderNavItem(item)}
Expand Down
2 changes: 1 addition & 1 deletion components/navigation/OnThisPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const OnThisPage = () => {
}

return (
<div className="sticky top-8">
<div className="sticky top-8 w-64">
<h3 className="mb-4 text-sm font-semibold">On This Page</h3>
<nav className="text-sm">
<ul className="space-y-2 text-muted-foreground">
Expand Down
Loading