Skip to content

Commit

Permalink
feat: integrate radix-ui tag to gpu pricing page
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyukikumazawa committed Aug 22, 2024
1 parent c311d2d commit a7d4847
Show file tree
Hide file tree
Showing 13 changed files with 651 additions and 1,190 deletions.
1,456 changes: 507 additions & 949 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.1.0",
"@tailwindcss/typography": "^0.5.10",
"@tanstack/react-query": "^4.29.7",
"@tanstack/react-query-devtools": "^4.32.6",
Expand Down Expand Up @@ -57,6 +60,7 @@
"swiper": "10.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.0.24",
"tailwindcss-animate": "^1.0.7",
"unist-util-remove": "^4.0.0",
"unist-util-visit": "^5.0.0",
"zustand": "^4.5.2"
Expand Down
4 changes: 2 additions & 2 deletions src/components/header/hamburger-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const navigation = [
name: "Development",
href: "/development/welcome/",
},
{ name: "Ecosystem", href: "/ecosystem/showcase/latest" },
{ name: "Ecosystem", href: "/ecosystem/showcase/latest/" },
{ name: "Community", href: "/community/akash-insiders/" },
{ name: "Blog", href: "/blog" },
{ name: "Docs", href: "/docs" },
{ name: "Pricing & Earnings", href: "/pricing/gpus" },
{ name: "Pricing & Earnings", href: "/pricing/" },
];

export default function HamburgerMenu({
Expand Down
6 changes: 3 additions & 3 deletions src/components/header/header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ ${disableSticky ? "" : "sticky top-0 z-[30]"}
Ecosystem
</NavLink>

<NavLink href="/blog" currentPath={pathname}>Blog</NavLink>
<NavLink href="/docs" currentPath={pathname}>Docs</NavLink>
<NavLink href="/pricing/gpus" currentPath={pathname}>Pricing & Earnings</NavLink>
<NavLink href="/blog/" currentPath={pathname}>Blog</NavLink>
<NavLink href="/docs/" currentPath={pathname}>Docs</NavLink>
<NavLink href="/pricing/" currentPath={pathname}>Pricing & Earnings</NavLink>
</div>
</div>

Expand Down
33 changes: 0 additions & 33 deletions src/components/pricing-page/pricing-navbar.astro

This file was deleted.

143 changes: 55 additions & 88 deletions src/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,55 @@
import { useEffect, useId, useState } from "react";

function classNames(...classes: any) {
return classes.filter(Boolean).join(" ");
}

export default function TabsWrapper({
defaultTab,
children,
}: {
defaultTab?: string;
children: any;
}) {
const [currentTab, setCurrentTab] = useState<any>(defaultTab);
const [alltabs, setAllTabs] = useState<string[]>([]);
const mainId = useId();

useEffect(() => {
const main = document.getElementById(mainId);
const tabs = main?.querySelectorAll("section");
tabs?.forEach((tab) => {
if (tab.id === currentTab) {
tab.classList.remove("hidden");
} else {
tab.classList.add("hidden");
}
});
}, [currentTab]);

useEffect(() => {
const main = document.getElementById(mainId);

// get all ids of section and log

const tabs = main?.querySelectorAll("section");

const allTabs: string[] = [];
tabs?.forEach((tab) => {
allTabs.push(tab.id);
});
setAllTabs(allTabs);

if (!defaultTab) {
setCurrentTab(allTabs[0]);
}
}, []);

console.log(currentTab);

return (
<div className="bg-background2 p-5 ">
<div className="border-b border-gray-200">
<nav className="-mb-px flex" aria-label="Tabs">
{alltabs.map((tab) => (
<button
onClick={() => setCurrentTab(tab)}
key={tab}
className={classNames(
currentTab === tab
? "border-black text-black dark:border-white dark:text-white"
: "border-transparent text-[#889096] hover:border-gray-300 hover:text-gray-700 dark:hover:text-white",
" border-b-2 px-3 py-2 text-center text-sm font-medium",
)}
aria-current={tab ? "page" : undefined}
>
{tab}
</button>
))}
</nav>
</div>
<div id={mainId}>{children}</div>
</div>
);
}

export const TabContent = ({
children,
value,
}: {
children: any;
value: string;
}) => {
return (
<section id={value} className="hidden">
{children}
</section>
);
};
"use client"

import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"

import { cn } from "@/lib/utils"

const Tabs = TabsPrimitive.Root

const TabsList = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.List>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
<TabsPrimitive.List
ref={ref}
className={cn(
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
className
)}
{...props}
/>
))
TabsList.displayName = TabsPrimitive.List.displayName

