Skip to content

Commit

Permalink
Merge pull request #48 from Lilypad-Tech/nadiem/feat-add-leaderboard-…
Browse files Browse the repository at this point in the history
…block-cards

Nadiem/feat add leaderboard block cards
  • Loading branch information
NadiemM authored Jun 26, 2024
2 parents 106711b + 61f77f1 commit 11d8586
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 8 deletions.
7 changes: 6 additions & 1 deletion apps/info-dashboard/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,10 @@
"leaderboard_node_provider_table_share_x_tweet_shareText2": "– I'm a ",
"leaderboard_node_provider_table_no_data_status": "No data",
"leaderboard_header_tooltip_title_status": "Node online status",
"leaderboard_header_tooltip_description_status": "Data is refreshed every 5 minutes - reload for real-time results."
"leaderboard_header_tooltip_description_status": "Data is refreshed every 5 minutes - reload for real-time results.",
"leaderboard_incentive_program_total_title": "Total",
"leaderboard_incentive_program_week_title": "This week",
"leaderboard_incentive_program_title": "Incentive program: Lilybit_rewards earned",
"leaderboard_get_started_node_provider_button_link": "https://lilypad.tech/incentivenet",
"leaderboard_get_started_node_provider_button_text": "Get started"
}
50 changes: 47 additions & 3 deletions apps/info-dashboard/src/app/leaderboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import Badge from "@/components/Badge/Badge";
import EmptyState from "@/components/EmptyState/EmptyState";
import Tooltip from "@/components/Tooltip/Tooltip";
import { fetchNodes } from "@/lib/fetchers/nodes";
import CardWithBorder from "@/components/CardWithBorder/CardWithBorder";
import Anchor from "@/components/Anchor/Anchor";

// `${API_HOST}metrics-dashboard/metrics` is the endpoint for the metrics dashboard

