Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

590 mobile cards agenda page #591

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions packages/berlin/src/components/table/Table.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import styled from 'styled-components';
import { FlexColumn } from '../containers/FlexColumn.styled';

export const TableContainer = styled.table`
width: 100%;
border-collapse: collapse;
margin-bottom: 2rem;
table-layout: fixed;
display: none;
@media (min-width: 600px) {
border-collapse: collapse;
display: table;
margin-bottom: 2rem;
table-layout: fixed;
width: 100%;
}
`;

export const TableHeader = styled.th`
Expand All @@ -24,3 +29,24 @@ export const TableCell = styled.td`
export const TableRow = styled.tr`
border-bottom: 1px solid var(--color-black);
`;

export const Cards = styled(FlexColumn)`
width: 100%;
@media (min-width: 600px) {
display: none;
}
`;

export const Card = styled.article`
border-radius: 0.5rem;
border: 1px solid var(--color-black);
display: flex;
flex-direction: column;
gap: 1rem;
padding: 2rem;
width: 100%;

@media (min-width: 600px) {
display: none;
}
`;
49 changes: 31 additions & 18 deletions packages/berlin/src/components/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
import { Body } from '../typography/Body.styled';
import { TableContainer, TableCell, TableHeader, TableRow } from './Table.styled';
import { Subtitle } from '../typography/Subtitle.styled';
import { TableContainer, TableCell, TableHeader, TableRow, Card, Cards } from './Table.styled';

function Table({ columns, rows }: { columns: string[]; rows: (string | React.ReactNode)[][] }) {
return (
<TableContainer>
<thead>
<TableRow>
{columns.map((column) => (
<TableHeader key={column}>
<Body>{column}</Body>
</TableHeader>
<>
<TableContainer>
<thead>
<TableRow>
{columns.map((column) => (
<TableHeader key={column}>
<Body>{column}</Body>
</TableHeader>
))}
</TableRow>
</thead>
<tbody>
{rows.map((row, index) => (
<TableRow key={index}>
{row.map((data, index) => (
<TableCell key={index}>
<Body>{data}</Body>
</TableCell>
))}
</TableRow>
))}
</TableRow>
</thead>
<tbody>
</tbody>
</TableContainer>
<Cards>
<Subtitle>{columns.at(0)}</Subtitle>
{rows.map((row, index) => (
<TableRow key={index}>
<Card key={index}>
{row.map((data, index) => (
<TableCell key={index}>
<Body>{data}</Body>
</TableCell>
<Body key={index}>{data}</Body>
))}
</TableRow>
</Card>
))}
</tbody>
</TableContainer>
</Cards>
</>
);
}

Expand Down
30 changes: 14 additions & 16 deletions packages/berlin/src/pages/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,20 @@ function CycleTable({ cycles, status }: { cycles: GetCycleResponse[]; status: 'o
};

return (
<div>
<Table
columns={[
`${status.charAt(0).toUpperCase() + status.slice(1)} Agendas`,
formattedColumnText(),
'',
]}
rows={cycles.map((cycle) => [
cycle.forumQuestions?.[0]?.questionTitle,
formatDate(cycle.endAt),
<Button onClick={() => handleClick(cycle.id)}>
{status === 'open' ? 'Vote' : 'Results'}
</Button>,
])}
/>
</div>
<Table
columns={[
`${status.charAt(0).toUpperCase() + status.slice(1)} Agendas`,
formattedColumnText(),
'',
]}
rows={cycles.map((cycle) => [
cycle.forumQuestions?.[0]?.questionTitle,
formatDate(cycle.endAt),
<Button onClick={() => handleClick(cycle.id)}>
{status === 'open' ? 'Vote' : 'Results'}
</Button>,
])}
/>
);
}

Expand Down
Loading