diff --git a/CLAUDE.md b/CLAUDE.md index 82ace21e7..165528abc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,6 +31,7 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi - No return type annotations. Put `satisfies Type` on the returned expression instead. - Wrap functions defined inside React components in `useCallback`. - Never inline a complex type (a union of object shapes, etc.) in a signature; name it as an interface or type. +- Use a string `enum` (`Page = "page"`) instead of a union of string literals (`"page" | "dialog"`) whenever the values can be enumerated. - In object literals, `...spread` entries come first, each on its own line, followed by a blank line, then the custom entries. A single-line object with a spread becomes multi-line. - When an object literal's values are long expressions, compute them first into `const`s named after their keys, then build the object with shorthand (`{ name, color, tanks: [] }`). Short values stay inline. - Always hoist values that take work to compute (a function call, math, a lookup, like `"A".charCodeAt(0)` or `1 - SCROLL_ZONE`) and don't change between iterations or calls out of loops and repeatedly called functions into a `const` above them. No exceptions. Plain literals (strings, numbers, selectors like `"[data-row]"`) cost nothing and stay inline. diff --git a/packages/website/src/components/TankSearchControls/index.module.css b/packages/website/src/components/TankSearchControls/index.module.css new file mode 100644 index 000000000..bc2777292 --- /dev/null +++ b/packages/website/src/components/TankSearchControls/index.module.css @@ -0,0 +1,32 @@ +.controls { + position: sticky; + z-index: 1; + + display: flex; + flex-direction: column; + gap: var(--space-4); + + margin-block: calc(-1 * var(--space-4)); + padding-block: var(--space-4); + + /* Bleeds across the page gutters so results don't peek out beside it */ + &[data-surface="page"] { + top: var(--navbar-big-height, 0); + + margin-inline: calc(-1 * var(--page-padding)); + padding-inline: var(--page-padding); + + background-color: var(--gray-1); + } + + /* Cancels the overlay's padding, which sticky offsets are measured inside of */ + &[data-surface="dialog"] { + top: calc(-1 * var(--space-4)); + + background-color: var(--gray-2); + } + + .filters { + overflow-x: auto; + } +} diff --git a/packages/website/src/components/TankSearchControls/index.tsx b/packages/website/src/components/TankSearchControls/index.tsx new file mode 100644 index 000000000..8f4b33c1b --- /dev/null +++ b/packages/website/src/components/TankSearchControls/index.tsx @@ -0,0 +1,35 @@ +import type { TankDefinition } from "@blitzkit/protos"; +import type { LocaleAcceptorProps } from "../../hooks/useLocale"; +import { ScrollerCurtains } from "../ScrollerCurtains"; +import { TankSearchBar } from "../TankSearchBar"; +import { TankSearchFilters } from "../TankSearchFilters"; +import styles from "./index.module.css"; + +export enum TankSearchControlsSurface { + Page = "page", + Dialog = "dialog", +} + +interface TankSearchControlsProps extends LocaleAcceptorProps { + // Which surface it sticks within, deciding its offset and background + surface: TankSearchControlsSurface; + onSelect?: (tank: TankDefinition) => void; +} + +// The search bar and filters, stuck flush to the top while the results scroll +export function TankSearchControls({ + locale, + surface, + onSelect, +}: TankSearchControlsProps) { + return ( +