Expand Down Expand Up @@ -104,6 +106,50 @@ export default function Leaderboard() {
/>
<SectionContainer className="sm:pt-uui-container-padding-desktop mx-auto pt-uui-container-padding-mobile">
{/* Set max height & min height to make table scrollable & minimize layout shifts on state changes */}
<div className="flex flex-col mb-uui-xl md:mb-uui-4xl space-y-uui-xl md:space-y-uui-none md:flex-row md:space-x-uui-3xl">
<CardWithBorder
title={m.leaderboard_incentive_program_title()}
>
<div className="flex space-x-uui-5xl">
<div className="flex-col flex space-y-uui-xs">
<span className="uui-text-sm font-medium text-uui-text-tertiary-600">
{m.leaderboard_incentive_program_total_title()}
</span>
<span className="text-uui-text-primary-900 uui-display-sm font-semibold">
{/* Todo add api cumalative Lilybit_rewards earned */}
n.a.
</span>
</div>
<div className="flex-col flex space-y-uui-xs">
<span className="uui-text-sm font-medium text-uui-text-tertiary-600">
{m.leaderboard_incentive_program_week_title()}
</span>
<span className="text-uui-text-primary-900 uui-display-sm font-semibold">
{/* Todo add api total Lilybit_rewards earned */}
n.a.
</span>
</div>
</div>
</CardWithBorder>
<CardWithBorder
className="gap-uui-3xl"
title="Get started as a node provider today"
subtitle="Check out our instructions and run a node!"
>
<Anchor
href={m.leaderboard_get_started_node_provider_button_link()}
target="_blank"
color="color"
destructive={false}
hierarchy="primary"
size="md"
className="w-fit "
>
{m.leaderboard_get_started_node_provider_button_text()}
</Anchor>
</CardWithBorder>
</div>

<Table className="max-h-[70vh] min-h-[70vh] relative">
{{
cardHeader: (
Expand Down Expand Up @@ -275,9 +321,7 @@ export default function Leaderboard() {
<td>
<TableLeadText
title={
row[
"Hashrate"
]
row["Hashrate"]
}
/>
</td>
Expand Down
33 changes: 33 additions & 0 deletions apps/info-dashboard/src/components/Anchor/Anchor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { AnchorHTMLAttributes, HTMLAttributes } from "react";
import { color, destructive, hierarchy, size } from "./AnchorTypes";
import AnchorWrapper from "./AnchorWrapper";
import AnchorTextAtom from "./AnchorTextAtom";

interface AnchorProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
size: size;
destructive: destructive;
color: color;
hierarchy: hierarchy;
}
const Anchor = ({
size,
destructive,
color,
hierarchy,
...props
}: AnchorProps) => {
return (
<AnchorWrapper
size={size}
destructive={destructive}
color={color}
hierarchy={hierarchy}
{...props}
className={`${props.className}`}
>
<AnchorTextAtom size={size}>{props.children}</AnchorTextAtom>
</AnchorWrapper>
);
};

export default Anchor;
26 changes: 26 additions & 0 deletions apps/info-dashboard/src/components/Anchor/AnchorTextAtom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { HTMLAttributes } from "react";
import { size } from "./AnchorTypes";

interface AnchorTextAtomProps extends HTMLAttributes<HTMLSpanElement> {
size: size;
}

const AnchorTextAtom = ({ size, children, ...props }: AnchorTextAtomProps) => {
const textSizes = {
md: " uui-text-sm ",
};

const layer1 =
" pointer-events-none font-semibold whitespace-nowrap px-uui-xxs ";

return (
<span
{...props}
className={`${props.className} ${textSizes[size]} ${layer1}`}
>
{children}
</span>
);
};

export default AnchorTextAtom;
7 changes: 7 additions & 0 deletions apps/info-dashboard/src/components/Anchor/AnchorTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type destructive = boolean;

export type color = "color";

export type hierarchy = "primary";

export type size = "md";
80 changes: 80 additions & 0 deletions apps/info-dashboard/src/components/Anchor/AnchorWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { HTMLAttributes } from "react";
import { color, destructive, hierarchy, size } from "./AnchorTypes";

interface AnchorWrapperProps extends HTMLAttributes<HTMLAnchorElement> {
size: size;
destructive: destructive;
color: color;
hierarchy: hierarchy;
}

type Coloring = {
[D in `${destructive}`]: {
[H in hierarchy]: {
color: string[];
};
};
};

export const AnchorWrapper = ({
children,
size,
destructive,
color,
hierarchy,
...props
}: AnchorWrapperProps) => {
const layer1 =
" group flex justify-center items-center [&.disabled]:pointer-events-none uui-focus-all:outline-none [&.disabled]:text-uui-fg-disabled [&.disabled]:pointer-events-none ";
const shadow = " shadow-uui-xs ";

const wrapperSizes = {
md: " p-[var(--uui-spacing-2-5)] px-[var(--uui-spacing-3-5)] ",
};

const coloring = {
false: {
primary: {
color: [
"bg-uui-button-primary-bg",
"text-uui-button-primary-fg",
"border-uui-button-primary-bg",
"border",
"rounded-uui-3xl",
"border-solid",
// hover
"uui-hover-all:bg-uui-button-primary-bg_hover",
"uui-hover-all:text-uui-button-primary-fg_hover",
"uui-hover-all:border-uui-button-primary-border_hover",
// focus
"uui-focus-all:uui-ring-brand",
"uui-focus-all:shadow-uui-xs",
// disabled
"[&.disabled]:bg-uui-bg-disabled",
"[&.disabled]:border-uui-border-disabled_subtle",
],
},
},
// empty for now, will add in correct styles when needed
true: {
primary: {
color: [],
},
},
};

const destructiveColoring = destructive.toString() as keyof Coloring;

return (
<a
{...props}
className={` ${props.className} ${layer1} ${shadow} ${
wrapperSizes[size]
} ${coloring[destructiveColoring][hierarchy][color].join(" ")}`}
>
{children}
</a>
);
};

export default AnchorWrapper;
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
interface CardWithBorderProps extends React.HTMLAttributes<HTMLDivElement> {
title: string;
title?: string;
subtitle?: string;
}

export default function CardWithBorder({
title,
subtitle,
children,
...props
}: CardWithBorderProps) {
return (
<div className="p-uui-2xl uui-desktop:p-uui-3xl gap-uui-2xl w-full snap-center h-full rounded-uui-xl border-uui-1 border-uui-border-secondary flex flex-col justify-between bg-uui-bg-primary_alt">
<div className="uui-text-lg text-uui-text-primary-900 font-semibold">
{title}
<div
{...props}
className={`${props.className} p-uui-2xl uui-desktop:p-uui-3xl gap-uui-2xl w-full snap-center rounded-uui-xl border-uui-1 border-uui-border-secondary flex flex-col justify-between bg-uui-bg-primary_alt `}
>
<div className="flex flex-col space-y-uui-xs">
{title && (
<div className="uui-text-lg text-uui-text-primary-900 font-semibold antialiased">
{title}
</div>
)}
{subtitle && (
<div className="uui-text-sm antialiased font-regular text-uui-text-tertiary-600">
{subtitle}
</div>
)}
</div>
{children}
</div>
Expand Down

0 comments on commit 11d8586

Please sign in to comment.