Skip to content

Commit

Permalink
navbar done
Browse files Browse the repository at this point in the history
  • Loading branch information
DMJain committed Jan 15, 2025
1 parent 7011f9a commit d90ca70
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 11 deletions.
89 changes: 86 additions & 3 deletions components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,92 @@
import React from 'react'
"use client"

import * as React from "react"
import Link from "next/link"
import { cn } from "@/lib/utils"
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu"
import { MoonIcon, SunIcon } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "./ui/button"

const Nav = () => {
const { setTheme, theme } = useTheme()

return (
<div>Nav</div>
<div className="fixed w-full z-50 top-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<nav className="container flex h-16 items-center justify-between">
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<Link href="/#hero" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Home
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
<NavigationMenuItem>
<Link href="/#about" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
About
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
<NavigationMenuItem>
<Link href="/#skills" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Skills
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
<NavigationMenuItem>
<Link href="/#timeline" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Timeline
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
<NavigationMenuItem>
<Link href="/#projects" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Projects
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
{/* <NavigationMenuItem>
<Link href="/#blog" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Blog
</NavigationMenuLink>
</Link>
</NavigationMenuItem> */}
<NavigationMenuItem>
<Link href="/#contact" legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
Contact
</NavigationMenuLink>
</Link>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
>
<SunIcon className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<MoonIcon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
</nav>
</div>
)
}

export default Nav
export default Nav;
2 changes: 1 addition & 1 deletion components/section/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ArrowDown } from 'lucide-react';

const Hero = () => {
return (
<section id="hero" className="min-h-screen flex items-center justify-center pt-16">
<section id="hero" className="min-h-screen flex items-center justify-center ">
<div className="container flex flex-col items-center text-center gap-8">
<motion.div
initial={{ opacity: 0, y: 20 }}
Expand Down
7 changes: 4 additions & 3 deletions components/section/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const featuredProjects: Project[] = [
title: "BookThatMovie",
description: "Watch your Fav movie near you.",
longDescription: "A Movie booking application to find movies at your nearist theaters.",
image: "/projects/staynest.png",
image: "/projects/moviesite.png",
tags: ["React", "NodeKs", "Socket-IO", "CashFree Payments"],
liveUrl: "",
githubUrl: "https://github.com/DMJain/MovieBookingApp",
Expand Down Expand Up @@ -135,6 +135,7 @@ export default function ProjectsSection() {
src={project.image}
alt={project.title}
fill
sizes="100%"
className="object-cover"
/>
</div>
Expand All @@ -151,12 +152,12 @@ export default function ProjectsSection() {
))}
</div>
<div className="flex gap-2 mt-auto pt-4">
<Button variant="outline" size="sm" className="gap-2" asChild>
{/* <Button variant="outline" size="sm" className="gap-2" asChild>
<a href={project.liveUrl} target="_blank" rel="noopener noreferrer" onClick={(e) => e.stopPropagation()}>
<ExternalLink className="h-4 w-4" />
Live Demo
</a>
</Button>
</Button> */}
<Button variant="outline" size="sm" className="gap-2" asChild>
<a href={project.githubUrl} target="_blank" rel="noopener noreferrer" onClick={(e) => e.stopPropagation()}>
<Github className="h-4 w-4" />
Expand Down
4 changes: 2 additions & 2 deletions components/section/TimelineSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const TimelineSection = () => {
},
];
return (
<div className="w-full">
<section id="timeline" className="w-full">
<Timeline data={data} />
</div>
</section>
);
}

Expand Down
4 changes: 2 additions & 2 deletions components/section/contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export default function ContactSection() {
});
const result = await response.json();
if (result.success) {
console.log(result);
// console.log(result);
}
console.log(values)
// console.log(values)
}

return (
Expand Down
128 changes: 128 additions & 0 deletions components/ui/navigation-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import * as React from 'react';
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';
import { cva } from 'class-variance-authority';
import { ChevronDown } from 'lucide-react';

import { cn } from '@/lib/utils';

const NavigationMenu = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
>(({ className, children, ...props }, ref) => (
<NavigationMenuPrimitive.Root
ref={ref}
className={cn(
'relative z-10 flex max-w-max flex-1 items-center justify-center',
className
)}
{...props}
>
{children}
<NavigationMenuViewport />
</NavigationMenuPrimitive.Root>
));
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;

const NavigationMenuList = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.List>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
>(({ className, ...props }, ref) => (
<NavigationMenuPrimitive.List
ref={ref}
className={cn(
'group flex flex-1 list-none items-center justify-center space-x-1',
className
)}
{...props}
/>
));
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;

const NavigationMenuItem = NavigationMenuPrimitive.Item;

const navigationMenuTriggerStyle = cva(
'group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50'
);

const NavigationMenuTrigger = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<NavigationMenuPrimitive.Trigger
ref={ref}
className={cn(navigationMenuTriggerStyle(), 'group', className)}
{...props}
>
{children}{' '}
<ChevronDown
className="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180"
aria-hidden="true"
/>
</NavigationMenuPrimitive.Trigger>
));
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;

const NavigationMenuContent = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
>(({ className, ...props }, ref) => (
<NavigationMenuPrimitive.Content
ref={ref}
className={cn(
'left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ',
className
)}
{...props}
/>
));
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;

const NavigationMenuLink = NavigationMenuPrimitive.Link;

const NavigationMenuViewport = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
>(({ className, ...props }, ref) => (
<div className={cn('absolute left-0 top-full flex justify-center')}>
<NavigationMenuPrimitive.Viewport
className={cn(
'origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]',
className
)}
ref={ref}
{...props}
/>
</div>
));
NavigationMenuViewport.displayName =
NavigationMenuPrimitive.Viewport.displayName;

const NavigationMenuIndicator = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
>(({ className, ...props }, ref) => (
<NavigationMenuPrimitive.Indicator
ref={ref}
className={cn(
'top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in',
className
)}
{...props}
>
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
</NavigationMenuPrimitive.Indicator>
));
NavigationMenuIndicator.displayName =
NavigationMenuPrimitive.Indicator.displayName;

export {
navigationMenuTriggerStyle,
NavigationMenu,
NavigationMenuList,
NavigationMenuItem,
NavigationMenuContent,
NavigationMenuTrigger,
NavigationMenuLink,
NavigationMenuIndicator,
NavigationMenuViewport,
};
Loading

0 comments on commit d90ca70

Please sign in to comment.