calendar init

This commit is contained in:
2024-06-12 18:19:43 -04:00
parent 085d82d3dd
commit a9094a2367
7 changed files with 3148 additions and 3298 deletions
+1
View File
@@ -27,6 +27,7 @@
"clsx": "^2.1.0", "clsx": "^2.1.0",
"cmdk": "^1.0.0", "cmdk": "^1.0.0",
"date-fns": "^3.3.1", "date-fns": "^3.3.1",
"date-fns-tz": "^3.1.3",
"lightweight-charts": "^4.1.3", "lightweight-charts": "^4.1.3",
"lucide-react": "^0.338.0", "lucide-react": "^0.338.0",
"next": "14.1.0", "next": "14.1.0",
+2507 -3203
View File
File diff suppressed because it is too large Load Diff
+6 -1
View File
@@ -1,3 +1,4 @@
import Calendar from "@/components/calendar/Calendar";
import { Metadata } from "next"; import { Metadata } from "next";
import React from "react"; import React from "react";
@@ -6,7 +7,11 @@ export const metadata: Metadata = {
}; };
const page = () => { const page = () => {
return <div>Calendar</div>; return (
<div className="w-full h-full">
<Calendar />
</div>
);
}; };
export default page; export default page;
+420
View File
@@ -0,0 +1,420 @@
import { format } from "date-fns-tz";
import React from "react";
import CalendarItem from "./CalendarItem";
const Calendar = () => {
const dates = [
{
"date": "2023-06-12T08:00:00.000Z",
"events": [
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
{ "title": "MSFT Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "MSFT Split", "variant": "split", "time": "AMC" },
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "BABA Event", "variant": "event", "time": "BMO" },
{ "title": "WMT Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "AMZN Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "BABA Conference", "variant": "conference", "time": "BMO" },
],
},
{
"date": "2023-06-13T08:00:00.000Z",
"events": [
{ "title": "TSLA Event", "variant": "event", "time": "AMC" },
{ "title": "JPM Conference", "variant": "conference", "time": "BMO" },
{ "title": "WMT Event", "variant": "event", "time": "BMO" },
{ "title": "GOOGL Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "META Event", "variant": "event", "time": "AMC" },
{ "title": "GOOGL Event", "variant": "event", "time": "AMC" },
],
},
{
"date": "2023-06-14T08:00:00.000Z",
"events": [
{ "title": "JPM Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AAPL Conference", "variant": "conference", "time": "AMC" },
{ "title": "META Split", "variant": "split", "time": "AMC" },
{ "title": "AMZN Conference", "variant": "conference", "time": "BMO" },
],
},
{
"date": "2023-06-15T08:00:00.000Z",
"events": [
{ "title": "JPM Conference", "variant": "conference", "time": "BMO" },
{ "title": "BABA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "BABA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "AMZN Split", "variant": "split", "time": "AMC" },
],
},
{
"date": "2023-06-16T08:00:00.000Z",
"events": [
{ "title": "AMZN Event", "variant": "event", "time": "AMC" },
{ "title": "JPM Conference", "variant": "conference", "time": "AMC" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "MSFT Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "META Conference", "variant": "conference", "time": "AMC" },
{ "title": "MSFT Conference", "variant": "conference", "time": "AMC" },
{ "title": "AMZN Split", "variant": "split", "time": "AMC" },
{ "title": "WMT Split", "variant": "split", "time": "AMC" },
],
},
{
"date": "2023-06-19T08:00:00.000Z",
"events": [
{ "title": "TSLA Conference", "variant": "conference", "time": "AMC" },
{ "title": "AMZN Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "MSFT Event", "variant": "event", "time": "AMC" },
{ "title": "MSFT Conference", "variant": "conference", "time": "BMO" },
],
},
{
"date": "2023-06-20T08:00:00.000Z",
"events": [
{ "title": "AAPL Conference", "variant": "conference", "time": "BMO" },
{ "title": "WMT Event", "variant": "event", "time": "BMO" },
{ "title": "MSFT Conference", "variant": "conference", "time": "BMO" },
{ "title": "TSLA Event", "variant": "event", "time": "BMO" },
{ "title": "GOOGL Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "TSLA Earnings", "variant": "earnings", "time": "AMC" },
],
},
{
"date": "2023-06-21T08:00:00.000Z",
"events": [
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "GOOGL Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "WMT Event", "variant": "event", "time": "BMO" },
{ "title": "NVDA Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "AMZN Conference", "variant": "conference", "time": "AMC" },
{ "title": "NVDA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "JPM Split", "variant": "split", "time": "BMO" },
],
},
{
"date": "2023-06-22T08:00:00.000Z",
"events": [
{ "title": "AMZN Conference", "variant": "conference", "time": "BMO" },
{ "title": "TSLA Conference", "variant": "conference", "time": "AMC" },
{ "title": "WMT Conference", "variant": "conference", "time": "BMO" },
{ "title": "WMT Conference", "variant": "conference", "time": "AMC" },
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
{ "title": "JPM Conference", "variant": "conference", "time": "BMO" },
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "BABA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "BABA Event", "variant": "event", "time": "BMO" },
{ "title": "JPM Event", "variant": "event", "time": "BMO" },
],
},
{
"date": "2023-06-23T08:00:00.000Z",
"events": [
{ "title": "AAPL Event", "variant": "event", "time": "BMO" },
{ "title": "GOOGL Event", "variant": "event", "time": "AMC" },
{ "title": "TSLA Conference", "variant": "conference", "time": "BMO" },
{ "title": "NVDA Split", "variant": "split", "time": "BMO" },
{ "title": "TSLA Split", "variant": "split", "time": "AMC" },
{ "title": "AMZN Event", "variant": "event", "time": "AMC" },
{ "title": "AAPL Event", "variant": "event", "time": "BMO" },
{ "title": "MSFT Conference", "variant": "conference", "time": "AMC" },
{ "title": "NVDA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "AMZN Event", "variant": "event", "time": "AMC" },
],
},
{
"date": "2023-06-26T08:00:00.000Z",
"events": [
{ "title": "JPM Conference", "variant": "conference", "time": "BMO" },
{ "title": "TSLA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "GOOGL Split", "variant": "split", "time": "BMO" },
{ "title": "NVDA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "NVDA Split", "variant": "split", "time": "AMC" },
{ "title": "TSLA Conference", "variant": "conference", "time": "AMC" },
{ "title": "NVDA Split", "variant": "split", "time": "AMC" },
{ "title": "GOOGL Dividend", "variant": "dividend", "time": "BMO" },
],
},
{
"date": "2023-06-27T08:00:00.000Z",
"events": [
{ "title": "BABA Split", "variant": "split", "time": "AMC" },
{ "title": "GOOGL Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "META Conference", "variant": "conference", "time": "AMC" },
{ "title": "META Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "GOOGL Event", "variant": "event", "time": "AMC" },
{ "title": "GOOGL Conference", "variant": "conference", "time": "AMC" },
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
{ "title": "BABA Earnings", "variant": "earnings", "time": "AMC" },
],
},
{
"date": "2023-06-28T08:00:00.000Z",
"events": [
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "JPM Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AMZN Conference", "variant": "conference", "time": "BMO" },
{ "title": "MSFT Conference", "variant": "conference", "time": "AMC" },
{ "title": "AAPL Event", "variant": "event", "time": "AMC" },
{ "title": "META Split", "variant": "split", "time": "AMC" },
{ "title": "JPM Earnings", "variant": "earnings", "time": "BMO" },
],
},
{
"date": "2023-06-29T08:00:00.000Z",
"events": [{ "title": "BABA Event", "variant": "event", "time": "BMO" }],
},
{
"date": "2023-06-30T08:00:00.000Z",
"events": [
{ "title": "AAPL Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AAPL Split", "variant": "split", "time": "BMO" },
{ "title": "META Conference", "variant": "conference", "time": "AMC" },
{ "title": "TSLA Event", "variant": "event", "time": "BMO" },
{ "title": "META Event", "variant": "event", "time": "AMC" },
],
},
{
"date": "2023-07-03T08:00:00.000Z",
"events": [
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "MSFT Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "TSLA Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "MSFT Dividend", "variant": "dividend", "time": "BMO" },
],
},
{
"date": "2023-07-04T08:00:00.000Z",
"events": [
{ "title": "BABA Split", "variant": "split", "time": "AMC" },
{ "title": "AAPL Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "AAPL Event", "variant": "event", "time": "AMC" },
{ "title": "JPM Event", "variant": "event", "time": "BMO" },
{ "title": "TSLA Event", "variant": "event", "time": "BMO" },
{ "title": "AAPL Earnings", "variant": "earnings", "time": "BMO" },
],
},
{
"date": "2023-07-05T08:00:00.000Z",
"events": [
{ "title": "NVDA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "NVDA Dividend", "variant": "dividend", "time": "AMC" },
],
},
{
"date": "2023-07-06T08:00:00.000Z",
"events": [
{ "title": "NVDA Conference", "variant": "conference", "time": "AMC" },
{ "title": "BABA Split", "variant": "split", "time": "BMO" },
{ "title": "MSFT Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "WMT Event", "variant": "event", "time": "BMO" },
{ "title": "MSFT Split", "variant": "split", "time": "AMC" },
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
],
},
{
"date": "2023-07-07T08:00:00.000Z",
"events": [
{ "title": "JPM Event", "variant": "event", "time": "AMC" },
{ "title": "TSLA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "TSLA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "NVDA Split", "variant": "split", "time": "AMC" },
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "TSLA Conference", "variant": "conference", "time": "BMO" },
],
},
{
"date": "2023-07-10T08:00:00.000Z",
"events": [
{ "title": "AMZN Split", "variant": "split", "time": "BMO" },
{ "title": "NVDA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "AMC" },
],
},
{
"date": "2023-07-11T08:00:00.000Z",
"events": [
{ "title": "TSLA Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AMZN Event", "variant": "event", "time": "BMO" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "BMO" },
{ "title": "WMT Conference", "variant": "conference", "time": "AMC" },
{ "title": "JPM Event", "variant": "event", "time": "BMO" },
{ "title": "NVDA Split", "variant": "split", "time": "BMO" },
{ "title": "AMZN Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "AAPL Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "AMZN Split", "variant": "split", "time": "AMC" },
{ "title": "TSLA Earnings", "variant": "earnings", "time": "BMO" },
],
},
{
"date": "2023-07-12T08:00:00.000Z",
"events": [
{ "title": "JPM Event", "variant": "event", "time": "AMC" },
{ "title": "TSLA Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "NVDA Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "TSLA Conference", "variant": "conference", "time": "BMO" },
{ "title": "MSFT Conference", "variant": "conference", "time": "AMC" },
],
},
{
"date": "2023-07-13T08:00:00.000Z",
"events": [
{ "title": "GOOGL Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "JPM Split", "variant": "split", "time": "AMC" },
{ "title": "MSFT Split", "variant": "split", "time": "BMO" },
{ "title": "AMZN Conference", "variant": "conference", "time": "AMC" },
{ "title": "NVDA Conference", "variant": "conference", "time": "AMC" },
{ "title": "JPM Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "MSFT Dividend", "variant": "dividend", "time": "BMO" },
],
},
{
"date": "2023-07-14T08:00:00.000Z",
"events": [
{ "title": "TSLA Split", "variant": "split", "time": "AMC" },
{ "title": "BABA Split", "variant": "split", "time": "AMC" },
{ "title": "AMZN Earnings", "variant": "earnings", "time": "BMO" },
],
},
{
"date": "2023-07-17T08:00:00.000Z",
"events": [
{ "title": "BABA Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "MSFT Conference", "variant": "conference", "time": "AMC" },
{ "title": "MSFT Earnings", "variant": "earnings", "time": "BMO" },
{ "title": "NVDA Event", "variant": "event", "time": "BMO" },
{ "title": "BABA Split", "variant": "split", "time": "AMC" },
{ "title": "AAPL Dividend", "variant": "dividend", "time": "BMO" },
],
},
{
"date": "2023-07-18T08:00:00.000Z",
"events": [
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
{ "title": "AAPL Event", "variant": "event", "time": "BMO" },
],
},
{
"date": "2023-07-19T08:00:00.000Z",
"events": [
{ "title": "META Dividend", "variant": "dividend", "time": "AMC" },
{ "title": "GOOGL Conference", "variant": "conference", "time": "BMO" },
{ "title": "WMT Split", "variant": "split", "time": "BMO" },
{ "title": "MSFT Event", "variant": "event", "time": "BMO" },
{ "title": "AMZN Dividend", "variant": "dividend", "time": "BMO" },
],
},
{
"date": "2023-07-20T08:00:00.000Z",
"events": [
{ "title": "GOOGL Event", "variant": "event", "time": "BMO" },
{ "title": "BABA Conference", "variant": "conference", "time": "AMC" },
{ "title": "META Earnings", "variant": "earnings", "time": "AMC" },
{ "title": "TSLA Event", "variant": "event", "time": "BMO" },
{ "title": "WMT Split", "variant": "split", "time": "BMO" },
{ "title": "AAPL Earnings", "variant": "earnings", "time": "BMO" },
],
},
{
"date": "2023-07-21T08:00:00.000Z",
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
},
{
"date": "2023-07-22T08:00:00.000Z",
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
},
{
"date": "2023-07-23T08:00:00.000Z",
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
},
{
"date": "2023-07-24T08:00:00.000Z",
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
},
{
"date": "2023-07-25T08:00:00.000Z",
"events": [{ "title": "BABA Split", "variant": "split", "time": "AMC" }],
},
{
"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" }],
},
];
return (
<div className="w-full h-full border border-neutral-700 rounded-lg bg-card">
<div className="grid grid-cols-7 grid-rows-6 h-full">
{dates.map((item, index) => (
<div key={index} className="border border-neutral-700 flex flex-col">
<p className="font-bold p-2">
{format(item.date, "d", { timeZone: "America/New_York" })}
</p>
<div className="grid grid-rows-5 overflow-hidden gap-1 p-1">
{item.events.length < 5
? item.events.map((event: any, eventkey: number) => (
<CalendarItem
time={event.time}
variant={event.variant}
title={event.title}
key={eventkey}
/>
))
: [
...item.events
.slice(0, 4)
.map((event: any, eventkey: number) => (
<CalendarItem
time={event.time}
variant={event.variant}
title={event.title}
key={eventkey}
/>
)),
<CalendarItem
title={`+ ${item.events.length - 4} more`}
key="end"
/>,
]}
</div>
</div>
))}
</div>
</div>
);
};
export default Calendar;
+41
View File
@@ -0,0 +1,41 @@
import { cn } from "@/lib/utils";
import { VariantProps, cva } from "class-variance-authority";
import React from "react";
const CalenderItemVariants = cva(
"border border-neutral-700 rounded-full cursor-pointer bg-opacity-50 hover:bg-opacity-70 px-1",
{
variants: {
variant: {
default: "bg-neutral-700",
conference: "bg-yellow-300 border-yellow-300 ",
dividend: "bg-blue-500 border-blue-500",
earnings: "bg-green-500 border-green-500",
event: "bg-violet-500 border-violet-500",
split: "bg-pink-500 border-pink-500",
},
},
defaultVariants: {
variant: "default",
},
}
);
interface CalendarItemProps extends VariantProps<typeof CalenderItemVariants> {
// type: "conference" | "dividend" | "earnings" | "event" | "split";
title: string;
time?: "AMC" | "BMO";
}
const CalendarItem = ({ variant, title, time }: CalendarItemProps) => {
return (
<div className={cn(CalenderItemVariants({ variant }))}>
<div className="flex justify-between p-1 text-xs">
<p>{title}</p>
<p>{time}</p>
</div>
</div>
);
};
export default CalendarItem;
View File
+79
View File
@@ -0,0 +1,79 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
className
)}
{...props}
/>
))
Card.displayName = "Card"
const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
))
CardHeader.displayName = "CardHeader"
const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
"text-2xl font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"
const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
CardDescription.displayName = "CardDescription"
const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
))
CardContent.displayName = "CardContent"
const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
))
CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }