mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-31 14:39:51 +01:00
feat: sticky tank cards
This commit is contained in:
1 parent
ac243a3cdd
commit
127ffc787e
4 files changed
+48
-16
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Flex } from '@radix-ui/themes';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
import { StickyTableRoot } from '../../../../components/StickyTableRoot';
|
||||||
|
import { BodyLoader } from './BodyLoader';
|
||||||
|
import { Header } from './Header';
|
||||||
|
import { Tanks } from './Tanks';
|
||||||
|
|
||||||
|
export function TankTable() {
|
||||||
|
return (
|
||||||
|
<Flex justify="center">
|
||||||
|
<StickyTableRoot variant="surface" style={{ maxWidth: '100%' }}>
|
||||||
|
<Header />
|
||||||
|
<Suspense fallback={<BodyLoader />}>
|
||||||
|
<Tanks />
|
||||||
|
</Suspense>
|
||||||
|
</StickyTableRoot>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,27 +1,14 @@
|
|||||||
import { Flex, Table } from '@radix-ui/themes';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
import { FilterControl } from '../tankopedia/components/FilterControl';
|
import { FilterControl } from '../tankopedia/components/FilterControl';
|
||||||
import { BodyLoader } from './components/BodyLoader';
|
|
||||||
import { Header } from './components/Header';
|
|
||||||
import { Info } from './components/Info';
|
import { Info } from './components/Info';
|
||||||
import { Tanks } from './components/Tanks';
|
import { TankTable } from './components/Table';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<PageWrapper color="jade" noMaxWidth>
|
<PageWrapper color="jade" noMaxWidth>
|
||||||
<Info />
|
<Info />
|
||||||
|
|
||||||
<FilterControl />
|
<FilterControl />
|
||||||
|
<TankTable />
|
||||||
<Flex justify="center">
|
|
||||||
<Table.Root variant="surface" style={{ maxWidth: '100%' }}>
|
|
||||||
<Header />
|
|
||||||
<Suspense fallback={<BodyLoader />}>
|
|
||||||
<Tanks />
|
|
||||||
</Suspense>
|
|
||||||
</Table.Root>
|
|
||||||
</Flex>
|
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Table } from '@radix-ui/themes';
|
||||||
|
import { RootProps } from '@radix-ui/themes/dist/cjs/components/table';
|
||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
|
export function StickyTableRoot(props: RootProps) {
|
||||||
|
const table = useRef<HTMLTableElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
table.current
|
||||||
|
?.querySelector('table')
|
||||||
|
?.style.setProperty('overflow', 'auto');
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <Table.Root {...props} ref={table} />;
|
||||||
|
}
|
||||||
@@ -13,7 +13,14 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
|
|||||||
const Icon = classIcons[tank.class];
|
const Icon = classIcons[tank.class];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.RowHeaderCell style={{ display: 'flex' }}>
|
<Table.RowHeaderCell
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
position: 'sticky',
|
||||||
|
left: 0,
|
||||||
|
backgroundColor: 'var(--color-background)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Link href={`/tools/tankopedia/${tank.id}`} tabIndex={-1}>
|
<Link href={`/tools/tankopedia/${tank.id}`} tabIndex={-1}>
|
||||||
<img
|
<img
|
||||||
alt={tank.name}
|
alt={tank.name}
|
||||||
|
|||||||
Reference in new issue
Block a user