mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 01:07:01 +00:00
258 lines
6.9 KiB
TypeScript
258 lines
6.9 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
heatmapData,
|
|
newsData,
|
|
winnerMovers,
|
|
loserMovers,
|
|
markets,
|
|
earningsCalendar,
|
|
} from "@/app/MockData/MockData";
|
|
import HomepageModule from "./HomepageModuleCard";
|
|
import PortfolioChart, {
|
|
AreaSeriesPartialOptionsWithData,
|
|
LineSeriesPartialOptionsWithData,
|
|
} from "../charts/Chart";
|
|
import MarketHeatmap from "../charts/MarketHeatmap";
|
|
import { Button } from "../ui/button";
|
|
import { ArrowRight } from "lucide-react";
|
|
import { NewsTable } from "../charts/news/NewsTable";
|
|
import { newsColumns } from "../charts/news/newsColumns";
|
|
import Chart from "../charts/Chart";
|
|
import {
|
|
LineData,
|
|
LineStyle,
|
|
LineType,
|
|
WhitespaceData,
|
|
} from "lightweight-charts";
|
|
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 = {
|
|
type: "line",
|
|
data: seriesThree,
|
|
color: "white",
|
|
lineType: LineType.Curved,
|
|
};
|
|
|
|
const indexLine: LineSeriesPartialOptionsWithData = {
|
|
type: "line",
|
|
data: seriesFive,
|
|
color: globalColors.yellow,
|
|
lineType: LineType.Curved,
|
|
};
|
|
|
|
return (
|
|
<HomepageModule title="Portfolio">
|
|
<div className="flex justify-between px-4">
|
|
<div>$34,120.87</div>
|
|
<div className="rounded-full bg-neutral-900 px-4">2W 1M YTD</div>
|
|
<div className="text-green-500">^10.0% $3,412.09</div>
|
|
</div>
|
|
<div className="h-3/4">
|
|
<Chart
|
|
series={[portfolioLine, indexLine]}
|
|
colors={{
|
|
backgroundColor: "transparent",
|
|
textColor: "white",
|
|
}}
|
|
/>
|
|
</div>
|
|
<div className="flex justify-between">
|
|
<Button className="text-white" variant="link">
|
|
Go to Portfolio
|
|
<ArrowRight className="ml-1" size={16} />
|
|
</Button>
|
|
</div>
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const NewsModule = () => {
|
|
return (
|
|
<HomepageModule title="News">
|
|
<NewsTable columns={newsColumns} data={newsData} />
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const HeatmapModule = () => {
|
|
return (
|
|
<HomepageModule title="Heatmap">
|
|
<MarketHeatmap data={heatmapData} />
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const MoversModule = () => {
|
|
return (
|
|
<HomepageModule title="Movers">
|
|
<div className="flex justify-between 2xl:px-2">
|
|
<div className="px-4 mt-4 2xl:mt-6">
|
|
<div className="text-lg">Gainers</div>
|
|
<div className="mt-4 grid grid-cols-2 grid-rows-5 gap-y-4 gap-x-2 2xl:gap-y-6 2xl:gap-x-10">
|
|
{winnerMovers.map((item) => (
|
|
<div
|
|
className="flex border-b border-neutral-400 pb-1 text-sm 2xl:text-base"
|
|
key={item.symbol}
|
|
>
|
|
<div className="w-32 font-bold 2xl:w-24">{item.symbol}</div>
|
|
<div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base">
|
|
{item.stockPrice}
|
|
</div>
|
|
<div className="text-xs ml-2 rounded-lg bg-green-500 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base">
|
|
+{item.percentChange}%
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
<div className="px-4 mt-4 2xl:mt-6">
|
|
<div className="text-lg">Losers</div>
|
|
<div className="mt-4 grid grid-cols-2 grid-rows-5 gap-y-4 gap-x-2 2xl:gap-y-6 2xl:gap-x-10">
|
|
{loserMovers.map((item) => (
|
|
<div
|
|
className="flex border-b border-neutral-400 pb-1 text-sm 2xl:text-base"
|
|
key={item.symbol}
|
|
>
|
|
<div className="w-32 font-bold 2xl:w-24">{item.symbol}</div>
|
|
<div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base">
|
|
{item.stockPrice}
|
|
</div>
|
|
<div className="text-xs ml-2 rounded-lg bg-red-500 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base">
|
|
{item.percentChange}%
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const MarketsModule = () => {
|
|
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: selectedMarket.chart,
|
|
color: "white",
|
|
lineType: LineType.Curved,
|
|
priceLineVisible: false,
|
|
};
|
|
|
|
const sma5Line: LineSeriesPartialOptionsWithData = {
|
|
type: "line",
|
|
data: smaFunc(selectedMarket.chart, 20),
|
|
color: globalColors.yellow,
|
|
lineType: LineType.Curved,
|
|
priceLineVisible: false,
|
|
};
|
|
|
|
return (
|
|
<HomepageModule title="Markets">
|
|
<div className="flex h-full items-center py-2 2xl:py-4">
|
|
<div className="flex flex-col grow max-w-[40%] justify-between h-full px-2">
|
|
{markets.map((marketItem) => (
|
|
<div
|
|
key={marketItem.symbol}
|
|
className="rounded-md hover:bg-neutral-700 hover:cursor-pointer"
|
|
>
|
|
<div className="flex items-center pl-2 py-1 justify-between border-b border-neutral-700">
|
|
<div className="text-sm font-semibold 2xl:text-base">
|
|
{marketItem.symbol}
|
|
</div>
|
|
<div className="flex justify-between space-x-4 text-sm pr-2">
|
|
<div className="text-sm w-12 text-right">
|
|
{getLastPrice(marketItem.chart)}
|
|
</div>
|
|
<div
|
|
className={cn(
|
|
getPriceDifference(marketItem.chart, 1) > 0
|
|
? "text-green-500"
|
|
: "text-red-500",
|
|
"text-sm w-10 text-right 2xl:w-12"
|
|
)}
|
|
>
|
|
{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 grow max-w-[60%] relative">
|
|
<div className="absolute ml-4 mt-1">S&P 500</div>
|
|
<Chart
|
|
series={[sp500IndexLine, sma5Line]}
|
|
colors={{
|
|
backgroundColor: "transparent",
|
|
textColor: "white",
|
|
}}
|
|
options={{
|
|
grid: {
|
|
horzLines: {
|
|
visible: false,
|
|
},
|
|
vertLines: {
|
|
visible: false,
|
|
},
|
|
},
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const EarningsModule = () => {
|
|
return (
|
|
<HomepageModule title="Earnings">
|
|
<CalendarSquares data={earningsCalendar} />
|
|
</HomepageModule>
|
|
);
|
|
};
|
|
|
|
export const DocumentsModule = () => {
|
|
return <HomepageModule title="Documents"></HomepageModule>;
|
|
};
|
|
|
|
export const IndicatorsModule = () => {
|
|
return <HomepageModule title="Indicators"></HomepageModule>;
|
|
};
|
|
|
|
export const ForexAndBondsModule = () => {
|
|
return <HomepageModule title="Forex and Bonds"></HomepageModule>;
|
|
};
|