From 8e5a97622484e37d9e325399e5a60f88476ed1f1 Mon Sep 17 00:00:00 2001 From: pheralb Date: Mon, 26 Dec 2022 17:52:30 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=92=EF=B8=8F=20Add=20Superkey.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 58 ++++++++++++------------ src/components/command/index.tsx | 78 ++++++++++++++++++++++++-------- src/components/header/index.tsx | 4 +- 3 files changed, 90 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index cb9d868..3f0bcfd 100644 --- a/package.json +++ b/package.json @@ -12,46 +12,46 @@ "postinstall": "prisma generate" }, "dependencies": { - "@headlessui/react": "1.7.4", + "@headlessui/react": "1.7.7", "@next-auth/prisma-adapter": "1.0.5", - "@prisma/client": "4.6.1", - "@tanstack/react-query": "4.16.1", - "@trpc/client": "10.1.0", - "@trpc/next": "10.1.0", - "@trpc/react-query": "10.1.0", - "@trpc/server": "10.1.0", + "@prisma/client": "4.8.0", + "@tanstack/react-query": "4.20.4", + "@trpc/client": "10.7.0", + "@trpc/next": "10.7.0", + "@trpc/react-query": "10.7.0", + "@trpc/server": "10.7.0", "@uiball/loaders": "1.2.6", - "@vercel/analytics": "0.1.5", - "framer-motion": "7.6.10", + "@vercel/analytics": "0.1.6", + "framer-motion": "8.0.2", "nanoid": "4.0.0", - "next": "13.0.5", - "next-auth": "4.17.0", - "next-seo": "5.14.1", + "next": "13.1.1", + "next-auth": "4.18.7", + "next-seo": "5.15.0", "nextjs-progressbar": "0.0.16", "react": "18.2.0", "react-dom": "18.2.0", - "react-hook-form": "7.39.5", + "react-hook-form": "7.41.1", "react-hot-toast": "2.4.0", - "react-icons": "4.6.0", - "superjson": "1.11.0", - "superkey": "0.1.0-rc.9", - "zod": "3.19.1" + "react-icons": "4.7.1", + "superjson": "1.12.1", + "superkey": "0.1.3", + "zod": "3.20.2" }, "devDependencies": { - "@types/node": "18.11.9", - "@types/react": "18.0.25", - "@types/react-dom": "18.0.9", - "@typescript-eslint/eslint-plugin": "5.44.0", - "@typescript-eslint/parser": "5.44.0", + "@types/node": "18.11.17", + "@types/react": "18.0.26", + "@types/react-dom": "18.0.10", + "@typescript-eslint/eslint-plugin": "5.47.1", + "@typescript-eslint/parser": "5.47.1", "autoprefixer": "10.4.13", - "eslint": "8.28.0", - "eslint-config-next": "13.0.5", - "postcss": "8.4.19", - "prettier": "2.8.0", - "prettier-plugin-tailwindcss": "0.1.13", - "prisma": "4.6.1", + "eslint": "8.30.0", + "eslint-config-next": "13.1.1", + "postcss": "8.4.20", + "prettier": "2.8.1", + "prettier-plugin-tailwindcss": "0.2.1", + "prisma": "4.8.0", "tailwindcss": "3.2.4", - "typescript": "4.9.3" + "typescript": "4.9.4" }, "ct3aMetadata": { "initVersion": "6.10.2" diff --git a/src/components/command/index.tsx b/src/components/command/index.tsx index 15b1aff..fc96ab6 100644 --- a/src/components/command/index.tsx +++ b/src/components/command/index.tsx @@ -1,23 +1,40 @@ import { useRouter } from "next/router"; -import { useState } from "react"; -import { BiCommand, BiPlus } from "react-icons/bi"; +import { useState, useEffect } from "react"; +import { BiBox, BiCommand, BiMessageSquareEdit, BiPlus } from "react-icons/bi"; +import { BsGithub, BsTwitter } from "react-icons/bs"; import { Command, CommandInput, CommandList, CommandOption } from "superkey"; const data = [ { id: 1, name: "Create new link", - description: "Description 1", href: "/dash/create", icon: , }, { id: 2, - name: "My links", - description: "", + name: "Dashboard", href: "/dash/create", - icon: , - } + icon: , + }, + { + id: 3, + name: "Report a bug", + href: "https://github.com/pheralb/slug/issues/new", + icon: , + }, + { + id: 4, + name: "Repository", + href: "https://github.com/pheralb/slug", + icon: , + }, + { + id: 5, + name: "Twitter", + href: "https://twitter.com/pheralb_", + icon: , + }, ]; const CommandMenu = () => { @@ -25,40 +42,61 @@ const CommandMenu = () => { const [open, setOpen] = useState(false); const router = useRouter(); - const filteredData = value - ? data.filter((example) => - example.name.toLowerCase().includes(value.toLowerCase()) - ) - : data; + useEffect(() => { + function handleKeyDown(event?: KeyboardEvent) { + if (event?.key === "k" && (event?.metaKey || event?.ctrlKey)) { + event?.preventDefault(); + setOpen(!open); + } + } + + if (typeof window !== "undefined") { + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + } + }, [open]); + + const filteredData = data.filter((doc) => { + return doc.name?.toLowerCase().includes(value.toLowerCase()); + }); return ( <> setOpen(true)} /> { + setOpen(!open); + }} commandFunction={(action) => { setOpen(false); router.push(`${action}`); }} - className="bg-midnight text-white border-none" - overlayClassName="bg-midnight/50 text-white" + className="border border-neutral-800 bg-midnight text-white" + overlayClassName="bg-midnight/50" > { setValue(e.target.value); }} - className="bg-midnight text-white border-b border-zinc-800" + className="border-b border-neutral-800 bg-midnight text-white" /> - + {filteredData.map((action) => ( - -
-
{action.icon}
+ +
+
{action.icon}

{action.name}

diff --git a/src/components/header/index.tsx b/src/components/header/index.tsx index 632c384..1a051b8 100644 --- a/src/components/header/index.tsx +++ b/src/components/header/index.tsx @@ -2,6 +2,7 @@ import Link from "next/link"; import { BsGithub } from "react-icons/bs"; import Auth from "@/components/auth"; import IconButton from "@/ui/iconButton"; +import CommandMenu from "../command"; const Header = () => { return ( @@ -13,8 +14,9 @@ const Header = () => {

slug

-
+
+ Date: Mon, 26 Dec 2022 17:52:41 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9A=92=EF=B8=8F=20Update=20schema.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b650b92..3937dc7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,12 +1,10 @@ generator client { - provider = "prisma-client-js" - previewFeatures = ["referentialIntegrity"] + provider = "prisma-client-js" } datasource db { - provider = "mysql" - url = env("DATABASE_URL") - referentialIntegrity = "prisma" + provider = "mysql" + url = env("DATABASE_URL") } model link { From 551496069a09623ec18e5ab16a43c5cad3832522 Mon Sep 17 00:00:00 2001 From: pheralb Date: Mon, 26 Dec 2022 17:53:37 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=92=EF=B8=8F=20Update=20command=20lin?= =?UTF-8?q?k.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/command/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/command/index.tsx b/src/components/command/index.tsx index fc96ab6..5226379 100644 --- a/src/components/command/index.tsx +++ b/src/components/command/index.tsx @@ -14,7 +14,7 @@ const data = [ { id: 2, name: "Dashboard", - href: "/dash/create", + href: "/dash", icon: , }, {