mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
Refactor Invest page UI components, add responsive support for graph type selection
This commit is contained in:
parent
a578bafac6
commit
c0d7a4b886
@ -1,4 +1,4 @@
|
|||||||
import { Metadata } from "next";
|
"use client";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@ -10,13 +10,10 @@ import {
|
|||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Overview } from "@/components/ui/overview";
|
import { Overview } from "@/components/ui/overview";
|
||||||
import { RecentSales } from "@/components/recent-sales";
|
import { RecentSales } from "@/components/recent-sales";
|
||||||
|
import { useState } from "react";
|
||||||
export const metadata: Metadata = {
|
|
||||||
title: "Dashboard",
|
|
||||||
description: "Example dashboard app built using the components.",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
const [graphType, setGraphType] = useState("line");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="md:hidden">
|
<div className="md:hidden">
|
||||||
@ -163,7 +160,24 @@ export default function Dashboard() {
|
|||||||
<CardTitle>Overview</CardTitle>
|
<CardTitle>Overview</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pl-2">
|
<CardContent className="pl-2">
|
||||||
<Overview />
|
<Overview graphType={graphType} />
|
||||||
|
{/* tab to switch between line and bar graph */}
|
||||||
|
<Tabs defaultValue="line" className="space-y-4 ml-[50%]">
|
||||||
|
<TabsList>
|
||||||
|
<TabsTrigger
|
||||||
|
value="line"
|
||||||
|
onClick={() => setGraphType("line")}
|
||||||
|
>
|
||||||
|
Line
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger
|
||||||
|
value="bar"
|
||||||
|
onClick={() => setGraphType("bar")}
|
||||||
|
>
|
||||||
|
Bar
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
</Tabs>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="col-span-3">
|
<Card className="col-span-3">
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from "recharts";
|
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis, LineChart, Line } from "recharts";
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
@ -53,9 +53,36 @@ const data = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function Overview() {
|
interface OverViewProps{
|
||||||
|
graphType:string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Overview(props: OverViewProps) {
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" height={350}>
|
<ResponsiveContainer width="100%" height={350}>
|
||||||
|
{props.graphType === 'line' ? (
|
||||||
|
<LineChart data={data}>
|
||||||
|
<XAxis
|
||||||
|
dataKey="name"
|
||||||
|
stroke="#888888"
|
||||||
|
fontSize={12}
|
||||||
|
tickLine={false}
|
||||||
|
axisLine={false}
|
||||||
|
/>
|
||||||
|
<YAxis
|
||||||
|
stroke="#888888"
|
||||||
|
fontSize={12}
|
||||||
|
tickLine={false}
|
||||||
|
axisLine={false}
|
||||||
|
tickFormatter={(value) => `$${value}`}
|
||||||
|
/>
|
||||||
|
<Line
|
||||||
|
dataKey="total"
|
||||||
|
fill="currentColor"
|
||||||
|
className="fill-primary"
|
||||||
|
/>
|
||||||
|
</LineChart>
|
||||||
|
) : (
|
||||||
<BarChart data={data}>
|
<BarChart data={data}>
|
||||||
<XAxis
|
<XAxis
|
||||||
dataKey="name"
|
dataKey="name"
|
||||||
@ -74,10 +101,10 @@ export function Overview() {
|
|||||||
<Bar
|
<Bar
|
||||||
dataKey="total"
|
dataKey="total"
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
radius={[4, 4, 0, 0]}
|
|
||||||
className="fill-primary"
|
className="fill-primary"
|
||||||
/>
|
/>
|
||||||
</BarChart>
|
</BarChart>
|
||||||
|
)}
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user