Command thing

main
Elias Almqvist 8 months ago
parent 8347566e1c
commit 23d2289b64
No known key found for this signature in database
GPG Key ID: E31A99CE3E75A158
  1. 2
      src/app/page.tsx
  2. 5
      src/components/layout/header.tsx
  3. 31
      src/components/layout/nav.tsx
  4. 10
      src/components/navlinks.tsx

@ -2,7 +2,7 @@ export default function Home() {
return ( return (
<> <>
<section id="about" className="min-h-screen"> <section id="about" className="min-h-screen">
<h1>Hello, I am a </h1> <h1 className="text-2xl">Hello, I am a </h1>
</section> </section>
</> </>
); );

@ -30,9 +30,10 @@ const Header = () => (
<ThemeButton className="w-4 h-4 hidden sm:block" /> <ThemeButton className="w-4 h-4 hidden sm:block" />
<NavCommand /> <NavCommand />
<ul className="flex-row space-x-2 w-fit h-full items-center hidden sm:flex"> <ul className="flex-row space-x-2 w-fit h-full items-center hidden sm:flex">
{NavLinks.map((link) => ( {NavLinks.map((link, index) => (
<li> <li>
<Link <Link
key={index}
href={link.href} href={link.href}
target={link.href.match("http") ? "_blank" : "_self"} target={link.href.match("http") ? "_blank" : "_self"}
className="flex flex-row items-center" className="flex flex-row items-center"
@ -42,7 +43,7 @@ const Header = () => (
size="icon" size="icon"
className="transition-opacity hover:bg-transparent hover:opacity-75" className="transition-opacity hover:bg-transparent hover:opacity-75"
> >
{link.icon} <link.icon className="h-5 w-5" />
</Button> </Button>
</Link> </Link>
</li> </li>

@ -1,7 +1,5 @@
"use client"; "use client";
import { useState } from "react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@ -18,17 +16,13 @@ import { GalleryHorizontalEnd, Home, SunMoon } from "lucide-react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useActionCommand } from "@/hooks/useActionCommand"; import { useActionCommand } from "@/hooks/useActionCommand";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import NavLinks from "../navlinks";
type NavCommandProps = { type NavCommandProps = {
className?: string; className?: string;
}; };
const NavCommand: React.FC<NavCommandProps> = ({ const NavCommand: React.FC<NavCommandProps> = ({ className, ...props }) => {
className,
...props
}) => {
const [value, setValue] = useState("");
const router = useRouter(); const router = useRouter();
const { open: actionOpen, setOpen: setActionOpen } = useActionCommand(); const { open: actionOpen, setOpen: setActionOpen } = useActionCommand();
const { theme, setTheme } = useTheme(); const { theme, setTheme } = useTheme();
@ -61,12 +55,7 @@ const NavCommand: React.FC<NavCommandProps> = ({
</Button> </Button>
<CommandDialog open={actionOpen} onOpenChange={setActionOpen}> <CommandDialog open={actionOpen} onOpenChange={setActionOpen}>
<CommandInput <CommandInput placeholder="Type a command or search..." />
placeholder="Type a command or search..."
onValueChange={(search) => {
setValue(search);
}}
/>
<CommandList> <CommandList>
<CommandGroup heading="Navigation"> <CommandGroup heading="Navigation">
<CommandItem <CommandItem
@ -102,6 +91,20 @@ const NavCommand: React.FC<NavCommandProps> = ({
<CommandShortcut>L</CommandShortcut> <CommandShortcut>L</CommandShortcut>
</CommandItem> </CommandItem>
</CommandGroup> </CommandGroup>
<CommandSeparator />
<CommandGroup heading="External links">
{NavLinks.map((link) => (
<CommandItem
key={link.href}
onSelect={action(() => {
router.push(link.href);
})}
>
<link.icon className="mr-2 w-4 h-4" />
<span>{link.label}</span>
</CommandItem>
))}
</CommandGroup>
</CommandList> </CommandList>
</CommandDialog> </CommandDialog>
</> </>

@ -6,27 +6,25 @@ import { FaXTwitter } from "react-icons/fa6";
type NavLink = { type NavLink = {
label: string; label: string;
icon: React.ReactNode; icon: React.FC<{ className?: string }>;
href: string; href: string;
}; };
const IconClassname = "w-5 h-5";
const NavLinks: NavLink[] = [ const NavLinks: NavLink[] = [
{ {
label: "GitHub", label: "GitHub",
href: "https://github.com/almqv", href: "https://github.com/almqv",
icon: <GitHub className={IconClassname} />, icon: GitHub,
}, },
{ {
label: "LinkedIn", label: "LinkedIn",
href: "https://www.linkedin.com/in/almqv/", href: "https://www.linkedin.com/in/almqv/",
icon: <LinkedInLogoIcon className={IconClassname} />, icon: LinkedInLogoIcon,
}, },
{ {
label: "X", label: "X",
href: "https://x.com/fcvprzhfgsybj", href: "https://x.com/fcvprzhfgsybj",
icon: <FaXTwitter className={IconClassname} />, icon: FaXTwitter,
}, },
]; ];

Loading…
Cancel
Save