mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 01:07:01 +00:00
grid calendar and day calendar
This commit is contained in:
@@ -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 { Metadata } from "next";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
@@ -8,8 +9,18 @@ export const metadata: Metadata = {
|
|||||||
|
|
||||||
const page = () => {
|
const page = () => {
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full">
|
<div className="flex flex-col w-full h-full gap-4">
|
||||||
<Calendar />
|
<div className="grid grid-cols-5 gap-4">
|
||||||
|
<div className="bg-card border-neutral-700 rounded-lg grow h-40">.</div>
|
||||||
|
<div className="bg-card border-neutral-700 rounded-lg grow h-40">.</div>
|
||||||
|
<div className="bg-card border-neutral-700 rounded-lg grow h-40">.</div>
|
||||||
|
<div className="bg-card border-neutral-700 rounded-lg grow h-40">.</div>
|
||||||
|
<div className="bg-card border-neutral-700 rounded-lg grow h-40">.</div>
|
||||||
|
</div>
|
||||||
|
<div className="w-full h-full flex gap-4">
|
||||||
|
<MonthCalendar />
|
||||||
|
<Day />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,9 +14,14 @@ const CalenderItemVariants = cva(
|
|||||||
event: "bg-violet-500 border-violet-500",
|
event: "bg-violet-500 border-violet-500",
|
||||||
split: "bg-pink-500 border-pink-500",
|
split: "bg-pink-500 border-pink-500",
|
||||||
},
|
},
|
||||||
|
size: {
|
||||||
|
sm: "",
|
||||||
|
lg: "rounded-lg min-h-16",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
variant: "default",
|
variant: "default",
|
||||||
|
size: "sm",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -24,16 +29,29 @@ const CalenderItemVariants = cva(
|
|||||||
interface CalendarItemProps extends VariantProps<typeof CalenderItemVariants> {
|
interface CalendarItemProps extends VariantProps<typeof CalenderItemVariants> {
|
||||||
// type: "conference" | "dividend" | "earnings" | "event" | "split";
|
// type: "conference" | "dividend" | "earnings" | "event" | "split";
|
||||||
title: string;
|
title: string;
|
||||||
time?: "AMC" | "BMO";
|
time?: string;
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CalendarItem = ({ variant, title, time }: CalendarItemProps) => {
|
const CalendarItem = ({
|
||||||
|
variant,
|
||||||
|
size,
|
||||||
|
title,
|
||||||
|
time,
|
||||||
|
description,
|
||||||
|
}: CalendarItemProps) => {
|
||||||
return (
|
return (
|
||||||
<div className={cn(CalenderItemVariants({ variant }))}>
|
<div className={cn(CalenderItemVariants({ variant, size }))}>
|
||||||
<div className="flex justify-between p-1 text-xs">
|
<div
|
||||||
|
className={cn(
|
||||||
|
size == "sm" ? "text-xs" : "",
|
||||||
|
"flex justify-between p-1 font-semibold"
|
||||||
|
)}
|
||||||
|
>
|
||||||
<p>{title}</p>
|
<p>{title}</p>
|
||||||
<p>{time}</p>
|
<p>{time}</p>
|
||||||
</div>
|
</div>
|
||||||
|
{description && <p className="p-1 font-light">{description}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardDescription,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from "../ui/card";
|
||||||
|
import CalendarItem from "./CalendarItem";
|
||||||
|
|
||||||
|
const Day = () => {
|
||||||
|
return (
|
||||||
|
<Card className="w-1/3 h-full">
|
||||||
|
<CardHeader className="p-4">
|
||||||
|
<CardTitle>Today</CardTitle>
|
||||||
|
<CardDescription>June 12, 2024</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<hr className="border-neutral-700" />
|
||||||
|
<CardContent className="p-0 pt-4">
|
||||||
|
<div className="">
|
||||||
|
<div className="flex items-center gap-1 pl-1">
|
||||||
|
<p className="text-muted-foreground text-sm">9am</p>
|
||||||
|
<div className="w-full">
|
||||||
|
<hr className="border-neutral-500" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="p-2 flex flex-col gap-1">
|
||||||
|
<CalendarItem
|
||||||
|
title="NVDA Earnings"
|
||||||
|
variant="earnings"
|
||||||
|
size="lg"
|
||||||
|
time="BMO"
|
||||||
|
description="Nvidia is reporting earnings after a boom in AI. "
|
||||||
|
/>
|
||||||
|
<CalendarItem
|
||||||
|
title="NVDA Split 10:1"
|
||||||
|
variant="split"
|
||||||
|
size="lg"
|
||||||
|
time="BMO"
|
||||||
|
/>
|
||||||
|
<CalendarItem
|
||||||
|
title="Apple Conference Call"
|
||||||
|
variant="conference"
|
||||||
|
size="lg"
|
||||||
|
time="9 am"
|
||||||
|
description="Apple is holding a conference call to update shareholders about it's recent AI WWDC event."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Day;
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { format } from "date-fns-tz";
|
import { format } from "date-fns-tz";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import CalendarItem from "./CalendarItem";
|
import CalendarItem from "./CalendarItem";
|
||||||
|
import { CardContent, CardHeader, Card, CardTitle } from "../ui/card";
|
||||||
|
|
||||||
const Calendar = () => {
|
const MonthCalendar = () => {
|
||||||
const dates = [
|
const dates = [
|
||||||
{
|
{
|
||||||
"date": "2023-06-12T08:00:00.000Z",
|
"date": "2023-06-12T08:00:00.000Z",
|
||||||
@@ -345,76 +346,89 @@ const Calendar = () => {
|
|||||||
"date": "2023-07-26T08:00:00.000Z",
|
"date": "2023-07-26T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
"date": "2023-07-27T08:00:00.000Z",
|
// "date": "2023-07-27T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-07-28T08:00:00.000Z",
|
// "date": "2023-07-28T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-07-29T08:00:00.000Z",
|
// "date": "2023-07-29T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-07-30T08:00:00.000Z",
|
// "date": "2023-07-30T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-07-31T08:00:00.000Z",
|
// "date": "2023-07-31T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-08-01T08:00:00.000Z",
|
// "date": "2023-08-01T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"date": "2023-08-02T08:00:00.000Z",
|
// "date": "2023-08-02T08:00:00.000Z",
|
||||||
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
// "events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full border border-neutral-700 rounded-lg bg-card">
|
// <div className="w-full h-full border border-neutral-700 rounded-lg bg-card overflow-hidden">
|
||||||
<div className="grid grid-cols-7 grid-rows-6 h-full">
|
<Card className="w-full overflow-hidden">
|
||||||
{dates.map((item, index) => (
|
<CardHeader className="p-4">
|
||||||
<div key={index} className="border border-neutral-700 flex flex-col">
|
<CardTitle>June 2024</CardTitle>
|
||||||
<p className="font-bold p-2">
|
</CardHeader>
|
||||||
{format(item.date, "d", { timeZone: "America/New_York" })}
|
<CardContent className="p-0">
|
||||||
</p>
|
<div className="grid grid-cols-7 grid-rows-5 h-full">
|
||||||
<div className="grid grid-rows-5 overflow-hidden gap-1 p-1">
|
{dates.map((item, index) => (
|
||||||
{item.events.length < 5
|
<div
|
||||||
? item.events.map((event: any, eventkey: number) => (
|
key={index}
|
||||||
<CalendarItem
|
className="border border-neutral-700 flex flex-col"
|
||||||
time={event.time}
|
>
|
||||||
variant={event.variant}
|
<p className="font-bold p-2">
|
||||||
title={event.title}
|
{format(item.date, "d", { timeZone: "America/New_York" })}
|
||||||
key={eventkey}
|
</p>
|
||||||
/>
|
<div className="grid grid-rows-5 overflow-hidden gap-1 p-1">
|
||||||
))
|
{item.events.length < 5
|
||||||
: [
|
? item.events.map((event: any, eventkey: number) => (
|
||||||
...item.events
|
<CalendarItem
|
||||||
.slice(0, 4)
|
time={event.time}
|
||||||
.map((event: any, eventkey: number) => (
|
variant={event.variant}
|
||||||
<CalendarItem
|
title={event.title}
|
||||||
time={event.time}
|
key={eventkey}
|
||||||
variant={event.variant}
|
size="sm"
|
||||||
title={event.title}
|
/>
|
||||||
key={eventkey}
|
))
|
||||||
/>
|
: [
|
||||||
)),
|
...item.events
|
||||||
<CalendarItem
|
.slice(0, 4)
|
||||||
title={`+ ${item.events.length - 4} more`}
|
.map((event: any, eventkey: number) => (
|
||||||
key="end"
|
<CalendarItem
|
||||||
/>,
|
time={event.time}
|
||||||
]}
|
variant={event.variant}
|
||||||
|
title={event.title}
|
||||||
|
key={eventkey}
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
)),
|
||||||
|
<CalendarItem
|
||||||
|
title={`+ ${item.events.length - 4} more`}
|
||||||
|
key="end"
|
||||||
|
size="sm"
|
||||||
|
/>,
|
||||||
|
]}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
))}
|
||||||
))}
|
</div>
|
||||||
</div>
|
</CardContent>
|
||||||
</div>
|
</Card>
|
||||||
|
// </div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Calendar;
|
export default MonthCalendar;
|
||||||
+66
-59
@@ -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<
|
const Card = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-lg border bg-card text-card-foreground shadow-sm",
|
"rounded-lg border border-neutral-700 bg-card text-card-foreground shadow-sm",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
Card.displayName = "Card"
|
Card.displayName = "Card";
|
||||||
|
|
||||||
const CardHeader = React.forwardRef<
|
const CardHeader = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
CardHeader.displayName = "CardHeader"
|
CardHeader.displayName = "CardHeader";
|
||||||
|
|
||||||
const CardTitle = React.forwardRef<
|
const CardTitle = React.forwardRef<
|
||||||
HTMLParagraphElement,
|
HTMLParagraphElement,
|
||||||
React.HTMLAttributes<HTMLHeadingElement>
|
React.HTMLAttributes<HTMLHeadingElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<h3
|
<h3
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-2xl font-semibold leading-none tracking-tight",
|
"text-2xl font-semibold leading-none tracking-tight",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
CardTitle.displayName = "CardTitle"
|
CardTitle.displayName = "CardTitle";
|
||||||
|
|
||||||
const CardDescription = React.forwardRef<
|
const CardDescription = React.forwardRef<
|
||||||
HTMLParagraphElement,
|
HTMLParagraphElement,
|
||||||
React.HTMLAttributes<HTMLParagraphElement>
|
React.HTMLAttributes<HTMLParagraphElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<p
|
<p
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("text-sm text-muted-foreground", className)}
|
className={cn("text-sm text-muted-foreground", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
CardDescription.displayName = "CardDescription"
|
CardDescription.displayName = "CardDescription";
|
||||||
|
|
||||||
const CardContent = React.forwardRef<
|
const CardContent = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
||||||
))
|
));
|
||||||
CardContent.displayName = "CardContent"
|
CardContent.displayName = "CardContent";
|
||||||
|
|
||||||
const CardFooter = React.forwardRef<
|
const CardFooter = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("flex items-center p-6 pt-0", className)}
|
className={cn("flex items-center p-6 pt-0", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
CardFooter.displayName = "CardFooter"
|
CardFooter.displayName = "CardFooter";
|
||||||
|
|
||||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
export {
|
||||||
|
Card,
|
||||||
|
CardHeader,
|
||||||
|
CardFooter,
|
||||||
|
CardTitle,
|
||||||
|
CardDescription,
|
||||||
|
CardContent,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user