const TabsTrigger = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Trigger
ref={ref}
className={cn(
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
className
)}
{...props}
/>
))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName

const TabsContent = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Content
ref={ref}
className={cn(
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
className
)}
{...props}
/>
))
TabsContent.displayName = TabsPrimitive.Content.displayName

export { Tabs, TabsList, TabsTrigger, TabsContent }
54 changes: 54 additions & 0 deletions src/pages/pricing/Pricing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import GpuTable from "@/components/gpu-table/gpu-table";
import ProviderTable from "@/components/pricing-page/provider/provider-table";
import UsageTable from "@/components/pricing-page/usage/usage-table";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"

function Pricing() {

return (
<Tabs defaultValue={"gpus"} className="w-full">
<TabsList className="bg-slate-800">
<TabsTrigger value="gpus">GPU Pricing</TabsTrigger>
<TabsTrigger value="usage">Usage Pricing Calculator</TabsTrigger>
<TabsTrigger value="provider">Provider Earn Calculator</TabsTrigger>
</TabsList>
<TabsContent value="gpus">
<div className="">
<h2 className="text-center text-2xl font-bold md:block md:text-3xl">
GPU Models, Prices & Availabilty
</h2>
<p className="text-center leading-[28px]">
Browse the list of available GPUs along with their hourly rates.
</p>
</div>
<GpuTable initialData={null} />
</TabsContent>
<TabsContent value="usage">
<div className="">
<h2 className="text-center text-2xl font-bold md:block md:text-3xl">
Usage Pricing
</h2>
<p className="text-center leading-[28px]">
Estimate your costs by selecting the resources you need. <br />
Adjust CPU, memory, storage, and other parameters to get a detailed
cost breakdown.
</p>
</div>
<UsageTable initialData={null} />
</TabsContent>
<TabsContent value="provider">
<div className="">
<h2 className="text-center text-2xl font-bold md:block md:text-3xl">
Provider Earn Calculator
</h2>
<p className="text-center leading-[28px]">
Calculate your potential earnings by providing resources to the Akash Network.
</p>
</div>
<ProviderTable initialData={null} />
</TabsContent>
</Tabs>
)
}

export { Pricing };
37 changes: 0 additions & 37 deletions src/pages/pricing/gpus/index.astro

This file was deleted.

25 changes: 25 additions & 0 deletions src/pages/pricing/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import Layout from "@/layouts/layout.astro";
import { Pricing } from "./Pricing.tsx";
---

<Layout
title=" GPU Availability and Pricing"
description=" GPU Availability and Pricing"
image="/meta-images/gpus.png"
>
<section
class="container mx-auto flex max-w-[1380px] flex-col gap-16 pt-[100px]"
>
<h1
class="text-center text-2xl font-bold md:block md:text-2lg lg:text-3lg lg:leading-[52px]"
>
Explorer pricing and calculate<br /> your costs or earnings
</h1>
<div
class="sidebar-scroll flex items-center overflow-x-auto p-2 md:overflow-x-hidden lg:justify-center"
>
<Pricing client:load />
</div>
</section>
</Layout>
37 changes: 0 additions & 37 deletions src/pages/pricing/provider/index.astro

This file was deleted.

Loading

0 comments on commit a7d4847

Please sign in to comment.