From 2d6a8d7c9ff856ede0133b76e24b6467929b409b Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Mon, 23 Sep 2024 20:17:08 -0600 Subject: [PATCH] updated new item creation --- .../course/[courseName]/calendar/day/Day.tsx | 36 ++++++++-- .../calendar/day/DayContextMenu.tsx | 70 ------------------- nextjs/src/app/globals.css | 26 +++---- nextjs/src/components/ButtonSelect.tsx | 4 +- 4 files changed, 46 insertions(+), 90 deletions(-) delete mode 100644 nextjs/src/app/course/[courseName]/calendar/day/DayContextMenu.tsx diff --git a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx index 3a48bb0..2a04606 100644 --- a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx @@ -13,7 +13,8 @@ import DropTargetStyling from "../../../../../components/DropTargetStyling"; import { ItemInDay } from "./ItemInDay"; import { useTodaysItems } from "./useTodaysItems"; import { useState } from "react"; -import { DayContextMenu } from "./DayContextMenu"; +import Modal from "@/components/Modal"; +import NewItemForm from "../../modules/NewItemForm"; export default function Day({ day, month }: { day: string; month: number }) { const dayAsDate = getDateFromStringOrThrow( @@ -54,11 +55,12 @@ export default function Day({ day, month }: { day: string; month: number }) { }} > - setContextCoordinates(undefined)} - /> + /> */} +
{todaysAssignments.map( @@ -102,8 +104,30 @@ export default function Day({ day, month }: { day: string; month: number }) { function DayTitle({ day, dayAsDate }: { day: string; dayAsDate: Date }) { const { courseName } = useCourseContext(); return ( - - {dayAsDate.getDate()} - +
+ + {dayAsDate.getDate()} + + + {({ closeModal }) => ( +
+ { + closeModal(); + }} + /> +
+ +
+ )} +
+
); } diff --git a/nextjs/src/app/course/[courseName]/calendar/day/DayContextMenu.tsx b/nextjs/src/app/course/[courseName]/calendar/day/DayContextMenu.tsx deleted file mode 100644 index 7afc527..0000000 --- a/nextjs/src/app/course/[courseName]/calendar/day/DayContextMenu.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import Modal from "@/components/Modal"; -import React, { FC, useEffect, useRef } from "react"; -import NewItemForm from "../../modules/NewItemForm"; - -export const DayContextMenu: FC<{ - coordinates?: { x: number; y: number }; - hideContextMenu: () => void; - day: string; -}> = ({ coordinates, hideContextMenu, day }) => { - const menuRef = useRef(null); - - // const handleContextMenu = (event: MouseEvent) => { - // event.preventDefault(); - // setPosition({ x: event.pageX, y: event.pageY }); - // setVisible(true); - // }; - - const handleClick = (event: MouseEvent) => { - if (menuRef.current && !menuRef.current.contains(event.target as Node)) { - hideContextMenu(); - } - }; - - useEffect(() => { - document.addEventListener("click", handleClick); - - return () => { - document.removeEventListener("click", handleClick); - }; - }, []); - - return ( -
{ - console.log(e.target); - e.stopPropagation(); - hideContextMenu(); - }} - ref={menuRef} - > - - {({ closeModal }) => ( -
- { - closeModal(); - hideContextMenu(); - }} - /> -
- -
- )} -
-
- ); -}; diff --git a/nextjs/src/app/globals.css b/nextjs/src/app/globals.css index 3a34b50..69a79a8 100644 --- a/nextjs/src/app/globals.css +++ b/nextjs/src/app/globals.css @@ -21,7 +21,9 @@ background-color: #020617 !important; /* background-color: #18181b !important; */ } -.monaco-editor { position: absolute !important; } +.monaco-editor { + position: absolute !important; +} .monaco-editor .mtk1 { @apply text-slate-300; @@ -69,14 +71,14 @@ table { } thead { - @apply text-lg ; + @apply text-lg; } -th, td { +th, +td { @apply px-2 py-1 border border-gray-700; } - hr { @apply border-t border-gray-500 my-4; } @@ -93,12 +95,14 @@ p { @apply mb-3; } -button, -.btn { - @apply bg-blue-900 hover:bg-blue-700 text-blue-50; +button, .btn { @apply font-bold py-1 px-3 rounded transition-all duration-200; } +button:not(.unstyled), .btn:not(.unstyled) { + @apply bg-blue-900 hover:bg-blue-700 text-blue-50; +} + .btn-danger { @apply bg-red-800 hover:bg-red-900 text-red-100; } @@ -114,22 +118,20 @@ select { @apply bg-slate-800; } - .collapsible { max-height: 0; overflow: hidden; - transition: max-height .5s ease-out; + transition: max-height 0.5s ease-out; } .collapsible.expand { max-height: 100vh; } - .markdownQuizAnswerPreview p:last-child { - @apply p-0 m-0 ; + @apply p-0 m-0; } .markdownPreview a { @apply text-blue-500 hover:text-blue-600 font-bold underline; -} \ No newline at end of file +} diff --git a/nextjs/src/components/ButtonSelect.tsx b/nextjs/src/components/ButtonSelect.tsx index 3ebe7fd..2e7a1b7 100644 --- a/nextjs/src/components/ButtonSelect.tsx +++ b/nextjs/src/components/ButtonSelect.tsx @@ -12,13 +12,13 @@ export default function ButtonSelect({ selectedOption: T | undefined; }) { return ( -
+
{options.map((o) => (