feat: tankopedia list

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
TrèsAbhiandCopilot committed 2026-04-26 18:19:09 -05:00
1 parent bc0004574a
commit 2bae132d18
7 files changed
+61 -14

No files matched your search

@@ -81,5 +81,7 @@ import "@fontsource-variable/roboto-flex";
--duration-brief: 200ms; --duration-brief: 200ms;
--duration-subtle: 2s; --duration-subtle: 2s;
--tank-card-width: 11rem;
} }
</style> </style>
@@ -23,7 +23,7 @@
} }
.icon { .icon {
width: 11rem; width: var(--tank-card-width);
height: 7rem; height: 7rem;
position: relative; position: relative;
@@ -1,4 +1,3 @@
import type { PopularTank } from "@protos/blitzkit/popular_tanks";
import { api } from "../../core/api/dynamic"; import { api } from "../../core/api/dynamic";
import { useAwait } from "../../hooks/useAwait"; import { useAwait } from "../../hooks/useAwait";
import { useGameStrings } from "../../hooks/useGameStrings"; import { useGameStrings } from "../../hooks/useGameStrings";
@@ -7,7 +6,12 @@ import { LinkI18n } from "../LinkI18n";
import { Text } from "../Text"; import { Text } from "../Text";
import styles from "./index.module.css"; import styles from "./index.module.css";
export function TankCard({ id }: PopularTank) { interface TankCardProps {
id: string;
subtitle?: string;
}
export function TankCard({ id }: TankCardProps) {
const tank = useAwait(() => api.tank(id), `tank-${id}`); const tank = useAwait(() => api.tank(id), `tank-${id}`);
const gameStrings = useGameStrings("TankEntity"); const gameStrings = useGameStrings("TankEntity");
const locale = useLocale(); const locale = useLocale();
@@ -0,0 +1,6 @@
.tank-cards {
display: grid;
gap: var(--space-5) var(--space-4);
grid-template-columns: repeat(auto-fill, var(--tank-card-width));
justify-content: center;
}
@@ -0,0 +1,9 @@
import styles from "./index.module.css";
interface Props {
children: React.ReactNode;
}
export function TankCards({ children }: Props) {
return <div className={styles["tank-cards"]}>{children}</div>;
}
@@ -0,0 +1,29 @@
import { TankCard } from "../../../components/TankCard";
import { TankCards } from "../../../components/TankCards";
import { api } from "../../../core/api/dynamic";
import { useAwait } from "../../../hooks/useAwait";
import { LocaleProvider } from "../../../hooks/useLocale";
interface PageProps {
locale: string;
}
export function Page({ locale, ...props }: PageProps) {
return (
<LocaleProvider locale={locale}>
<Content {...props} />
</LocaleProvider>
);
}
function Content() {
const tankList = useAwait(() => api.tankList(), "tank-list");
return (
<TankCards>
{tankList.list.map(({ id }) => (
<TankCard key={id} id={id} />
))}
</TankCards>
);
}
@@ -1,9 +1,11 @@
--- ---
import "@radix-ui/colors/violet-dark.css"; import "@radix-ui/colors/violet-dark.css";
import { Section } from "../../../components/Section";
import ToolBanner from "../../../components/ToolBanner.astro"; import ToolBanner from "../../../components/ToolBanner.astro";
import { api } from "../../../core/api/dynamic"; import { api } from "../../../core/api/dynamic";
import { tools } from "../../../core/tools/tools"; import { tools } from "../../../core/tools/tools";
import BaseLayout from "../../../layouts/BaseLayout.astro"; import BaseLayout from "../../../layouts/BaseLayout.astro";
import { Page } from "./_index";
export { getStaticPaths } from "../index.astro"; export { getStaticPaths } from "../index.astro";
@@ -14,16 +16,11 @@ const tankList = await api.tankList();
<BaseLayout {locale} accent="purple"> <BaseLayout {locale} accent="purple">
<ToolBanner {locale} tool={tools.tanks} slot="pre-app" /> <ToolBanner {locale} tool={tools.tanks} slot="pre-app" />
<h1>tanks</h1> <Section>
<Page {locale} client:load />
</Section>
{ <!-- {
tankList.list.map(({ id, slug }) => (
<p> } -->
<a href={`/tanks/${slug}`}>
<img height="128" width="128" src={`/api/tanks/${id}.webp`} />
{slug} ({id})
</a>
</p>
))
}
</BaseLayout> </BaseLayout>