flexbox update

This commit is contained in:
2024-02-29 20:25:41 -05:00
parent e8a8c64e39
commit 18f95460a2
9 changed files with 165 additions and 16 deletions
+1 -1
View File
@@ -689,7 +689,7 @@ export type newsDataType = {
outletLogo: string;
};
export const newsData = [
export const newsData: newsDataType[] = [
{
"headline": "Tesla reports 0-60 under 1s available in latest Roadster",
"subtitle":
+34 -4
View File
@@ -1,9 +1,39 @@
import { PortfolioModule } from "@/components/modules/HomepageModules";
"use client";
export default function Page() {
import { ResponsiveTreeMap } from "@nivo/treemap";
import { heatmapData as data } from "../MockData/MockData";
export default function page() {
return (
<div>
<PortfolioModule />
<div className="flex h-96 w-[500px] rounded-md">
<div className="flex flex-col flex-grow bg-neutral-800 rounded-lg">
<div className="flex justify-between px-2 py-2 pb-0">
<div className="flex items-center text-lg px-2">Heatmap</div>
</div>
<div className="flex-grow w-full">
<ResponsiveTreeMap
data={data}
identity="name"
value="loc"
valueFormat=".02s"
tile="binary"
// margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
labelSkipSize={30}
labelTextColor="black"
parentLabelPosition="left"
parentLabelTextColor={{
from: "color",
modifiers: [["darker", 2]],
}}
colors={{ scheme: "red_yellow_green" }}
borderColor={{
from: "color",
modifiers: [["brighter", 0.1]],
}}
motionConfig="wobbly"
/>
</div>
</div>
</div>
);
}
-7
View File
@@ -1,7 +0,0 @@
import React from "react";
const NewsTable = () => {
return <div>NewsTable</div>;
};
export default NewsTable;
+80
View File
@@ -0,0 +1,80 @@
"use client";
import {
ColumnDef,
flexRender,
getCoreRowModel,
useReactTable,
} from "@tanstack/react-table";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
interface NewsTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
}
export function NewsTable<TData, TValue>({
columns,
data,
}: NewsTableProps<TData, TValue>) {
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
});
return (
<div className="rounded-md border">
<Table>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<TableHead key={header.id}>
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext()
)}
</TableHead>
);
})}
</TableRow>
))}
</TableHeader>
<TableBody>
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && "selected"}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={columns.length} className="h-24 text-center">
No results.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
);
}
@@ -0,0 +1,19 @@
"use client";
import { ColumnDef } from "@tanstack/react-table";
import { newsDataType } from "@/app/MockData/MockData";
export const newsColumns: ColumnDef<newsDataType>[] = [
{
accessorKey: "headline",
header: "Headline",
},
{
accessorKey: "dateTime",
header: "Time",
},
{
accessorKey: "outlet",
header: "Outlet",
},
];
@@ -9,11 +9,11 @@ interface HomepageModuleProps {
const HomepageModule = ({ title, children }: HomepageModuleProps) => {
return (
<div className="h-full bg-neutral-800 rounded-lg">
<div className="flex flex-col h-full bg-neutral-800 rounded-lg">
<div className="flex justify-between px-2 py-2 pb-0">
<div className="flex items-center text-lg px-2">{title}</div>
</div>
<div className="h-3/4 w-full">{children}</div>
<div className="flex-grow w-full overflow-hidden">{children}</div>
</div>
);
};
+8 -2
View File
@@ -1,9 +1,11 @@
import { heatmapData, portfolioData } from "@/app/MockData/MockData";
import { heatmapData, newsData, portfolioData } from "@/app/MockData/MockData";
import HomepageModule from "./HomepageModuleCard";
import PortfolioChart from "../charts/PortfolioChart";
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";
export const PortfolioModule = () => {
return (
@@ -25,7 +27,11 @@ export const PortfolioModule = () => {
};
export const NewsModule = () => {
return <HomepageModule title="News"></HomepageModule>;
return (
<HomepageModule title="News">
<NewsTable columns={newsColumns} data={newsData} />
</HomepageModule>
);
};
export const HeatmapModule = () => {