Skip to content

Commit

Permalink
feat: server home
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanddd committed May 6, 2024
1 parent 13a73e1 commit d5e2cda
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/[server]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Image from "next/image";
import { Button, Typography } from "@mochi-ui/core";
import { PlusLine, VaultSolid } from "@mochi-ui/icons";
import { Highlights } from "@/components/overview/highlights";
import { About } from "@/components/overview/about";
import { BountyTable } from "@/components/overview/bounty-table";

const Overview = () => {
const { abort, getInfo } = useServerInfo();
Expand Down Expand Up @@ -65,7 +67,7 @@ const Overview = () => {
</div>
</div>
</div>
<div className="flex relative flex-col px-40">
<div className="flex relative flex-col px-40 pb-16">
<div className="flex justify-between items-end -mt-[66px]">
<div className="overflow-hidden p-1 bg-[#f4f5f6] rounded-full">
<Image
Expand All @@ -89,12 +91,11 @@ const Overview = () => {
</Button>
</div>
</div>
<div className="flex flex-col pt-6 pb-10">
<div className="flex flex-col py-6">
<Highlights />
</div>
{/* <About /> */}
{/* <InfoGrid /> */}
{/* <BountyTable /> */}
<About />
<BountyTable />
</div>
<div className="mt-auto">
<Footer />
Expand Down
163 changes: 163 additions & 0 deletions components/overview/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { Typography } from "@mochi-ui/core";
import { FireSolid } from "@mochi-ui/icons";
import Color from "color";
import { utils } from "@consolelabs/mochi-formatter";
import { useServerInfo } from "@/store/server-info";

const colors = [
Color("#4C5054"),
Color("#C8A38B"),
Color("#2F6ED1"),
Color("#538E22"),
Color("#D77F31"),
Color("#9198E6"),
Color("#E66C9F"),
Color("#E98405"),
Color("#F5B938"),
Color("#3EBBD6"),
Color("#7F747A"),
];

function Cell({
index = 0,
img,
title,
subtitle,
}: {
index?: number;
title: string;
subtitle: string | number;
img?: React.ReactNode;
}) {
return (
<div className="flex gap-x-4 py-2 px-4">
{img ?? (
<div
style={{ backgroundColor: colors[index].hexa() }}
className="flex justify-center items-center w-8 h-8 rounded-full aspect-square"
>
<FireSolid className="text-white" />
</div>
)}
<div className="flex flex-col">
<Typography level="p6" className="font-medium text-neutral-500">
{title}
</Typography>
<Typography level="p5" className="font-medium">
{subtitle}
</Typography>
</div>
</div>
);
}

export function About() {
const { data } = useServerInfo();

return (
<div className="flex flex-col py-6">
<div className="flex flex-col gap-y-2">
<Typography level="h5" className="font-medium">
{" "}
About
</Typography>
<div className="flex flex-col gap-y-4 font-light">
<Typography>
Dwarves Foundation is a software development firm based in Asia.
Helping tech startups, entrepreneurs build and scale world-class
products since 2013.
</Typography>
<Typography>
Our approach to technologies and people is tailored to each product.
You will always work with team of experts who understand your end
goal and support you all the way to the finish line, no matter where
it is in the product lifecycle.
</Typography>
</div>
</div>
<div className="grid grid-cols-3 auto-rows-auto gap-4 py-8">
<Cell
img={
<div
style={{
background:
"linear-gradient(38deg, rgba(255, 65, 110, 0.20) 25.6%, rgba(3, 0, 142, 0.20) 87.4%)",
}}
className="p-1 w-8 h-8 rounded-full"
>
<img src="/dfg-token.png" alt="" />
</div>
}
title="Token Ticker"
subtitle="$DFG"
/>
<Cell
index={0}
title="Blockchain"
subtitle={data?.overview.about.token.chain ?? ""}
/>
<Cell
index={1}
title="ATH"
subtitle={utils.formatUsdDigit(
data?.overview.about.token.all_time_high ?? 0
)}
/>
<Cell
index={2}
title="Market Cap"
subtitle={utils.formatUsdDigit({
value: data?.overview.about.token.market_cap ?? 0,
shorten: false,
})}
/>
<Cell
index={3}
title="Price"
subtitle={utils.formatUsdDigit(data?.overview.about.token.price ?? 0)}
/>
<Cell
index={4}
title="FDV"
subtitle={utils.formatUsdDigit(
data?.overview.about.token.full_diluted_valuation ?? 0
)}
/>
<Cell
index={5}
title="24 Hour Trading Vol"
subtitle={utils.formatUsdDigit(
data?.overview.about.token.trading_volume_24h ?? 0
)}
/>
<Cell
index={6}
title="Max Supply"
subtitle={data?.overview.about.token.max_supply ?? 0}
/>
<Cell index={7} title="Age" subtitle="9 years" />
<Cell
index={8}
title="Change (H1)"
subtitle={utils.formatPercentDigit(
data?.overview.about.token.change_h1 ?? 0
)}
/>
<Cell
index={9}
title="Change (D1)"
subtitle={utils.formatPercentDigit(
data?.overview.about.token.change_d1 ?? 0
)}
/>
<Cell
index={10}
title="Change (W1)"
subtitle={utils.formatPercentDigit(
data?.overview.about.token.change_w1 ?? 0
)}
/>
</div>
</div>
);
}
105 changes: 105 additions & 0 deletions components/overview/bounty-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { useServerInfo } from "@/store/server-info";
import { Badge, Table, Typography } from "@mochi-ui/core";
import {
BulletsListLine,
CalendarLine,
ChartLine,
GiftLine,
TrophyLine,
TwinkleSolid,
} from "@mochi-ui/icons";
import utc from "dayjs/plugin/utc";
import dayjs from "dayjs";
dayjs.extend(utc);

export function BountyTable() {
const { data } = useServerInfo();

return (
<div className="flex flex-col py-6">
<Typography level="h5" className="font-medium">
Bounty
</Typography>
<div className="py-6">
<Table
columns={[
{
id: "index",
accessorFn: (_, index) => index + 1,
header: () => <BulletsListLine className="w-4 h-4" />,
},
{
accessorKey: "name",
header: () => (
<Typography
level="p6"
className="flex gap-x-2 items-center text-neutral-500"
>
<GiftLine className="w-3 h-3" /> BOUNTY
</Typography>
),
},
{
id: "reward",
cell: ({ row }) => (
<Typography level="p6" className="flex gap-x-2 items-center">
<TwinkleSolid className="w-4 h-4 text-warning-solid" />
{row.original.reward}
</Typography>
),
header: () => (
<Typography
level="p6"
className="flex gap-x-2 items-center text-neutral-500"
>
<TrophyLine />
REWARD
</Typography>
),
},
{
id: "duedate",
accessorFn: (row) =>
dayjs(row.expired).utc(true).format("DD/MM/YYYY"),
header: () => (
<Typography
level="p6"
className="flex gap-x-2 items-center text-neutral-500"
>
<CalendarLine />
DUEDATE
</Typography>
),
},
{
id: "status",
cell: ({ row }) => (
<Badge
className="ml-auto w-max capitalize"
appearance={
row.original.status === "review"
? "secondary"
: row.original.status === "open"
? "success"
: "primary"
}
>
{row.original.status}
</Badge>
),
header: () => (
<Typography
level="p6"
className="flex gap-x-2 justify-end items-center text-neutral-500"
>
<ChartLine /> STATUS
</Typography>
),
},
]}
data={data?.bounty ?? []}
/>
</div>
</div>
);
}
Binary file added public/dfg-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d5e2cda

Please sign in to comment.