mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-13 14:31:10 -05:00
* side layout initial * add elements to side nav * side buttons links * remove clog * calendar page initial * position sticky working * x trends page initial * new table * same mode selector * mobile friendly table * no underline for nav links * xsearch * x trends page outlined * sr initial * relocate calendar components * calendar fix flex * topnav fancier look * layout looking good edition * relocate xtrends * xtrends remove linecharts * x trends new * calender page new * delete headbanner, new login * remove calendar stuff from api * rename stuff in utils * fix user item margin * new home page initial * remove page concept * no pointer xtrends * remove xrank from app * xtrends service * move fa from app * move plus * maps tweaks * new table for plus history * navigational sidebar flex tweaks * builds page * analyzer * user page * free agents * plans * remove mx * tweaks * change layout to grid * home page finalized * mobile nav * restrict main content width * tweaks style * language switcher * container in css * sticky nav * use duplicate icons for now * change mapsketch width to old * chara tour vid * borzoic icons
109 lines
2.5 KiB
TypeScript
109 lines
2.5 KiB
TypeScript
import { Box, Grid } from "@chakra-ui/layout";
|
|
import { useMediaQuery } from "@chakra-ui/media-query";
|
|
import {
|
|
Table,
|
|
TableCaption,
|
|
Tbody,
|
|
Td,
|
|
Tfoot,
|
|
Th,
|
|
Thead,
|
|
Tr,
|
|
} from "@chakra-ui/table";
|
|
import React, { Fragment } from "react";
|
|
import OutlinedBox from "./OutlinedBox";
|
|
|
|
export default function NewTable({
|
|
caption,
|
|
headers,
|
|
data,
|
|
smallAtPx,
|
|
}: {
|
|
caption?: string;
|
|
headers: {
|
|
name: string;
|
|
dataKey: string;
|
|
}[];
|
|
data: (Record<string, React.ReactNode> & { id: number })[];
|
|
smallAtPx?: string;
|
|
}) {
|
|
const [isSmall] = useMediaQuery(
|
|
smallAtPx ? `(max-width: ${smallAtPx}px)` : "(max-width: 600px)"
|
|
);
|
|
|
|
if (isSmall) {
|
|
return (
|
|
<>
|
|
{data.map((row) => {
|
|
return (
|
|
<Grid
|
|
key={row.id}
|
|
border="1px solid"
|
|
borderColor="whiteAlpha.300"
|
|
rounded="lg"
|
|
px={4}
|
|
py={2}
|
|
mb={4}
|
|
templateColumns="1fr 2fr"
|
|
gridRowGap={1}
|
|
alignItems="center"
|
|
>
|
|
{headers.map(({ name, dataKey }) => {
|
|
return (
|
|
<Fragment key={dataKey}>
|
|
<Box
|
|
textTransform="uppercase"
|
|
fontWeight="bold"
|
|
fontSize="sm"
|
|
fontFamily="heading"
|
|
letterSpacing="wider"
|
|
color="gray.400"
|
|
mr={2}
|
|
>
|
|
{name}
|
|
</Box>
|
|
<Box>{row[dataKey]}</Box>
|
|
</Fragment>
|
|
);
|
|
})}
|
|
</Grid>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<OutlinedBox>
|
|
<Table variant="simple" fontSize="sm">
|
|
{caption && <TableCaption placement="top">{caption}</TableCaption>}
|
|
<Thead>
|
|
<Tr>
|
|
{headers.map(({ name }) => (
|
|
<Th key={name}>{name}</Th>
|
|
))}
|
|
</Tr>
|
|
</Thead>
|
|
<Tbody>
|
|
{data.map((row) => {
|
|
return (
|
|
<Tr key={row.id}>
|
|
{headers.map(({ dataKey }) => {
|
|
return <Td key={dataKey}>{row[dataKey]}</Td>;
|
|
})}
|
|
</Tr>
|
|
);
|
|
})}
|
|
</Tbody>
|
|
<Tfoot>
|
|
<Tr>
|
|
{headers.map(({ name }) => (
|
|
<Th key={name}>{name}</Th>
|
|
))}
|
|
</Tr>
|
|
</Tfoot>
|
|
</Table>
|
|
</OutlinedBox>
|
|
);
|
|
}
|