Spaces:
Paused
Paused
Download components/StatsDisplay.tsx from samirhosninet/HubAPI: direct link, hf CLI and curl.
- Browser
- Download file 6.08 kB
-
https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/StatsDisplay.tsx
- Command line
-
hf download hf://spaces/samirhosninet/HubAPI/components/StatsDisplay.tsx
-
curl -L -o StatsDisplay.tsx https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/StatsDisplay.tsx
6.08 kB
| "use client"; | |
| import { topCountries } from "../data/country-data"; | |
| import { useLanguage } from "@/components/LanguageContext"; | |
| function PreviewMetricRow({ label, value }: { label: string; value: string }) { | |
| return ( | |
| <li className="flex items-center justify-between gap-x-3 w-full"> | |
| <h3 className="m-0 font-mono font-medium text-xs text-muted-foreground uppercase tracking-tight"> | |
| {label} | |
| </h3> | |
| <div className="flex-1 border-b border-dashed border-primary/15 mx-2 min-w-[1rem]" aria-hidden="true" /> | |
| <span className="text-foreground font-mono text-xs font-semibold tabular-nums text-right shrink-0"> | |
| {value} | |
| </span> | |
| </li> | |
| ); | |
| } | |
| function PreviewFeatureCard({ | |
| title, | |
| description, | |
| items, | |
| footer, | |
| }: { | |
| title: string; | |
| description?: string; | |
| items?: string[]; | |
| footer?: { label: string; note: string }; | |
| }) { | |
| return ( | |
| <div className="premium-glass-card p-5 md:p-6 w-full h-full transition-colors duration-300 shadow-sm dark:shadow-none clip-cyber-card corner-bracket relative group"> | |
| <div className="corner-bracket-inner" aria-hidden="true" /> | |
| <div className="space-y-2 relative z-10"> | |
| <h2 className="my-0 font-mono font-bold text-xs tracking-tight uppercase text-muted-foreground group-hover:text-primary transition-colors"> | |
| {title} | |
| </h2> | |
| {description && ( | |
| <p className="text-sm text-muted-foreground font-mono leading-relaxed mt-2"> | |
| {description} | |
| </p> | |
| )} | |
| {items && items.length > 0 && ( | |
| <ul className="space-y-1.5 list-none pl-0 mt-3"> | |
| {items.map((item) => ( | |
| <li | |
| key={item} | |
| className="font-mono text-xs text-primary/80 uppercase tracking-tight flex items-center gap-2" | |
| > | |
| <span className="text-primary/50" aria-hidden="true"> | |
| ▸ | |
| </span> | |
| {item} | |
| </li> | |
| ))} | |
| </ul> | |
| )} | |
| {footer && ( | |
| <div className="mt-4 pt-3 border-t border-primary/10"> | |
| <p className="text-xs font-mono text-muted-foreground uppercase">{footer.label}</p> | |
| <p className="text-[10px] font-mono text-primary/70 mt-1 uppercase tracking-widest"> | |
| {footer.note} | |
| </p> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| ); | |
| } | |
| export function DashboardPreviewMetrics() { | |
| const { t } = useLanguage(); | |
| const metrics = [ | |
| { label: t("dashboardMetricApiKeys"), value: t("dashboardMetricApiKeysValue") }, | |
| { label: t("dashboardMetricModels"), value: t("dashboardMetricModelsValue") }, | |
| { label: t("dashboardMetricRequests"), value: t("dashboardMetricRequestsValue") }, | |
| { label: t("dashboardMetricBalance"), value: t("dashboardMetricBalanceValue") }, | |
| { label: t("dashboardMetricTopModel"), value: t("dashboardMetricTopModelValue") }, | |
| { label: t("dashboardMetricSpend"), value: t("dashboardMetricSpendValue") }, | |
| ]; | |
| return ( | |
| <div className="space-y-3"> | |
| <div className="flex items-center justify-between gap-2"> | |
| <h2 className="my-0 font-mono font-medium text-sm tracking-tight uppercase text-muted-foreground"> | |
| {t("dashboardPreviewOnly")} | |
| </h2> | |
| </div> | |
| <ul className="list-none pl-0 space-y-2"> | |
| {metrics.map((m) => ( | |
| <PreviewMetricRow key={m.label} label={m.label} value={m.value} /> | |
| ))} | |
| </ul> | |
| </div> | |
| ); | |
| } | |
| export function PlannedProviderRegions() { | |
| const { t } = useLanguage(); | |
| return ( | |
| <div className="space-y-2"> | |
| <h2 className="my-0 font-mono font-medium text-sm tracking-tight uppercase text-muted-foreground"> | |
| {t("dashboardPlannedRegions")} | |
| </h2> | |
| <ul className="list-none pl-0 space-y-1.5"> | |
| {topCountries.map((country) => ( | |
| <li | |
| key={country.code} | |
| className="flex items-center gap-x-2 font-mono text-sm text-foreground" | |
| > | |
| <span style={{ color: country.color }} className="text-sm" aria-hidden="true"> | |
| ■ | |
| </span> | |
| <span className="font-medium tracking-tight">{country.code}</span> | |
| </li> | |
| ))} | |
| </ul> | |
| </div> | |
| ); | |
| } | |
| export function RegionCount() { | |
| const { t } = useLanguage(); | |
| return ( | |
| <div className="flex items-center w-full md:w-fit justify-between md:justify-start mt-2"> | |
| <span aria-hidden="true" className="inline-block translate-y-[-2px] text-primary/60 text-[10px]"> | |
| ▲ | |
| </span> | |
| <span className="font-mono text-sm text-muted-foreground tracking-tight"> | |
| {t("dashboardRegionCountLabel")} | |
| </span> | |
| </div> | |
| ); | |
| } | |
| export function StatsGrid() { | |
| const { t } = useLanguage(); | |
| const cards = [ | |
| { title: t("dashboardCard1Title"), description: t("dashboardCard1Desc") }, | |
| { title: t("dashboardCard2Title"), description: t("dashboardCard2Desc") }, | |
| { title: t("dashboardCard3Title"), description: t("dashboardCard3Desc") }, | |
| { title: t("dashboardCard4Title"), description: t("dashboardCard4Desc") }, | |
| { title: t("dashboardCard5Title"), description: t("dashboardCard5Desc") }, | |
| { title: t("dashboardCard6Title"), description: t("dashboardCard6Desc") }, | |
| { | |
| title: t("dashboardCard7Title"), | |
| items: [ | |
| t("dashboardCard7Item1"), | |
| t("dashboardCard7Item2"), | |
| t("dashboardCard7Item3"), | |
| t("dashboardCard7Item4"), | |
| t("dashboardCard7Item5"), | |
| ], | |
| }, | |
| { | |
| title: t("dashboardCard8Title"), | |
| description: t("dashboardCard8Desc"), | |
| footer: { | |
| label: t("dashboardCard8Savings"), | |
| note: t("dashboardCard8SavingsNote"), | |
| }, | |
| }, | |
| ]; | |
| return ( | |
| <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5"> | |
| {cards.map((card) => ( | |
| <PreviewFeatureCard | |
| key={card.title} | |
| title={card.title} | |
| description={card.description} | |
| items={card.items} | |
| footer={card.footer} | |
| /> | |
| ))} | |
| </div> | |
| ); | |
| } | |