simplified page padding scheme

This commit is contained in:
tresabhi committed 2026-11-21 19:33:55 -06:00
1 parent baf42d0273
commit 9efcb55083
30 files changed
+129 -196

No files matched your search

@@ -23,6 +23,7 @@ styles += "}";
<style>
:root {
--page-width: 64rem;
--page-padding: var(--space-4);
--max-size: max(100vw, 100vh);
--radius-max: var(--max-size);
@@ -75,7 +75,7 @@ export function CompareTable() {
}, [members, environment]);
return (
<Table.Root scrollable>
<Table.Root>
<Table.Head>
<Table.Row>
<Table.IconCorner>
@@ -2,7 +2,7 @@
import { api } from "../api/dynamic";
import { tools } from "../constants/tools";
import { Heading } from "./Heading";
import HomeSection from "./HomeSection.astro";
import { Section } from "./Section";
import ToolCard from "./ToolCard.astro";
import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro";
import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro";
@@ -16,7 +16,7 @@ const { locale } = Astro.props;
const strings = await api.strings(locale);
---
<HomeSection>
<Section>
<Heading size="2">{strings.home.cosmetics}</Heading>
<ToolCardLayoutRoot minor>
@@ -28,4 +28,4 @@ const strings = await api.strings(locale);
<ToolCard {locale} tool={tools.backgrounds} />
</ToolCardLayoutColumn>
</ToolCardLayoutRoot>
</HomeSection>
</Section>
@@ -2,7 +2,7 @@
import { api } from "../api/dynamic";
import { tools } from "../constants/tools";
import { Heading } from "./Heading";
import HomeSection from "./HomeSection.astro";
import { Section } from "./Section";
import ToolCard from "./ToolCard.astro";
import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro";
import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro";
@@ -16,7 +16,7 @@ const { locale } = Astro.props;
const strings = await api.strings(locale);
---
<HomeSection>
<Section>
<Heading size="2" className="title">{strings.home.games}</Heading>
<ToolCardLayoutRoot>
@@ -28,4 +28,4 @@ const strings = await api.strings(locale);
<ToolCard {locale} tool={tools.guesser} />
</ToolCardLayoutColumn>
</ToolCardLayoutRoot>
</HomeSection>
</Section>
@@ -2,7 +2,7 @@
import { api } from "../api/dynamic";
import { tools } from "../constants/tools";
import { Heading } from "./Heading";
import HomeSection from "./HomeSection.astro";
import { Section } from "./Section";
import ToolCard from "./ToolCard.astro";
import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro";
import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro";
@@ -16,7 +16,7 @@ const { locale } = Astro.props;
const strings = await api.strings(locale);
---
<HomeSection>
<Section>
<Heading size="2">{strings.home.players}</Heading>
<ToolCardLayoutRoot>
@@ -30,4 +30,4 @@ const strings = await api.strings(locale);
<!-- <ToolCard {locale} tool={tools.players} /> -->
</ToolCardLayoutColumn>
</ToolCardLayoutRoot>
</HomeSection>
</Section>
@@ -1,11 +0,0 @@
<style>
.home-section {
display: flex;
flex-direction: column;
gap: var(--space-4);
}
</style>
<div class="home-section">
<slot />
</div>
@@ -2,7 +2,7 @@
import { api } from "../api/dynamic";
import { tools } from "../constants/tools";
import { Heading } from "./Heading";
import HomeSection from "./HomeSection.astro";
import { Section } from "./Section";
import ToolCard from "./ToolCard.astro";
import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro";
import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro";
@@ -15,7 +15,7 @@ const { locale } = Astro.props;
const strings = await api.strings(locale);
---
<HomeSection>
<Section>
<Heading size="2">{strings.home.tanks}</Heading>
<ToolCardLayoutRoot>
@@ -28,4 +28,4 @@ const strings = await api.strings(locale);
<ToolCard {locale} minor tool={tools.performance} />
</ToolCardLayoutColumn>
</ToolCardLayoutRoot>
</HomeSection>
</Section>
@@ -2,7 +2,7 @@
import { api } from "../api/dynamic";
import { tools } from "../constants/tools";
import { Heading } from "./Heading";
import HomeSection from "./HomeSection.astro";
import { Section } from "./Section";
import ToolCard from "./ToolCard.astro";
import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro";
import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro";
@@ -16,7 +16,7 @@ const { locale } = Astro.props;
const strings = await api.strings(locale);
---
<HomeSection>
<Section>
<Heading size="2">{strings.home.technical}</Heading>
<ToolCardLayoutRoot minor>
@@ -28,4 +28,4 @@ const strings = await api.strings(locale);
<ToolCard {locale} tool={tools.changelogs} />
</ToolCardLayoutColumn>
</ToolCardLayoutRoot>
</HomeSection>
</Section>
@@ -24,7 +24,7 @@ export const filtered = Object.values(tools).filter(
<style>
#navbar-desktop {
--icon-size: 1.5rem;
--padding: var(--space-4);
--padding: var(--page-padding);
--min-content-width: calc(var(--icon-size) + 2 * var(--padding));
display: none;
@@ -1,7 +1,3 @@
.root {
overflow-x: auto;
}
.value {
white-space: nowrap;
}
@@ -102,7 +102,7 @@ export function PerformanceTable() {
}
return (
<Table.Root className={styles.root}>
<Table.Root>
<Head />
<Body filtered={filtered} />
</Table.Root>
@@ -1,24 +1,25 @@
.section {
padding: var(--space-4);
@media (pointer: fine) {
padding-left: 0;
}
display: flex;
justify-content: center;
flex-direction: column;
padding-right: var(--page-padding);
/* astro island's children sometimes end up being first deeper into the div's */
&:first-child:not(astro-island > &) {
padding-top: var(--page-padding);
}
&:last-child {
flex: 1;
padding-bottom: var(--page-padding);
}
.content {
flex: 1;
max-width: var(--page-width);
@media (pointer: coarse) {
padding-left: var(--page-padding);
}
gap: var(--space-5);
display: flex;
flex-direction: column;
&[data-overflow="true"] {
padding-right: 0;
overflow-x: auto;
}
}
@@ -2,13 +2,17 @@ import type { ComponentProps } from "react";
import { classNames } from "../../ui/classNames";
import styles from "./index.module.css";
export interface SectionProps extends ComponentProps<"div"> {}
export interface SectionProps extends ComponentProps<"section"> {
overflow?: boolean;
}
// TODO: reevaluate the usefulness of this as it seems to do very little
export function Section({ className, children, ...props }: SectionProps) {
export function Section({ className, overflow, ...props }: SectionProps) {
return (
<div className={classNames(styles.section, className)} {...props}>
<div className={styles.content}>{children}</div>
</div>
<section
className={classNames(styles.section, className)}
data-overflow={overflow || undefined}
{...props}
/>
);
}
@@ -1,17 +1,13 @@
.scroller {
/* Fits the table, centered by the parent, never wider than the page */
max-width: 100%;
border: var(--space-0) solid var(--gray-a5);
border-radius: var(--space-3);
/* Clips the corners without becoming a scroll container, so sticky headers follow the page */
overflow: clip;
}
.table {
border-radius: var(--space-3);
overflow: hidden;
border-collapse: separate;
border-spacing: 0;
width: fit-content;
margin: auto;
th,
td {
padding: var(--space-3);
@@ -13,16 +13,12 @@ import { Logo } from "../../icons/Logo";
import { SortDirection } from "../../stores/tankopediaPersistent";
import { CharacteristicRanking } from "../../types/characteristics";
import { classNames } from "../../ui/classNames";
import { Scroller, ScrollerOrientation } from "../Scroller";
import styles from "./index.module.css";
interface RootProps
extends Omit<ComponentProps<typeof Scroller>, "orientation"> {
scrollable?: boolean;
}
interface RootProps extends ComponentProps<"table"> {}
// When scrollable, scrolls both ways, keeping the head, the row headers and the group titles in view
function Root({ children, className, scrollable, ...props }: RootProps) {
function Root({ children, className, ...props }: RootProps) {
const table = useRef<HTMLTableElement>(null);
// Group titles stick right below the head, whatever its height
@@ -42,30 +38,12 @@ function Root({ children, className, scrollable, ...props }: RootProps) {
return () => observer.disconnect();
}, []);
const content = (
return (
<table ref={table} className={styles.table}>
{children}
</table>
);
if (!scrollable) {
return (
<div className={classNames(styles.scroller, className)} {...props}>
{content}
</div>
);
}
return (
<Scroller
orientation={ScrollerOrientation.Both}
startCurtain={false}
className={classNames(styles.scroller, className)}
{...props}
>
{content}
</Scroller>
);
}
function Head(props: ComponentProps<"thead">) {
@@ -25,8 +25,8 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
background-size: cover;
@media (pointer: fine) {
margin: var(--margin) var(--margin) 0 0;
border-radius: var(--space-4);
margin: var(--page-padding) var(--page-padding) 0 0;
}
.content {