Skip to content

Commit

Permalink
💄 Updated responsive navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Dec 5, 2023
1 parent 039e72f commit dfab062
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"use client"

import { Button } from "@/components/ui/button"
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet"
import { MenuIcon } from "lucide-react"
import { useState } from "react"


export function SmallNav({
onLinkClick
} : {
onLinkClick: (name: string) => void
}) {
const [selectedItem, setSelectedItem] = useState<string>("dashboard");
const [open, setOpen] = useState(false);
const navItemClassName = (itemName: string) =>
`text-sm border-b font-medium w-full text-left mx-0 py-2 hover:bg-gray-900 cursor-pointer ${
selectedItem === itemName ? "bg-gray-900" : "text-muted-foreground"
} transition-colors`;

function click(name: string) {
setSelectedItem(name);
onLinkClick(name);
setOpen(false);
}
return (
<div className="flex flex-row mx-0 px-0">
<Sheet key={"left"} open={open}>
<SheetTrigger asChild className=" ml-4 mt-4">
<Button variant="outline" onClick={()=> setOpen(true)}><MenuIcon className="h-6 w-6" /></Button>
</SheetTrigger>
<SheetContent side={"left"} className="p-0">
<SheetHeader>
<SheetTitle className="mx-4 my-4">
<img src="logo.png" className="w-16"/> <span className="font-bold">Panora.</span>
</SheetTitle>
</SheetHeader>
<nav
className={`flex flex-col items-start mt-6`}
>
<a
className={navItemClassName('quickstart')}
onClick={() => click('quickstart')}
>
<p className="mx-4">Quick Start</p>
</a>
<a
className={navItemClassName('dashboard')}
onClick={() => click('dashboard')}
>
<p className="mx-4">Dashboard</p>
</a>
<a
className={navItemClassName('jobs')}
onClick={() => click('jobs')}
>
<p className="mx-4">Jobs</p>

</a>
<a
className={navItemClassName('connections')}
onClick={() => click('connections')}
>
<p className="mx-4">Connections</p>
</a>
<a
className={navItemClassName('configuration')}
onClick={() => click('configuration')}
>
<p className="mx-4">Configuration</p>
</a>
<a
className={navItemClassName('api-keys')}
onClick={() => click('api-keys')}
>
<p className="mx-4">API Keys</p>
</a>
<a
className={`${navItemClassName('docs')} flex items-center`}
href="https://docs.panora.dev/"
target="_blank"
rel="noopener noreferrer"
>
<p className="mx-4">Docs</p>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
</a>
{/* Add other nav items as needed */}
</nav>
</SheetContent>
</Sheet>
</div>
)
}
38 changes: 27 additions & 11 deletions packages/webapp/src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import { MainNav } from "./components/main-nav"
import TeamSwitcher from "../shared/team-switcher"
import { UserNav } from "./components/user-nav"
import { useState } from "react"
import { useEffect, useState } from "react"
import JobsPage from "../jobs"
import ConnectionsPage from "../connections"
import MainPage from "../main-component"
import ConfigurationPage from "../configuration"
import ApiKeysPage from "../api-keys"
import QuickStartPage from "../quickstart"
import { SmallNav } from "./components/main-nav-sm"

