mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 01:07:01 +00:00
i dont even remember tbh, some calendar thing i think
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import React from "react";
|
||||
import { ResponsiveTimeRange } from "@nivo/calendar";
|
||||
|
||||
const CalendarSquares = ({ data }: any) => {
|
||||
const fromDate = new Date();
|
||||
const toDate = fromDate.getDate() + 30;
|
||||
|
||||
return (
|
||||
<ResponsiveTimeRange
|
||||
data={data}
|
||||
// from={fromDate.toLocaleString("en-us")}
|
||||
// to={toDate.toLocaleDateString("en-us")}
|
||||
from="2024-03-07"
|
||||
to="2024-04-11"
|
||||
emptyColor="#171717"
|
||||
colors={["#61cdbb", "#97e3d5", "#e8c1a0", "#f47560"]}
|
||||
margin={{ top: -70 }}
|
||||
direction="vertical"
|
||||
square={false}
|
||||
firstWeekday="thursday"
|
||||
weekdayTicks={[]}
|
||||
tooltip={undefined}
|
||||
// monthLegendOffset={0}
|
||||
weekdayLegendOffset={0}
|
||||
dayBorderWidth={1}
|
||||
dayBorderColor="#ffffff"
|
||||
// legends={[
|
||||
// {
|
||||
// anchor: "bottom-right",
|
||||
// direction: "row",
|
||||
// justify: false,
|
||||
// itemCount: 4,
|
||||
// itemWidth: 42,
|
||||
// itemHeight: 36,
|
||||
// itemsSpacing: 14,
|
||||
// itemDirection: "right-to-left",
|
||||
// translateX: -60,
|
||||
// translateY: -60,
|
||||
// symbolSize: 20,
|
||||
// },
|
||||
// ]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default CalendarSquares;
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
winnerMovers,
|
||||
loserMovers,
|
||||
markets,
|
||||
earningsCalendar,
|
||||
} from "@/app/MockData/MockData";
|
||||
import HomepageModule from "./HomepageModuleCard";
|
||||
import PortfolioChart, {
|
||||
@@ -24,11 +25,22 @@ import {
|
||||
LineType,
|
||||
WhitespaceData,
|
||||
} from "lightweight-charts";
|
||||
import { globalColors, smaFunc } from "@/lib/utils";
|
||||
import {
|
||||
cn,
|
||||
getIntervalPrice,
|
||||
getLastPrice,
|
||||
getPercentDifference,
|
||||
getPriceDifference,
|
||||
globalColors,
|
||||
smaFunc,
|
||||
} from "@/lib/utils";
|
||||
import { seriesOne } from "@/app/MockData/seriesOne";
|
||||
import { seriesThree } from "@/app/MockData/seriesThree";
|
||||
import { seriesFive } from "@/app/MockData/seriesFive";
|
||||
import { useState } from "react";
|
||||
import { Badge } from "../ui/badge";
|
||||
import { ResponsiveTimeRange } from "@nivo/calendar";
|
||||
import CalendarSquares from "../charts/CalendarSquares";
|
||||
|
||||
export const PortfolioModule = () => {
|
||||
const portfolioLine: LineSeriesPartialOptionsWithData = {
|
||||
@@ -135,11 +147,16 @@ export const MoversModule = () => {
|
||||
};
|
||||
|
||||
export const MarketsModule = () => {
|
||||
const [selectedMarket, setSelectedMarket] = useState("S&P 500");
|
||||
const [selectedMarket, setSelectedMarket] = useState({
|
||||
symbol: "S&P 500",
|
||||
symbolName: "SPDR S&P 500 ETF Trust",
|
||||
symbolUrl: "https://...",
|
||||
chart: seriesOne,
|
||||
});
|
||||
|
||||
const sp500IndexLine: LineSeriesPartialOptionsWithData = {
|
||||
type: "line",
|
||||
data: seriesOne,
|
||||
data: selectedMarket.chart,
|
||||
color: "white",
|
||||
lineType: LineType.Curved,
|
||||
priceLineVisible: false,
|
||||
@@ -147,61 +164,53 @@ export const MarketsModule = () => {
|
||||
|
||||
const sma5Line: LineSeriesPartialOptionsWithData = {
|
||||
type: "line",
|
||||
data: smaFunc(seriesOne, 20),
|
||||
data: smaFunc(selectedMarket.chart, 20),
|
||||
color: globalColors.yellow,
|
||||
lineType: LineType.Curved,
|
||||
priceLineVisible: false,
|
||||
};
|
||||
|
||||
// const getPrice = (data: LineData[], dataPoint: number) => {
|
||||
// const price = data.at(dataPoint)?.value as number;
|
||||
|
||||
// return price;
|
||||
// };
|
||||
|
||||
// const getPriceDifference = (data: LineData[], interval: number) => {
|
||||
// const lastPrice = getPrice(data, -1) as number;
|
||||
// const intervalPrice = getPrice(data, -(interval + 1)) as number;
|
||||
|
||||
// const priceDifference = (lastPrice - intervalPrice).toFixed(2);
|
||||
|
||||
// return priceDifference;
|
||||
// };
|
||||
|
||||
// const getPercentDifference = (data: LineData[], interval: number) => {
|
||||
// const priceDifference = getPriceDifference(data, interval);
|
||||
// const intervalPrice = getPrice(data, interval);
|
||||
|
||||
// const percentDifference = (
|
||||
// (parseFloat(priceDifference) / intervalPrice) *
|
||||
// 100
|
||||
// ).toFixed(2);
|
||||
|
||||
// return percentDifference;
|
||||
// };
|
||||
|
||||
return (
|
||||
<HomepageModule title="Markets">
|
||||
<div className="flex h-full">
|
||||
<div className="w-2/5 p-4 pt-3">
|
||||
<div className="flex h-full items-center py-4">
|
||||
<div className="flex flex-col justify-between w-2/5 h-full px-2">
|
||||
{markets.map((marketItem) => (
|
||||
<div
|
||||
key={marketItem.symbol}
|
||||
className="py-[5px] my-1 rounded-lg hover:bg-neutral-700"
|
||||
className="rounded-lg hover:bg-neutral-700 hover:cursor-pointer"
|
||||
>
|
||||
<div className="flex items-center justify-between pl-2 border-b border-neutral-700">
|
||||
{marketItem.symbol}
|
||||
<div className="flex justify-between space-x-6 text-sm pr-2">
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div className="flex items-center pl-2 py-1 justify-between border-b border-neutral-700">
|
||||
<div className="font-semibold">{marketItem.symbol}</div>
|
||||
<div className="flex justify-between space-x-4 text-sm pr-2">
|
||||
<div className="w-12 text-right">
|
||||
{getLastPrice(marketItem.chart)}
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
getPriceDifference(marketItem.chart, 1) > 0
|
||||
? "text-green-500"
|
||||
: "text-red-500",
|
||||
"w-12 text-right"
|
||||
)}
|
||||
>
|
||||
{getPriceDifference(marketItem.chart, 1)}
|
||||
</div>
|
||||
<Badge
|
||||
variant={
|
||||
getPercentDifference(marketItem.chart, 1) > 0
|
||||
? "positive"
|
||||
: "negative"
|
||||
}
|
||||
>
|
||||
<div>{getPercentDifference(marketItem.chart, 1) + "%"}</div>
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="h-full w-3/5 relative">
|
||||
<div className="absolute ml-4">S&P 500</div>
|
||||
<div className="absolute ml-4 mt-1">S&P 500</div>
|
||||
<Chart
|
||||
series={[sp500IndexLine, sma5Line]}
|
||||
colors={{
|
||||
@@ -226,7 +235,11 @@ export const MarketsModule = () => {
|
||||
};
|
||||
|
||||
export const EarningsModule = () => {
|
||||
return <HomepageModule title="Earnings"></HomepageModule>;
|
||||
return (
|
||||
<HomepageModule title="Earnings">
|
||||
<CalendarSquares data={earningsCalendar} />
|
||||
</HomepageModule>
|
||||
);
|
||||
};
|
||||
|
||||
export const DocumentsModule = () => {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as React from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
||||
secondary:
|
||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
destructive:
|
||||
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
||||
outline: "text-foreground",
|
||||
positive: "border-transparent bg-green-600 w-14 rounded-md",
|
||||
negative: "border-transparent bg-red-600 w-14 rounded-md",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export interface BadgeProps
|
||||
extends React.HTMLAttributes<HTMLDivElement>,
|
||||
VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||
return (
|
||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants };
|
||||
Reference in New Issue
Block a user