Skip to content

Commit

Permalink
feat: financial statement
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Sep 26, 2023
1 parent 554e6af commit 4fe8bd6
Showing 1 changed file with 43 additions and 36 deletions.
79 changes: 43 additions & 36 deletions libs/analytics/src/FinancialStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,62 @@ export const FinancialStatement = (props: {
columns: string[];
data: Record<string, Record<string, Record<string, number[]>>>;
}) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
const columnWeight = props.columns.length + 2;
return (
<Stack
gap={2}
color={(theme) => theme.palette.text.primary}
fontFamily={'Inter'}
fontSize={{ xs: '.7rem', sm: '.875rem' }}
>
<Paper
sx={{
borderRadius: { xs: 1, sm: 2, md: 3 },
overflow: 'hidden',
}}
<Header columns={props.columns} />
{Object.entries(props.data).map(([title, data]) => (
<Table key={title} title={title} data={data} />
))}
</Stack>
);
};

const Header = (props: { columns: string[] }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
const columnWeight = props.columns.length + 2;
return (
<Paper
sx={{
borderRadius: { xs: 1, sm: 2, md: 3 },
overflow: 'hidden',
}}
>
<Stack
direction={'row'}
alignItems={'center'}
justifyContent={'space-between'}
color={(theme) => theme.palette.primary.contrastText}
sx={{ backgroundColor: (theme) => theme.palette.grey[800] }}
fontSize={{ xs: '.875rem', sm: '1.125rem' }}
px={{ xs: 1, sm: 2, md: 4 }}
py={{ xs: 2, sm: 3, md: 4 }}
>
<Stack
direction={'row'}
justifyContent={'space-between'}
color={(theme) => theme.palette.primary.contrastText}
sx={{ backgroundColor: (theme) => theme.palette.grey[800] }}
fontSize={{ xs: '.875rem', sm: '1.125rem' }}
px={{ xs: 1, sm: 2, md: 4 }}
py={{ xs: 2, sm: 3, md: 4 }}
>
<Box width={`${(100 / columnWeight) * 1.5}%`} />
{props.columns.map((column) => (
<Box
key={column}
width={`${100 / columnWeight}%`}
maxWidth={250}
textAlign={'right'}
>
{column}
</Box>
))}
{props.columns.map((column, index) => (
<Box
width={`${100 / columnWeight}%`}
key={column}
width={`${(100 / columnWeight) * (index === 0 ? 2.5 : 1)}%`}
maxWidth={250}
textAlign={'right'}
ml={1}
>
{isMobile ? 'Diff' : 'Difference'}
{column}
</Box>
</Stack>
</Paper>
{Object.entries(props.data).map(([title, data]) => (
<Table key={title} title={title} data={data} />
))}
</Stack>
))}
<Box
width={`${100 / columnWeight}%`}
maxWidth={250}
textAlign={'right'}
>
{isMobile ? 'Diff' : 'Difference'}
</Box>
</Stack>
</Paper>
);
};

Expand Down

0 comments on commit 4fe8bd6

Please sign in to comment.