export default function DashboardPage() {
const [activePage, setActivePage] = useState('dashboard');
const [windowWidth, setWindowWidth] = useState(window.innerWidth);

useEffect(() => {
const handleResize = () => setWindowWidth(window.innerWidth);

window.addEventListener('resize', handleResize);

// Clean up the event listener when the component unmounts
return () => window.removeEventListener('resize', handleResize);
}, []);

const lgBreakpoint = 1024; // Tailwind's 'lg' breakpoint


let ContentComponent;
switch (activePage) {
Expand All @@ -37,18 +51,20 @@ export default function DashboardPage() {
}
return (
<>
<div className="flex">
<div className="flex items-center lg:flex-col border-r fixed left-0 bg-opacity-90 backdrop-filter backdrop-blur-lg w-[200px] h-screen">
<div className="flex lg:flex-col items-center py-4 space-y-4">
<img src="logo.png" className="w-16"/> <span className="font-bold">Panora.</span>
<TeamSwitcher className="w-40" />
<MainNav className="flex lg:flex-col mx-auto w-[200px] space-y-0" onLinkClick={setActivePage} />
<div className="ml-auto flex lg:flex-col items-center space-x-4 w-full">
<UserNav />
<div>
{ windowWidth < lgBreakpoint ? <SmallNav onLinkClick={setActivePage} /> :
<div className="items-center hidden lg:flex lg:flex-col border-r fixed left-0 bg-opacity-90 backdrop-filter backdrop-blur-lg w-[200px] h-screen">
<div className="flex lg:flex-col items-center py-4 space-y-4">
<img src="logo.png" className="w-16"/> <span className="font-bold">Panora.</span>
<TeamSwitcher className="w-40" />
<MainNav className="flex lg:flex-col mx-auto w-[200px] space-y-0" onLinkClick={setActivePage} />
<div className="ml-auto flex lg:flex-col items-center space-x-4 w-full">
<UserNav />
</div>
</div>
</div>
</div>
<div className="flex-1 space-y-4 pt-6 px-10 ml-[200px]">
}
<div className="flex-1 space-y-4 pt-6 px-10 lg:ml-[200px]">
<ContentComponent/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/src/components/jobs/JobsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DataTableLoading } from "../shared/data-table-loading";
export default function JobsTable() {
const { data: jobs, isLoading, error } = useJobs();

//TODO
const transformedJobs = jobs?.map((job: Job) => ({
method: '', // replace with actual value
url: '', // replace with actual value
Expand Down
4 changes: 2 additions & 2 deletions packages/webapp/src/components/shared/data-table-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function DataTableToolbar<TData>({
<div className="flex flex-1 items-center space-x-2">
<Input
placeholder="Filter jobs..."
value={(table.getColumn("title")?.getFilterValue() as string) ?? ""}
value={(table.getColumn("method")?.getFilterValue() as string) ?? ""}
onChange={(event) =>
table.getColumn("title")?.setFilterValue(event.target.value)
table.getColumn("method")?.setFilterValue(event.target.value)
}
className="h-8 w-[150px] lg:w-[250px]"
/>
Expand Down
3 changes: 1 addition & 2 deletions packages/webapp/src/components/shared/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
} from "@/components/ui/table"

import { DataTablePagination } from "./data-table-pagination"
import { DataTableToolbar } from "./data-table-toolbar"

interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[]
Expand Down Expand Up @@ -69,7 +68,7 @@ export function DataTable<TData, TValue>({

return (
<div className="space-y-4">
<DataTableToolbar table={table} />
{/*<DataTableToolbar table={table} />*/}
<div className="rounded-md border">
<Table>
<TableHeader>
Expand Down
138 changes: 138 additions & 0 deletions packages/webapp/src/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import * as React from "react"
import * as SheetPrimitive from "@radix-ui/react-dialog"
import { Cross2Icon } from "@radix-ui/react-icons"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const Sheet = SheetPrimitive.Root

const SheetTrigger = SheetPrimitive.Trigger

const SheetClose = SheetPrimitive.Close

const SheetPortal = SheetPrimitive.Portal

const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
ref={ref}
/>
))
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName

const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
{
variants: {
side: {
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
bottom:
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
right:
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
},
},
defaultVariants: {
side: "right",
},
}
)

interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
VariantProps<typeof sheetVariants> {}

const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(({ side = "right", className, children, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
ref={ref}
className={cn(sheetVariants({ side }), className)}
{...props}
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
<Cross2Icon className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
))
SheetContent.displayName = SheetPrimitive.Content.displayName

const SheetHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
)
SheetHeader.displayName = "SheetHeader"

const SheetFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
)
SheetFooter.displayName = "SheetFooter"

const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Title
ref={ref}
className={cn("text-lg font-semibold text-foreground", className)}
{...props}
/>
))
SheetTitle.displayName = SheetPrimitive.Title.displayName

const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
SheetDescription.displayName = SheetPrimitive.Description.displayName

export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
}

0 comments on commit dfab062

Please sign in to comment.