From d2ad50c54b535a2221ff69f1999fb6a6479cb1d3 Mon Sep 17 00:00:00 2001 From: Aayush Kumar Bhat Date: Wed, 30 Oct 2024 19:06:28 +0530 Subject: [PATCH 1/6] Add feature: Navbar --- app/(root)/page.tsx | 151 +++++++++++++++++++++++++++++++++++---- app/about/layout.tsx | 19 +++++ app/about/page.tsx | 9 +++ app/community/layout.tsx | 19 +++++ app/community/page.tsx | 9 +++ app/datasets/layout.tsx | 19 +++++ app/datasets/page.tsx | 9 +++ app/models/layout.tsx | 19 +++++ app/models/page.tsx | 9 +++ components/ui/dialog.tsx | 122 +++++++++++++++++++++++++++++++ package-lock.json | 2 - {app => public}/icon.ico | Bin 12 files changed, 373 insertions(+), 14 deletions(-) create mode 100644 app/about/layout.tsx create mode 100644 app/about/page.tsx create mode 100644 app/community/layout.tsx create mode 100644 app/community/page.tsx create mode 100644 app/datasets/layout.tsx create mode 100644 app/datasets/page.tsx create mode 100644 app/models/layout.tsx create mode 100644 app/models/page.tsx create mode 100644 components/ui/dialog.tsx rename {app => public}/icon.ico (100%) diff --git a/app/(root)/page.tsx b/app/(root)/page.tsx index 3a45f5d..0eedcca 100644 --- a/app/(root)/page.tsx +++ b/app/(root)/page.tsx @@ -1,18 +1,145 @@ -import { Button } from "@/components/ui/button"; +'use client'; import Link from "next/link"; +import { useState, useEffect } from "react"; +import { Button } from "@/components/ui/button"; +import { Dialog, DialogTrigger, DialogContent, DialogTitle } from "@/components/ui/dialog"; +import Image from "next/image"; +import { Search, Moon, Sun, Menu } from "lucide-react"; // Import Menu icon from Lucide + +const commands = [ + { label: "Home", href: "/" }, + { label: "Datasets", href: "/datasets" }, + { label: "Models", href: "/models" }, + { label: "Learn", href: "/learn" }, + { label: "Community", href: "/community" }, + { label: "About", href: "/about" }, +]; + +// Define props type for Navbar +interface NavbarProps { + darkMode: boolean; + toggleDarkMode: () => void; +} + +function Navbar({ darkMode, toggleDarkMode }: NavbarProps) { + const [isOpen, setIsOpen] = useState(false); + const [searchTerm, setSearchTerm] = useState(""); + + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === "Escape") { + setIsOpen(false); + } + }; + + useEffect(() => { + // Add event listener for keydown + window.addEventListener("keydown", handleKeyDown); + + return () => { + // Cleanup the event listener + window.removeEventListener("keydown", handleKeyDown); + }; + }, []); + + return ( + + ); +} + +// Define props type for Home export default function Home() { + const [isOpen, setIsOpen] = useState(false); // To control the dialog state + const [darkMode, setDarkMode] = useState(false); // State for dark mode + + const toggleDarkMode = () => { + setDarkMode(prevMode => !prevMode); + }; + return ( -
-

ML4E

-

- Machine Learning for Everyone is a collection of resources to help you learn machine learning. -

- - - -
+
+ +
+

+ ML4E +

+

+ Machine Learning for Everyone is a collection of resources to help you + learn machine learning. +

