From ed429155fd23630881695a896f1d47c6c328fbff Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Wed, 12 Jun 2024 22:23:20 -0400 Subject: [PATCH] grid calendar and day calendar --- src/app/calendar/page.tsx | 17 +- src/components/calendar/CalendarItem.tsx | 26 ++- src/components/calendar/Day.tsx | 55 +++++++ .../{Calendar.tsx => MonthCalendar.tsx} | 148 ++++++++++-------- src/components/ui/card.tsx | 125 ++++++++------- 5 files changed, 238 insertions(+), 133 deletions(-) create mode 100644 src/components/calendar/Day.tsx rename src/components/calendar/{Calendar.tsx => MonthCalendar.tsx} (85%) diff --git a/src/app/calendar/page.tsx b/src/app/calendar/page.tsx index 0445d36..d18df32 100644 --- a/src/app/calendar/page.tsx +++ b/src/app/calendar/page.tsx @@ -1,4 +1,5 @@ -import Calendar from "@/components/calendar/Calendar"; +import Day from "@/components/calendar/Day"; +import MonthCalendar from "@/components/calendar/MonthCalendar"; import { Metadata } from "next"; import React from "react"; @@ -8,8 +9,18 @@ export const metadata: Metadata = { const page = () => { return ( -
- +
+
+
.
+
.
+
.
+
.
+
.
+
+
+ + +
); }; diff --git a/src/components/calendar/CalendarItem.tsx b/src/components/calendar/CalendarItem.tsx index c18c4dd..d7c20e7 100644 --- a/src/components/calendar/CalendarItem.tsx +++ b/src/components/calendar/CalendarItem.tsx @@ -14,9 +14,14 @@ const CalenderItemVariants = cva( event: "bg-violet-500 border-violet-500", split: "bg-pink-500 border-pink-500", }, + size: { + sm: "", + lg: "rounded-lg min-h-16", + }, }, defaultVariants: { variant: "default", + size: "sm", }, } ); @@ -24,16 +29,29 @@ const CalenderItemVariants = cva( interface CalendarItemProps extends VariantProps { // type: "conference" | "dividend" | "earnings" | "event" | "split"; title: string; - time?: "AMC" | "BMO"; + time?: string; + description?: string; } -const CalendarItem = ({ variant, title, time }: CalendarItemProps) => { +const CalendarItem = ({ + variant, + size, + title, + time, + description, +}: CalendarItemProps) => { return ( -
-
+
+

{title}

{time}

+ {description &&

{description}

}
); }; diff --git a/src/components/calendar/Day.tsx b/src/components/calendar/Day.tsx new file mode 100644 index 0000000..8995f27 --- /dev/null +++ b/src/components/calendar/Day.tsx @@ -0,0 +1,55 @@ +import React from "react"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "../ui/card"; +import CalendarItem from "./CalendarItem"; + +const Day = () => { + return ( + + + Today + June 12, 2024 + +
+ +
+
+

9am

+
+
+
+
+
+ + + +
+
+
+
+ ); +}; + +export default Day; diff --git a/src/components/calendar/Calendar.tsx b/src/components/calendar/MonthCalendar.tsx similarity index 85% rename from src/components/calendar/Calendar.tsx rename to src/components/calendar/MonthCalendar.tsx index 701590c..f5cd508 100644 --- a/src/components/calendar/Calendar.tsx +++ b/src/components/calendar/MonthCalendar.tsx @@ -1,8 +1,9 @@ import { format } from "date-fns-tz"; import React from "react"; import CalendarItem from "./CalendarItem"; +import { CardContent, CardHeader, Card, CardTitle } from "../ui/card"; -const Calendar = () => { +const MonthCalendar = () => { const dates = [ { "date": "2023-06-12T08:00:00.000Z", @@ -345,76 +346,89 @@ const Calendar = () => { "date": "2023-07-26T08:00:00.000Z", "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], }, - { - "date": "2023-07-27T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-07-28T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-07-29T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-07-30T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-07-31T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-08-01T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, - { - "date": "2023-08-02T08:00:00.000Z", - "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], - }, + // { + // "date": "2023-07-27T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-07-28T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-07-29T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-07-30T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-07-31T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-08-01T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, + // { + // "date": "2023-08-02T08:00:00.000Z", + // "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }], + // }, ]; return ( -
-
- {dates.map((item, index) => ( -
-

- {format(item.date, "d", { timeZone: "America/New_York" })} -

-
- {item.events.length < 5 - ? item.events.map((event: any, eventkey: number) => ( - - )) - : [ - ...item.events - .slice(0, 4) - .map((event: any, eventkey: number) => ( - - )), - , - ]} + //
+ + + June 2024 + + +
+ {dates.map((item, index) => ( +
+

+ {format(item.date, "d", { timeZone: "America/New_York" })} +

+
+ {item.events.length < 5 + ? item.events.map((event: any, eventkey: number) => ( + + )) + : [ + ...item.events + .slice(0, 4) + .map((event: any, eventkey: number) => ( + + )), + , + ]} +
-
- ))} -
-
+ ))} +
+ + + //
); }; -export default Calendar; +export default MonthCalendar; diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx index afa13ec..df5f519 100644 --- a/src/components/ui/card.tsx +++ b/src/components/ui/card.tsx @@ -1,79 +1,86 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Card = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -
-)) -Card.displayName = "Card" +
+)); +Card.displayName = "Card"; const CardHeader = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -
-)) -CardHeader.displayName = "CardHeader" +
+)); +CardHeader.displayName = "CardHeader"; const CardTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes + HTMLParagraphElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -

-)) -CardTitle.displayName = "CardTitle" +

+)); +CardTitle.displayName = "CardTitle"; const CardDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes + HTMLParagraphElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -

-)) -CardDescription.displayName = "CardDescription" +

+)); +CardDescription.displayName = "CardDescription"; const CardContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -

-)) -CardContent.displayName = "CardContent" +
+)); +CardContent.displayName = "CardContent"; const CardFooter = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -
-)) -CardFooter.displayName = "CardFooter" +
+)); +CardFooter.displayName = "CardFooter"; -export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } +export { + Card, + CardHeader, + CardFooter, + CardTitle, + CardDescription, + CardContent, +};