This commit is contained in:
tresabhi committed 2026-11-18 22:31:10 -06:00
1 parent 08df0001ed
commit 8cf000cbe6
12 files changed
+265 -42

No files matched your search

@@ -19,12 +19,22 @@ const filtered = Object.values(tools).filter(
---
<style>
#navbar {
#navbar-desktop {
--icon-size: 1.5rem;
--padding: var(--space-4);
--min-content-width: calc(var(--icon-size) + 2 * var(--padding));
@media screen and (max-width: 80rem) {
display: none;
}
width: var(--min-content-width);
height: 100dvh;
position: sticky;
top: 0;
z-index: 1;
.expander {
background-color: var(--gray-1);
@@ -51,7 +61,6 @@ const filtered = Object.values(tools).filter(
&:hover {
width: fit-content;
padding-right: calc(2 * var(--padding));
}
@@ -116,7 +125,6 @@ const filtered = Object.values(tools).filter(
.expander:hover & {
width: calc(2 * var(--icon-size));
border-radius: var(--radius-max);
filter: saturate(1);
}
@@ -136,14 +144,14 @@ const filtered = Object.values(tools).filter(
transition-duration: var(--duration-brief);
#navbar:hover & {
#navbar-desktop:hover & {
background-color: var(--black-a8);
}
}
}
</style>
<nav id="navbar">
<nav id="navbar-desktop">
<div class="overlay" />
<div class="expander">
@@ -0,0 +1,121 @@
---
import { CaretUpIcon, GearIcon } from "@radix-ui/react-icons";
import { api } from "../api/dynamic";
import type { Tool } from "../constants/tools";
import type { LocaleAcceptorProps } from "../hooks/useLocale";
import { Logo } from "../icons/Logo";
import { Text } from "./Text";
type Props = LocaleAcceptorProps & {
tool: Tool;
};
const { locale, tool } = Astro.props;
const strings = await api.strings(locale);
---
<style>
#navbar-mobile {
--icon-size: 1.5rem;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
padding: var(--space-4);
box-sizing: border-box;
justify-content: space-between;
z-index: 1;
background-color: var(--black-a9);
backdrop-filter: var(--blur-tint);
border-top: var(--space-0) solid var(--white-a4);
transition-duration: var(--duration-brief);
display: none;
@media screen and (max-width: 80rem) {
display: flex;
}
&[data-visible="false"] {
transform: translateY(100%);
border-top: 0 solid var(--white-a3);
}
.icon {
color: var(--gray-11);
width: var(--icon-size);
height: var(--icon-size);
}
.tool {
display: flex;
align-items: center;
.logo {
flex-shrink: 0;
width: var(--icon-size);
height: var(--icon-size);
background-size: cover;
background-position: center;
border-radius: var(--radius-max);
margin-right: var(--space-4);
}
.icon {
margin-left: var(--space-2);
color: var(--gray-12);
}
}
}
</style>
<script>
const navbar = document.getElementById("navbar-mobile")!;
let lastScrollY = window.scrollY;
window.addEventListener(
"scroll",
() => {
const scrollY = window.scrollY;
if (scrollY === lastScrollY) return;
navbar.dataset.visible = `${scrollY < lastScrollY}`;
lastScrollY = scrollY;
},
{ passive: true },
);
</script>
<nav id="navbar-mobile" data-visible="true">
<Logo className="icon" />
<div class="tool">
<div
style={`background-image: url(/media/tools/banners/${tool.slug ?? tool.id}.webp)`}
class="logo"
/>
<Text className="name">
{strings.tools[tool.id as keyof typeof strings.tools].name}
</Text>
<CaretUpIcon className="icon" />
</div>
<GearIcon className="icon" />
</nav>
@@ -48,6 +48,19 @@
}
}
&[data-variant="overline"] {
border-radius: 0;
.indicator {
background: linear-gradient(var(--accent-a2), transparent);
outline: none;
border-radius: 0;
border-top: var(--space-1) solid var(--accent-9);
}
}
.option {
position: relative;
@@ -1,4 +1,5 @@
import { type ReactNode } from "react";
import { type ComponentProps, type ReactNode } from "react";
import { classNames } from "../../ui/classNames";
import styles from "./index.module.css";
export interface SegmentedControlOption {
@@ -6,12 +7,12 @@ export interface SegmentedControlOption {
label: ReactNode;
}
export interface SegmentedControlProps {
export interface SegmentedControlProps extends ComponentProps<"div"> {
options: readonly SegmentedControlOption[];
value: string;
onValueChange(value: string): void;
size?: "regular" | "minor";
variant?: "solid" | "underline";
variant?: "solid" | "underline" | "overline";
}
export function SegmentedControl({
@@ -20,19 +21,24 @@ export function SegmentedControl({
onValueChange,
size = "regular",
variant = "solid",
className,
style,
...props
}: SegmentedControlProps) {
const selectedIndex = options.findIndex((option) => option.value === value);
const segmentWidth = 100 / options.length;
return (
<div
className={styles.options}
className={classNames(styles.options, className)}
role="radiogroup"
data-size={size}
data-variant={variant}
style={{
gridTemplateColumns: `repeat(${options.length}, minmax(0, 1fr))`,
...style,
}}
{...props}
>
<div
className={styles.indicator}
@@ -1,7 +1,5 @@
.wrapper {
height: calc(100dvh - 16rem);
padding: var(--space-4);
padding-bottom: 0;
.cavity {
overflow: hidden;
@@ -13,5 +11,9 @@
background-color: black;
border-radius: var(--space-4);
@media screen and (max-width: 80rem) {
border-radius: 0;
}
}
}
@@ -0,0 +1,13 @@
.tabs {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
display: none;
@media screen and (max-width: 80rem) {
display: flex;
}
}
@@ -0,0 +1,24 @@
import { Tankopedia, TankopediaTab } from "../../stores/tankopedia";
import { SegmentedControl } from "../SegmentedControl";
import styles from "./index.module.css";
export function TankopediaTabs() {
const tab = Tankopedia.use((state) => state.tab);
return (
<SegmentedControl
className={styles.tabs}
value={tab}
options={[
{ label: "Sandbox", value: TankopediaTab.Sandbox },
{ label: "Loadout", value: TankopediaTab.Loadout },
]}
onValueChange={(value) => {
Tankopedia.mutate((state) => {
state.tab = value as TankopediaTab;
});
}}
variant="overline"
/>
);
}
+16 -5
View File
@@ -3,8 +3,10 @@ import BaseMeta from "../components/BaseMeta.astro";
import BaseStyles from "../components/BaseStyles.astro";
import ColorAlias from "../components/ColorAlias.astro";
import ColorScale from "../components/ColorScale.astro";
import Navbar from "../components/Navbar.astro";
import NavbarDesktop from "../components/NavbarDesktop.astro";
import NavbarMobile from "../components/NavbarMobile.astro";
import SystemTheme from "../components/SystemTheme.astro";
import { tools } from "../constants/tools";
import type { LocaleAcceptorProps } from "../hooks/useLocale";
import type { Color } from "../ui/color";
@@ -13,6 +15,8 @@ type Props = LocaleAcceptorProps & {
};
const { locale, accent } = Astro.props;
const tool = tools.tanks;
---
<html lang={locale} class="dark">
@@ -40,14 +44,16 @@ const { locale, accent } = Astro.props;
interpolate-size: allow-keywords;
background-color: var(--gray-1);
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
body {
margin: 0;
width: 100dvw;
height: 100dvh;
display: flex;
background-color: var(--gray-1);
@@ -57,12 +63,17 @@ const { locale, accent } = Astro.props;
.main {
flex: 1;
}
@media screen and (max-width: 80rem) {
flex-direction: column-reverse;
}
}
</style>
</head>
<body>
<Navbar {locale} />
<NavbarDesktop {locale} {tool} />
<NavbarMobile {locale} {tool} />
<main class="main">
<slot />
@@ -1,18 +0,0 @@
---
import locales from "@blitzkit/i18n/locales.json";
import BaseLayout2 from "../../../layouts/BaseLayout2.astro";
import { getStaticPaths as _getStaticPaths } from "../_index";
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => {
return locales.supported.map(({ locale }) => ({
props: { locale },
params: { locale: locale === locales.default ? undefined : locale },
}));
});
const { locale } = Astro.props;
---
<BaseLayout2 {locale} />
@@ -1,12 +1,17 @@
.page {
max-height: 100dvh;
flex-grow: 1;
display: flex;
gap: var(--space-4);
.sandbox {
flex-grow: 1;
margin-left: calc(-1 * var(--space-4));
padding-top: var(--space-4);
@media screen and (max-width: 80rem) {
padding-top: 0;
}
}
.loadout {
@@ -15,6 +20,11 @@
background-color: var(--gray-2);
position: sticky;
top: 0;
max-height: 100dvh;
.content {
padding: var(--space-5);
@@ -23,4 +33,13 @@
gap: var(--space-5);
}
}
@media screen and (max-width: 80rem) {
.sandbox,
.loadout {
&[data-tabbed="false"] {
display: none;
}
}
}
}
@@ -9,13 +9,14 @@ import { TankopediaCharacteristics } from "../../../../../components/TankopediaC
import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities";
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
import { TankopediaTabs } from "../../../../../components/TankopediaTabs";
import { TankopediaVideos } from "../../../../../components/TankopediaVideos";
import { defaultEqualizer } from "../../../../../config/equalizer";
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
import { withLocale } from "../../../../../hocs/withLocale";
import { useAwait } from "../../../../../hooks/useAwait";
import { useCharacteristics } from "../../../../../hooks/useCharacteristics";
import { Tankopedia } from "../../../../../stores/tankopedia";
import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia";
import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps";
import styles from "./_index.module.css";
@@ -45,9 +46,12 @@ export const Page = withErrorWrapper(
);
function Loadout() {
const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Loadout);
return (
<Scroller
className={styles.loadout}
data-tabbed={tabbed}
orientation={ScrollerOrientation.Vertical}
>
<div className={styles.content}>
@@ -82,11 +86,10 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
return { value } satisfies ThicknessRange;
}, [protagonist, equalize]);
const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Sandbox);
return (
<Scroller
className={styles.sandbox}
orientation={ScrollerOrientation.Vertical}
>
<div className={styles.sandbox}>
<TankopediaSandbox
antagonistCharacteristics={antagonistCharacteristics}
skeleton={skeleton}
@@ -95,6 +98,18 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
<TankopediaCharacteristics characteristics={characteristics} />
<TankopediaGameModeAbilities />
<TankopediaVideos />
</Scroller>
<TankopediaTabs />
</div>
);
// return (
// <Scroller
// id="main"
// className={styles.sandbox}
// data-tabbed={tabbed}
// orientation={ScrollerOrientation.Vertical}
// >
// </Scroller>
// );
}
@@ -102,6 +102,8 @@ interface Tankopedia {
showControls: boolean;
animate: boolean;
tab: TankopediaTab;
protagonist: TankState;
antagonist: TankState;
environment: TankEnvironment;
@@ -125,6 +127,11 @@ interface Tankopedia {
// statSearch?: string;
}
export enum TankopediaTab {
Sandbox = "sandbox",
Loadout = "loadout",
}
const skills = await api.skills();
export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
@@ -134,6 +141,8 @@ export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
showControls: false,
animate: true,
tab: TankopediaTab.Sandbox,
protagonist: createTankState(tank),
antagonist: createTankState(tank),
environment: createDefaultEnvironment(skills),