mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 01:07:01 +00:00
added db calls to today, wrapped text and adjust height as needed for small calendar items
This commit is contained in:
@@ -15,6 +15,8 @@ export const metadata: Metadata = {
|
||||
title: "Calendar",
|
||||
};
|
||||
|
||||
export const revalidate = 900;
|
||||
|
||||
const page = async () => {
|
||||
const startDate = startOfWeek(startOfMonth(new Date("2024-06-19")));
|
||||
const endDate = addDays(startDate, 41);
|
||||
@@ -59,7 +61,7 @@ const page = async () => {
|
||||
<div className="w-full h-full flex gap-4">
|
||||
{/* <MonthCalendar events={getEventArray} /> */}
|
||||
<Calendar events={events} />
|
||||
<Day />
|
||||
<Day events={events} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -59,6 +59,10 @@ const Calendar = ({ events }: CalendarProps) => {
|
||||
setMonthYear(format(newMonth, "MMMM yyyy"));
|
||||
};
|
||||
|
||||
const toToday = () => {
|
||||
setMonthYear(format(new Date(), "MMMM yyyy"));
|
||||
};
|
||||
|
||||
return (
|
||||
<Tabs className="w-full h-full overflow-hidden" defaultValue="month">
|
||||
<Card className="flex flex-col">
|
||||
@@ -90,17 +94,19 @@ const Calendar = ({ events }: CalendarProps) => {
|
||||
<CardTitle className="text-xl">{monthYear}</CardTitle>
|
||||
</div>
|
||||
<div className="flex gap-1 place-self-end">
|
||||
<Button variant="secondary" className="px-2">
|
||||
<ArrowLeftIcon
|
||||
className="text-muted-foreground"
|
||||
onClick={prevMonth}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="px-4"
|
||||
onClick={toToday}
|
||||
disabled={monthYear == format(today, "MMMM yyyy")}
|
||||
>
|
||||
Today
|
||||
</Button>
|
||||
<Button variant="secondary" className="px-2">
|
||||
<ArrowRightIcon
|
||||
className="text-muted-foreground"
|
||||
onClick={nextMonth}
|
||||
/>
|
||||
<Button variant="secondary" className="px-2" onClick={prevMonth}>
|
||||
<ArrowLeftIcon className="text-muted-foreground" />
|
||||
</Button>
|
||||
<Button variant="secondary" className="px-2" onClick={nextMonth}>
|
||||
<ArrowRightIcon className="text-muted-foreground" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,11 +3,11 @@ import { VariantProps, cva } from "class-variance-authority";
|
||||
import React from "react";
|
||||
|
||||
const CalenderItemVariants = cva(
|
||||
"rounded-sm cursor-pointer bg-opacity-15 hover:bg-opacity-40",
|
||||
"rounded-sm cursor-pointer bg-opacity-15 hover:bg-opacity-40 w-full",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-neutral-700",
|
||||
default: "bg-background",
|
||||
conference: "bg-yellow-300 text-yellow-300",
|
||||
dividend: "bg-blue-500 text-blue-500",
|
||||
earnings: "bg-green-500 text-green-500",
|
||||
@@ -43,7 +43,7 @@ const CalendarItem = ({
|
||||
<div className={cn(CalenderItemVariants({ variant, size }))}>
|
||||
<div
|
||||
className={cn(
|
||||
size == "sm" ? "text-xs h-6" : "",
|
||||
size == "sm" ? "text-xs" : "",
|
||||
"flex justify-between p-1 font-bold"
|
||||
)}
|
||||
>
|
||||
@@ -58,7 +58,7 @@ const CalendarItem = ({
|
||||
className={cn(size == "lg" && "flex flex-col px-1 gap-2", "w-full")}
|
||||
>
|
||||
<div className="flex gap-1 justify-between px-1 w-full">
|
||||
<p>{title}</p>
|
||||
<p className="text-wrap">{title}</p>
|
||||
<p className={cn(size == "sm" ? "hidden xl:block" : "", "")}>
|
||||
{time}
|
||||
</p>
|
||||
|
||||
@@ -7,13 +7,22 @@ import {
|
||||
CardTitle,
|
||||
} from "../ui/card";
|
||||
import CalendarItem from "./CalendarItem";
|
||||
import EventList from "./EventList";
|
||||
import { Event } from "@/db/db_calls";
|
||||
import { format } from "date-fns";
|
||||
|
||||
interface DayProps {
|
||||
events: Event[];
|
||||
}
|
||||
|
||||
const Day = ({ events }: DayProps) => {
|
||||
const today = new Date();
|
||||
|
||||
const Day = () => {
|
||||
return (
|
||||
<Card className="w-1/3 h-full">
|
||||
<CardHeader className="p-4">
|
||||
<CardTitle>Today</CardTitle>
|
||||
<CardDescription>June 12, 2024</CardDescription>
|
||||
<CardDescription>{format(today, "MMMM dd, yyyy")}</CardDescription>
|
||||
</CardHeader>
|
||||
<hr className="border-neutral-700" />
|
||||
<CardContent className="p-0 pt-4">
|
||||
@@ -24,30 +33,12 @@ const Day = () => {
|
||||
<hr className="border-neutral-500" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-2 flex flex-col gap-1">
|
||||
<CalendarItem
|
||||
title="NVDA Earnings"
|
||||
variant="earnings"
|
||||
<EventList
|
||||
date={today}
|
||||
events={events}
|
||||
monthYear={"June 2024"}
|
||||
size="lg"
|
||||
time="BMO"
|
||||
description="Nvidia is reporting earnings after a boom in AI. Nvidia has emerged as a major player driving advancements in artificial intelligence. The company's high-performance graphics processing units (GPUs) have become the workhorses powering many of the latest AI models and applications. In 2023, Nvidia doubled down on AI with the launch of its Hopper architecture - a new chip design optimized for transformer-based language models like GPT-3. They also introduced new AI software tools and services through their Nvidia AI platform. This includes pre-trained models, development frameworks, and cloud services for enterprises looking to deploy large language models and computer vision AI. Additionally, Nvidia has been at the forefront of accelerating AI computing through innovations like their Grace CPU designed for AI/ML workloads. As generative AI goes mainstream, Nvidia's chips and software are becoming critical infrastructure enabling everything from content creation to drug discovery using advanced machine learning techniques."
|
||||
/>
|
||||
<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 has been ramping up its artificial intelligence efforts in recent years. At its Worldwide Developers Conference (WWDC) in June 2023, the company unveiled several new AI-powered features across its software platforms. This includes an enhanced Siri assistant with improved language understanding and multitasking capabilities. Apple also introduced Visioneer, a new AI model for advanced computer vision tasks like image analysis and video processing. Additionally, the company has been working on implementing generative AI models into its productivity apps like Pages and Keynote to assist with content creation. While Apple has historically been more cautious about adopting cutting-edge AI compared to rivals, these latest moves signal their intent to double down on machine learning and AI across their product ecosystem.
|
||||
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -8,15 +8,18 @@ interface EventListProps {
|
||||
date: Date;
|
||||
events: Event[];
|
||||
monthYear: string;
|
||||
size: "sm" | "lg";
|
||||
}
|
||||
|
||||
const EventList = ({ date, events, monthYear }: EventListProps) => {
|
||||
const EventList = ({ date, events, monthYear, size }: EventListProps) => {
|
||||
const eventsForDate = events.filter((event) =>
|
||||
isSameDay(event.datetime, date)
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="grid grid-rows-4 overflow-hidden gap-1 p-1 px-2">
|
||||
<div>
|
||||
{size === "sm" ? (
|
||||
<div className="flex flex-col gap-1 p-1 px-2">
|
||||
{eventsForDate.length < 4
|
||||
? eventsForDate.map((event, eventkey: number) => (
|
||||
<CalendarItem
|
||||
@@ -57,6 +60,23 @@ const EventList = ({ date, events, monthYear }: EventListProps) => {
|
||||
/>,
|
||||
]}
|
||||
</div>
|
||||
) : (
|
||||
<div className="p-2 flex flex-col gap-1">
|
||||
{eventsForDate.map((event, eventkey: number) => (
|
||||
<CalendarItem
|
||||
time={format(event.datetime, "p", {
|
||||
timeZone: "America/New_York",
|
||||
})}
|
||||
title={event.title}
|
||||
key={eventkey}
|
||||
variant={event.variant}
|
||||
size="lg"
|
||||
description={event.description != null ? event.description : ""}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,12 @@ const Month = ({ monthYear, events }: MonthProps) => {
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<EventList date={item} events={events} monthYear={monthYear} />
|
||||
<EventList
|
||||
date={item}
|
||||
events={events}
|
||||
monthYear={monthYear}
|
||||
size="sm"
|
||||
/>
|
||||
{/* <div className="grid grid-rows-4 overflow-hidden gap-1 p-1 px-2">
|
||||
{item.events.length < 4
|
||||
? item.events.map((event: any, eventkey: number) => (
|
||||
|
||||
+2
-2
@@ -78,8 +78,8 @@ export const getEvents = cache(async (startDate: Date, endDate: Date) => {
|
||||
return eventArray;
|
||||
});
|
||||
|
||||
export const getAllEvents = async () => {
|
||||
export const getAllEvents = cache(async () => {
|
||||
const allEvents: Event[] = await db.select().from(EventsTable);
|
||||
|
||||
return allEvents;
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user