+ + + +
+
); } diff --git a/app/about/layout.tsx b/app/about/layout.tsx new file mode 100644 index 0000000..0dae3b3 --- /dev/null +++ b/app/about/layout.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Metadata } from 'next'; +import { SidebarProvider } from "@/components/ui/sidebar" +import AppSidebar from "@/components/custom/AppSidebar"; + +export const metadata: Metadata = { + title: "Learn - ML4E", + description: "ML4E - Machine Learning for Everyone is a collection of resources to help you learn machine learning.", +}; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + +
+ {children} +
+ ) +} + diff --git a/app/about/page.tsx b/app/about/page.tsx new file mode 100644 index 0000000..e407959 --- /dev/null +++ b/app/about/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
this is about page
+ ) +} + +export default page \ No newline at end of file diff --git a/app/community/layout.tsx b/app/community/layout.tsx new file mode 100644 index 0000000..0dae3b3 --- /dev/null +++ b/app/community/layout.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Metadata } from 'next'; +import { SidebarProvider } from "@/components/ui/sidebar" +import AppSidebar from "@/components/custom/AppSidebar"; + +export const metadata: Metadata = { + title: "Learn - ML4E", + description: "ML4E - Machine Learning for Everyone is a collection of resources to help you learn machine learning.", +}; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + +
+ {children} +
+ ) +} + diff --git a/app/community/page.tsx b/app/community/page.tsx new file mode 100644 index 0000000..ae7ba16 --- /dev/null +++ b/app/community/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
this is community page
+ ) +} + +export default page \ No newline at end of file diff --git a/app/datasets/layout.tsx b/app/datasets/layout.tsx new file mode 100644 index 0000000..0dae3b3 --- /dev/null +++ b/app/datasets/layout.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Metadata } from 'next'; +import { SidebarProvider } from "@/components/ui/sidebar" +import AppSidebar from "@/components/custom/AppSidebar"; + +export const metadata: Metadata = { + title: "Learn - ML4E", + description: "ML4E - Machine Learning for Everyone is a collection of resources to help you learn machine learning.", +}; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + +
+ {children} +
+ ) +} + diff --git a/app/datasets/page.tsx b/app/datasets/page.tsx new file mode 100644 index 0000000..039a248 --- /dev/null +++ b/app/datasets/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
this is dataset page
+ ) +} + +export default page \ No newline at end of file diff --git a/app/models/layout.tsx b/app/models/layout.tsx new file mode 100644 index 0000000..0dae3b3 --- /dev/null +++ b/app/models/layout.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Metadata } from 'next'; +import { SidebarProvider } from "@/components/ui/sidebar" +import AppSidebar from "@/components/custom/AppSidebar"; + +export const metadata: Metadata = { + title: "Learn - ML4E", + description: "ML4E - Machine Learning for Everyone is a collection of resources to help you learn machine learning.", +}; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + +
+ {children} +
+ ) +} + diff --git a/app/models/page.tsx b/app/models/page.tsx new file mode 100644 index 0000000..156f494 --- /dev/null +++ b/app/models/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
this is models page
+ ) +} + +export default page \ No newline at end of file diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx new file mode 100644 index 0000000..95b0d38 --- /dev/null +++ b/components/ui/dialog.tsx @@ -0,0 +1,122 @@ +"use client" + +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { Cross2Icon } from "@radix-ui/react-icons" + +import { cn } from "@/lib/utils" + +const Dialog = DialogPrimitive.Root + +const DialogTrigger = DialogPrimitive.Trigger + +const DialogPortal = DialogPrimitive.Portal + +const DialogClose = DialogPrimitive.Close + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +DialogContent.displayName = DialogPrimitive.Content.displayName + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogHeader.displayName = "DialogHeader" + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogFooter.displayName = "DialogFooter" + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogTitle.displayName = DialogPrimitive.Title.displayName + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogDescription.displayName = DialogPrimitive.Description.displayName + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogTrigger, + DialogClose, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +} diff --git a/package-lock.json b/package-lock.json index a600581..7b19b13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1009,7 +1009,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.2.tgz", "integrity": "sha512-Yj4dZtqa2o+kG61fzB0H2qUvmwBA2oyQroGLyNtBj1beo1khoQ3q1a2AO8rrQYjd8256CO9+N8L9tvsS+bnIyA==", - "license": "MIT", "dependencies": { "@radix-ui/primitive": "1.1.0", "@radix-ui/react-compose-refs": "1.1.0", @@ -4555,7 +4554,6 @@ "version": "0.454.0", "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.454.0.tgz", "integrity": "sha512-hw7zMDwykCLnEzgncEEjHeA6+45aeEzRYuKHuyRSOPkhko+J3ySGjGIzu+mmMfDFG1vazHepMaYFYHbTFAZAAQ==", - "license": "ISC", "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" } diff --git a/app/icon.ico b/public/icon.ico similarity index 100% rename from app/icon.ico rename to public/icon.ico From d4f11f661e32c12ca41bb275f37f7cf23bdfe886 Mon Sep 17 00:00:00 2001 From: Aayush Kumar Bhat Date: Wed, 30 Oct 2024 20:10:19 +0530 Subject: [PATCH 2/6] fixed --- app/about/layout.tsx | 3 --- app/community/layout.tsx | 2 -- app/datasets/layout.tsx | 2 -- app/models/layout.tsx | 2 -- 4 files changed, 9 deletions(-) diff --git a/app/about/layout.tsx b/app/about/layout.tsx index 0dae3b3..6add61c 100644 --- a/app/about/layout.tsx +++ b/app/about/layout.tsx @@ -1,8 +1,5 @@ import React from 'react'; import { Metadata } from 'next'; -import { SidebarProvider } from "@/components/ui/sidebar" -import AppSidebar from "@/components/custom/AppSidebar"; - export const metadata: Metadata = { title: "Learn - ML4E", description: "ML4E - Machine Learning for Everyone is a collection of resources to help you learn machine learning.", diff --git a/app/community/layout.tsx b/app/community/layout.tsx index 0dae3b3..93ff9bb 100644 --- a/app/community/layout.tsx +++ b/app/community/layout.tsx @@ -1,7 +1,5 @@ import React from 'react'; import { Metadata } from 'next'; -import { SidebarProvider } from "@/components/ui/sidebar" -import AppSidebar from "@/components/custom/AppSidebar"; export const metadata: Metadata = { title: "Learn - ML4E", diff --git a/app/datasets/layout.tsx b/app/datasets/layout.tsx index 0dae3b3..93ff9bb 100644 --- a/app/datasets/layout.tsx +++ b/app/datasets/layout.tsx @@ -1,7 +1,5 @@ import React from 'react'; import { Metadata } from 'next'; -import { SidebarProvider } from "@/components/ui/sidebar" -import AppSidebar from "@/components/custom/AppSidebar"; export const metadata: Metadata = { title: "Learn - ML4E", diff --git a/app/models/layout.tsx b/app/models/layout.tsx index 0dae3b3..93ff9bb 100644 --- a/app/models/layout.tsx +++ b/app/models/layout.tsx @@ -1,7 +1,5 @@ import React from 'react'; import { Metadata } from 'next'; -import { SidebarProvider } from "@/components/ui/sidebar" -import AppSidebar from "@/components/custom/AppSidebar"; export const metadata: Metadata = { title: "Learn - ML4E", From 79f61127f64362aaf5bb86b72eb21a070ea30b6d Mon Sep 17 00:00:00 2001 From: Aayush Kumar Bhat Date: Wed, 30 Oct 2024 20:18:12 +0530 Subject: [PATCH 3/6] small fix --- app/(root)/page.tsx | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/app/(root)/page.tsx b/app/(root)/page.tsx index 0eedcca..d08c94a 100644 --- a/app/(root)/page.tsx +++ b/app/(root)/page.tsx @@ -4,7 +4,7 @@ import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogTrigger, DialogContent, DialogTitle } from "@/components/ui/dialog"; import Image from "next/image"; -import { Search, Moon, Sun, Menu } from "lucide-react"; // Import Menu icon from Lucide +import { Search, Moon, Sun, Menu } from "lucide-react"; const commands = [ { label: "Home", href: "/" }, @@ -15,14 +15,14 @@ const commands = [ { label: "About", href: "/about" }, ]; -// Define props type for Navbar interface NavbarProps { darkMode: boolean; toggleDarkMode: () => void; + isOpen: boolean; // Add isOpen as a prop + setIsOpen: (open: boolean) => void; // Add setIsOpen as a prop } -function Navbar({ darkMode, toggleDarkMode }: NavbarProps) { - const [isOpen, setIsOpen] = useState(false); +function Navbar({ darkMode, toggleDarkMode, isOpen, setIsOpen }: NavbarProps) { const [searchTerm, setSearchTerm] = useState(""); const handleKeyDown = (event: KeyboardEvent) => { @@ -32,11 +32,9 @@ function Navbar({ darkMode, toggleDarkMode }: NavbarProps) { }; useEffect(() => { - // Add event listener for keydown window.addEventListener("keydown", handleKeyDown); return () => { - // Cleanup the event listener window.removeEventListener("keydown", handleKeyDown); }; }, []); @@ -44,7 +42,6 @@ function Navbar({ darkMode, toggleDarkMode }: NavbarProps) { return (