From 16ae127d9b8ccba419a93a9be18556190a8332ec Mon Sep 17 00:00:00 2001 From: unimu-cic <125171539+unimu-cic@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:41:21 +0800 Subject: [PATCH] feat: improve date picker --- package.json | 2 + src/app/dashboard/page.tsx | 2 +- src/app/globals.css | 7 +++ src/app/page.tsx | 2 +- src/components/Create.tsx | 6 +- src/components/ToDoItem.tsx | 41 ++++++++------ yarn.lock | 108 +++++++++++++++++++++++++++++++++++- 7 files changed, 145 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 022d8b6..9392a06 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "dayjs": "^1.11.10", "next": "14.1.0", "react": "^18", + "react-datepicker": "^6.1.0", "react-dom": "^18", "react-hook-form": "^7.50.0", "zustand": "^4.5.0" @@ -25,6 +26,7 @@ "devDependencies": { "@types/node": "^20", "@types/react": "^18", + "@types/react-datepicker": "^4.19.5", "@types/react-dom": "^18", "autoprefixer": "^10.0.1", "eslint": "^8", diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 88ec9d4..2e2f880 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -3,12 +3,12 @@ import Create from "@/components/Create"; import { cookies } from "next/headers"; import { createServerComponentClient, - Session, } from "@supabase/auth-helpers-nextjs"; import { redirect } from "next/navigation"; import ToDoList from "@/components/ToDoList"; import { Database } from "../../../types_db"; import SignOutBtn from "@/components/SignOutBtn"; +import "react-datepicker/dist/react-datepicker.css"; const Dashboard = async () => { const supabase = createServerComponentClient({ cookies }); diff --git a/src/app/globals.css b/src/app/globals.css index b5c61c9..4ecc358 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1,3 +1,10 @@ @tailwind base; @tailwind components; @tailwind utilities; + +.react-datepicker-wrapper input { + @apply bg-transparent; + @apply placeholder:text-black-300; + @apply outline-0; + @apply appearance-none; +} diff --git a/src/app/page.tsx b/src/app/page.tsx index efcd348..82edd65 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -10,7 +10,7 @@ export default function Home() { Start to GTD -> diff --git a/src/components/Create.tsx b/src/components/Create.tsx index 5042445..63a40e9 100644 --- a/src/components/Create.tsx +++ b/src/components/Create.tsx @@ -53,10 +53,10 @@ const Create: FC = ({ session }) => { return (
-
+
void; onDelete: (id: string) => void; }; -const ToDoItem = ({ todo, onToggle, onUpdate, onDelete }: Props) => { +const ToDoItem = ({todo, onToggle, onUpdate, onDelete}: Props) => { const [isOpen, setIsOpen] = useState(false); const { + control, register, handleSubmit, - formState: { errors }, + formState: {errors}, } = useForm(); const onSubmit: SubmitHandler = (formData) => { @@ -102,7 +104,7 @@ const ToDoItem = ({ todo, onToggle, onUpdate, onDelete }: Props) => { - + @@ -119,7 +121,7 @@ const ToDoItem = ({ todo, onToggle, onUpdate, onDelete }: Props) => { )}
- + setIsOpen(false)} className="fixed top-[50%] left-[50%] max-h-[85vh] text-black w-[90vw] max-w-[450px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] bg-secondary-500 p-[25px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none" @@ -131,7 +133,7 @@ const ToDoItem = ({ todo, onToggle, onUpdate, onDelete }: Props) => { className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmit)} > -
+
{ })} />
-
+
{ {...register("description", {})} />
-
- + { + return ( + + ); + }} />