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:
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user