feat: shadow sticky column

This commit is contained in:
TrèsAbhi committed 2024-07-07 21:13:40 -05:00
1 parent 86d7007dc2
commit b27d200ae6
3 files changed
+23 -8

No files matched your search

@@ -1,5 +1,6 @@
import { Table } from '@radix-ui/themes'; import { Table } from '@radix-ui/themes';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
import { StickyRowHeaderCell } from '../../../../components/StickyRowHeaderCell';
import { import {
AverageDefinitionsAllStats, AverageDefinitionsAllStats,
AverageDefinitionsEntryWithId, AverageDefinitionsEntryWithId,
@@ -42,7 +43,7 @@ export const Total = memo<TotalProps>(
return ( return (
<Table.Row> <Table.Row>
<Table.RowHeaderCell>Total</Table.RowHeaderCell> <StickyRowHeaderCell>Total</StickyRowHeaderCell>
<Table.Cell align="center">{(winrate * 100).toFixed(1)}%</Table.Cell> <Table.Cell align="center">{(winrate * 100).toFixed(1)}%</Table.Cell>
<Table.Cell align="center"> <Table.Cell align="center">
{numberFormat.format(ratio * players)} {numberFormat.format(ratio * players)}
+17
View File
@@ -0,0 +1,17 @@
import { Table } from '@radix-ui/themes';
import { RowHeaderCellProps } from '@radix-ui/themes/dist/cjs/components/table';
export function StickyRowHeaderCell({ style, ...props }: RowHeaderCellProps) {
return (
<Table.RowHeaderCell
style={{
position: 'sticky',
left: 0,
backgroundColor: 'var(--color-panel)',
boxShadow: 'var(--shadow-6)',
...style,
}}
{...props}
/>
);
}
+4 -7
View File
@@ -1,9 +1,9 @@
import { Table } from '@radix-ui/themes';
import { TankDefinition } from '../core/blitzkit/tankDefinitions'; import { TankDefinition } from '../core/blitzkit/tankDefinitions';
import { tankIcon } from '../core/blitzkit/tankIcon'; import { tankIcon } from '../core/blitzkit/tankIcon';
import { classIcons } from './ClassIcon'; import { classIcons } from './ClassIcon';
import { Link } from './Link'; import { Link } from './Link';
import { ScienceIcon } from './ScienceIcon'; import { ScienceIcon } from './ScienceIcon';
import { StickyRowHeaderCell } from './StickyRowHeaderCell';
interface TankRowHeaderCellProps { interface TankRowHeaderCellProps {
tank: TankDefinition; tank: TankDefinition;
@@ -13,17 +13,14 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
const Icon = classIcons[tank.class]; const Icon = classIcons[tank.class];
return ( return (
<Table.RowHeaderCell <StickyRowHeaderCell
maxWidth={{ maxWidth={{
initial: '180px', initial: '180px',
sm: '240px', sm: '240px',
}} }}
style={{ style={{
display: 'flex',
position: 'sticky',
left: 0,
backgroundColor: 'var(--color-background)',
overflow: 'hidden', overflow: 'hidden',
display: 'flex',
}} }}
> >
<Link href={`/tools/tankopedia/${tank.id}`} tabIndex={-1}> <Link href={`/tools/tankopedia/${tank.id}`} tabIndex={-1}>
@@ -77,6 +74,6 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
<ScienceIcon style={{ width: '1em', height: '1em' }} /> <ScienceIcon style={{ width: '1em', height: '1em' }} />
)} )}
</Link> </Link>
</Table.RowHeaderCell> </StickyRowHeaderCell>
); );
} }