Skip to content

Commit

Permalink
Update InfoBar
Browse files Browse the repository at this point in the history
  • Loading branch information
SkidGod4444 committed Nov 8, 2024
1 parent 2e27916 commit a49ebb5
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 21 deletions.
8 changes: 3 additions & 5 deletions apps/app/app/(routes)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"use client";
import Infobar from "@/components/custom/infobar/infobar";
import InfoBreadCrumb from "@/components/custom/infobar/bread-crumb";
import BillingSettings from "@/components/custom/settings/billing.settings";
import ThemeSettings from "@/components/custom/settings/theme.settings";
import React from "react";

export default function SettingsPage() {
return (
<div className="flex flex-col h-full w-full items-start overflow-hidden p-2">
<div>
<Infobar />
</div>
<div className="flex flex-col h-full w-full items-start overflow-hidden">
<InfoBreadCrumb />
<div className="flex flex-col gap-10">
<BillingSettings />
<ThemeSettings />
Expand Down
3 changes: 3 additions & 0 deletions apps/app/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
--ring: 240 10% 3.9%;
--radius: 0.5rem;

--progress-background: hsl(var(--primary));
--progress-foreground: hsl(var(--primary-foreground));

--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
Expand Down
4 changes: 4 additions & 0 deletions apps/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ThemeProvider } from "@/hooks/theme-provider";
import { SidebarProvider } from "@/components/ui/sidebar";
import { AppSidebar } from "@/components/custom/sidebar/sidebar";
import { cookies } from "next/headers";
import Infobar from "@/components/custom/infobar/infobar";
import ProgressBar from "@/components/custom/progress.bar";

export const metadata: Metadata = {
title: "Plura",
Expand Down Expand Up @@ -34,6 +36,8 @@ async function RootLayout({
<AppSidebar />
<div className="p-2">
{/* <SidebarTrigger/> */}
<ProgressBar />
<Infobar />
{children}
</div>
</SidebarProvider>
Expand Down
4 changes: 2 additions & 2 deletions apps/app/components/custom/infobar/bread-crumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
export default function InfoBreadCrumb() {
const page = usePathname();
return (
<div className="flex flex-col ">
<div className="flex flex-col w-full items-start justify-center mb-6">
<div className="flex gap-5 items-center">
<h2 className="text-3xl font-bold capitalize">
{page.replace(/^\/+/, "")}
Expand All @@ -22,7 +22,7 @@ export default function InfoBreadCrumb() {
</Loader>
)} */}
</div>
<p className="text-muted-foreground text-sm">
<p className="text-muted-foreground text-sm pl-0">
{page == "settings"
? "Manage your account settings, preferences and integrations"
: page == "dashboard"
Expand Down
200 changes: 195 additions & 5 deletions apps/app/components/custom/infobar/infobar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,204 @@
import React from "react";
import InfoBreadCrumb from "./bread-crumb";
"use client";

import React, { useState, useEffect } from "react";
import { SidebarTrigger } from "@/components/ui/sidebar";
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { Check, ChevronsUpDown, Slash } from "lucide-react";
import { Separator } from "@/components/ui/separator";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";

const frameworks = [
{
value: "next.js",
label: "Next.js",
},
{
value: "sveltekit",
label: "SvelteKit",
},
{
value: "nuxt.js",
label: "Nuxt.js",
},
{
value: "remix",
label: "Remix",
},
{
value: "astro",
label: "Astro",
},
];

export default function Infobar() {
const [isScrolled, setIsScrolled] = useState(false);
const [openPopover1, setOpenPopover1] = useState(false);
const [openPopover2, setOpenPopover2] = useState(false);
const [value, setValue] = useState("");

useEffect(() => {
const handleScroll = () => {
setIsScrolled(window.scrollY > 0);
};

window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, []);

return (
<nav className="flex w-full items-start justify-between gap-4 mb-8">
<div className="flex items-center">
<nav
className={`flex flex-col w-full items-start sticky top-0 right-0 bg-background transition-all duration-200 ${
isScrolled ? "shadow-sm backdrop-blur-sm z-10" : ""
}`}
>
<div className="flex flex-row items-center gap-2 py-3 w-full">
<SidebarTrigger />
<Separator orientation="vertical" className="h-6 bg-muted" />
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<Popover open={openPopover1} onOpenChange={setOpenPopover1}>
<PopoverTrigger asChild>
<Button
variant="ghost"
role="combobox"
aria-expanded={openPopover1}
className="justify-between p-2 h-6"
>
{value
? frameworks.find(
(framework) => framework.value === value,
)?.label
: "BlueFinZ"}
<ChevronsUpDown className="opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput
placeholder="Search framework..."
className="h-9"
/>
<CommandList>
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
{frameworks.map((framework) => (
<CommandItem
key={framework.value}
value={framework.value}
onSelect={(currentValue) => {
setValue(
currentValue === value ? "" : currentValue,
);
setOpenPopover1(false);
}}
>
{framework.label}
<Check
className={cn(
"ml-auto",
value === framework.value
? "opacity-100"
: "opacity-0",
)}
/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash className="h-4 w-4" />
</BreadcrumbSeparator>
<BreadcrumbItem>
<Popover open={openPopover2} onOpenChange={setOpenPopover2}>
<PopoverTrigger asChild>
<Button
variant="ghost"
role="combobox"
aria-expanded={openPopover2}
className="justify-between p-2 h-6"
>
{value
? frameworks.find(
(framework) => framework.value === value,
)?.label
: "Plura"}
<ChevronsUpDown className="opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput
placeholder="Search framework..."
className="h-9"
/>
<CommandList>
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
{frameworks.map((framework) => (
<CommandItem
key={framework.value}
value={framework.value}
onSelect={(currentValue) => {
setValue(
currentValue === value ? "" : currentValue,
);
setOpenPopover2(false);
}}
>
{framework.label}
<Check
className={cn(
"ml-auto",
value === framework.value
? "opacity-100"
: "opacity-0",
)}
/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash className="h-4 w-4" />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
</div>
<InfoBreadCrumb />
{isScrolled && (
<div className="h-px bg-gradient-to-r from-transparent via-foreground/10 to-transparent" />
)}
</nav>
);
}
63 changes: 63 additions & 0 deletions apps/app/components/custom/progress.bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"use client";

import { useState, useEffect, useCallback } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import { Progress } from "@/components/ui/progress";

export default function ProgressBar() {
const [progress, setProgress] = useState(0);
const [isVisible, setIsVisible] = useState(false);
const pathname = usePathname();
const searchParams = useSearchParams();

// Function to start progress when navigation begins
const startProgress = useCallback(() => {
setProgress(0);
setIsVisible(true);
}, []);

// Function to complete the progress bar with a delay for smoothness
const completeProgress = useCallback(() => {
setProgress(100);
const timeout = setTimeout(() => {
setIsVisible(false);
setProgress(0);
}, 500);
return () => clearTimeout(timeout);
}, []);

useEffect(() => {
startProgress();

// Gradually increase progress to give a smooth loading effect
const interval = setInterval(() => {
setProgress((prev) => {
if (prev < 90) {
return prev + 10; // Adjust the increment and speed as needed
}
return prev;
});
}, 200); // Update every 200ms for smoothness

// Complete the progress on route change completion
const complete = setTimeout(() => {
completeProgress();
clearInterval(interval);
}, 800); // Total time for the progress to complete

// Cleanup timeouts and interval on unmount or rerender
return () => {
clearTimeout(complete);
clearInterval(interval);
};
}, [pathname, searchParams, startProgress, completeProgress]);

if (!isVisible) return null;

return (
<Progress
value={progress}
className="fixed top-0 left-0 right-0 z-50 h-1 w-full transition-opacity duration-200 bg-transparent"
/>
);
}
9 changes: 3 additions & 6 deletions apps/app/components/custom/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
const items = [
{
title: "Home",
url: "#",
url: "/home",
icon: Home,
},
{
Expand All @@ -50,7 +50,7 @@ const items = [
},
{
title: "Settings",
url: "#",
url: "/settings",
icon: Settings,
},
];
Expand Down Expand Up @@ -78,7 +78,6 @@ export function AppSidebar() {
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
{/* {isExpanded && <SidebarTrigger className="hover:bg-transparent"/>} */}
</div>
</SidebarMenuItem>
</SidebarMenu>
Expand All @@ -104,9 +103,7 @@ export function AppSidebar() {
</SidebarContent>
<SidebarFooter>
<SidebarMenu>
<SidebarMenuItem>
{/* {!isExpanded && <SidebarTrigger/>} */}
</SidebarMenuItem>
<SidebarMenuItem></SidebarMenuItem>
</SidebarMenu>
</SidebarFooter>
</Sidebar>
Expand Down
Loading

0 comments on commit a49ebb5

Please sign in to comment.