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

Some improvements to Tables and OverviewPage #990

Merged
merged 18 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
da36f84
Add missing footer to Election Report Page
Lionqueen94 Feb 7, 2025
79a57cb
Make sure table linkrow has separate column for the chevron with a se…
Lionqueen94 Feb 7, 2025
a6990f0
Show a message that no elections exist on overview page instead of a …
Lionqueen94 Feb 7, 2025
41ece77
Forgot UserListPage LinkRow change
Lionqueen94 Feb 7, 2025
f58f162
Corrected error logo color in Alert, ProgressList and StatusList and …
Lionqueen94 Feb 7, 2025
2c2435b
Merge branch 'main' into some_small_fixes
Lionqueen94 Feb 7, 2025
2d26841
Make sure there is no empty table when there are no polling stations …
Lionqueen94 Feb 8, 2025
ffba221
Adjusted no elections text, to be expanded in other epic
Lionqueen94 Feb 8, 2025
ce7cbca
Fix test
Lionqueen94 Feb 9, 2025
baf5ca6
Merge branch 'main' into some_small_fixes
Lionqueen94 Feb 10, 2025
9f9e9ea
Rename Table.Column to Table.HeaderCell and undid empty cell for chev…
Lionqueen94 Feb 10, 2025
558485a
Added Footer to OverviewLayout and removed from all child routes and …
Lionqueen94 Feb 10, 2025
5fe59c8
Merge branch 'main' into some_small_fixes
Lionqueen94 Feb 10, 2025
9d96510
Merge branch 'main' into some_small_fixes
Lionqueen94 Feb 11, 2025
e72177b
Added separate alert when all polling stations data entries have been…
Lionqueen94 Feb 11, 2025
eecd93d
Merge branch 'main' into some_small_fixes
Lionqueen94 Feb 12, 2025
a06a9ac
Re-added the Footer back to the pages instead of in the Layout, we sh…
Lionqueen94 Feb 12, 2025
20d7838
Moved footer to OverviewPage instead of OverviewLayout to be more con…
Lionqueen94 Feb 12, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function PollingStationsList({ pollingStations }: PollingStationsListProp
<Table.Header>
<Table.Column>{t("number")}</Table.Column>
<Table.Column>{t("polling_station.title.singular")}</Table.Column>
<Table.Column />
</Table.Header>
<Table.Body>
{pollingStations.map((pollingStation: PollingStation) => {
Expand All @@ -35,6 +36,7 @@ export function PollingStationsList({ pollingStations }: PollingStationsListProp
<span>{pollingStation.name}</span>
{status && <Badge type={status} showIcon />}
</Table.Cell>
<Table.Cell />
</Table.LinkRow>
);
})}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/module/election/page/OverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function OverviewPage() {
{!isAdminOrCoordinator ? t("election.location") : t("election.level_polling_station")}
</Table.Column>
<Table.Column>{t("election_status.label")}</Table.Column>
<Table.Column />
</Table.Header>
<Table.Body className="fs-md">
{electionList.map((election) => (
Expand All @@ -69,6 +70,7 @@ export function OverviewPage() {
userRole={isAdminOrCoordinator ? "coordinator" : "typist"}
/>
</Table.Cell>
<Table.Cell />
</Table.LinkRow>
))}
</Table.Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ describe("PollingStationListPage", () => {
const table = await screen.findByRole("table");
expect(table).toBeVisible();
expect(table).toHaveTableContent([
["Nummer", "Naam", "Soort"],
["33", "Op Rolletjes", "Mobiel"],
["34", "Testplek", "Bijzonder"],
["35", "Testschool", "Vaste locatie"],
["36", "Testbuurthuis", "Vaste locatie"],
["Nummer", "Naam", "Soort", ""],
["33", "Op Rolletjes", "Mobiel", ""],
["34", "Testplek", "Bijzonder", ""],
["35", "Testschool", "Vaste locatie", ""],
["36", "Testbuurthuis", "Vaste locatie", ""],
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function PollingStationListPage() {
<Table.Column>{t("number")}</Table.Column>
<Table.Column>{t("name")}</Table.Column>
<Table.Column>{t("type")}</Table.Column>
<Table.Column />
</Table.Header>
<Table.Body className="fs-md">
{data.polling_stations.map((station) => (
Expand All @@ -114,6 +115,7 @@ export function PollingStationListPage() {
<Table.Cell>
{station.polling_station_type && labelForPollingStationType[station.polling_station_type]}
</Table.Cell>
<Table.Cell />
</Table.LinkRow>
))}
</Table.Body>
Expand Down
12 changes: 6 additions & 6 deletions frontend/app/module/users/UserListPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe("PollingStationListPage", () => {
const table = await screen.findByRole("table");
expect(table).toBeVisible();
expect(table).toHaveTableContent([
["Gebruikersnaam", "Rol", "Volledige naam", "Laatste activiteit"],
["Sanne", "Beheerder", "Sanne Molenaar", "vandaag 10:20"],
["Jayden", "Coördinator", "Jayden Ahmen", "vandaag 13:37"],
["Gebruiker01", "Invoerder", "Nog niet gebruikt", "–"],
["Gebruiker02", "Invoerder", "Nog niet gebruikt", "–"],
["Gebruiker03", "Invoerder", "Nog niet gebruikt", "–"],
["Gebruikersnaam", "Rol", "Volledige naam", "Laatste activiteit", ""],
["Sanne", "Beheerder", "Sanne Molenaar", "vandaag 10:20", ""],
["Jayden", "Coördinator", "Jayden Ahmen", "vandaag 13:37", ""],
["Gebruiker01", "Invoerder", "Nog niet gebruikt", "–", ""],
["Gebruiker02", "Invoerder", "Nog niet gebruikt", "–", ""],
["Gebruiker03", "Invoerder", "Nog niet gebruikt", "–", ""],
]);
});
});
1 change: 1 addition & 0 deletions frontend/lib/icon/generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const IconChevronRight = (props: React.SVGAttributes<SVGElement>) => (
version="1.1"
viewBox="0 0 20 20"
role="img"
fill="#475467"
>
<path d="M7.5,15.8c-.2,0-.4,0-.6-.2-.3-.3-.3-.9,0-1.2l4.4-4.4-4.4-4.4c-.3-.3-.3-.9,0-1.2.3-.3.9-.3,1.2,0l5,5c.3.3.3.9,0,1.2l-5,5c-.2.2-.4.2-.6.2Z" />
</svg>
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/icon/svg/chevronRight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions frontend/lib/ui/Table/Table.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
background: var(--color-hover);
}

/* Chevron icon cell */
td:last-of-type {
width: 5rem;
padding-right: 2.75rem;
background-image: url("../../icon/svg/chevronRight.svg");
background-size: 1.25rem;
Expand Down
6 changes: 5 additions & 1 deletion frontend/lib/ui/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ export const LinkTable: Story = () => {
<Table.Header>
<Table.Column>Number</Table.Column>
<Table.Column>Click me</Table.Column>
<Table.Column>Look a chevron</Table.Column>
<Table.Column>Look a chevron right of here</Table.Column>
<Table.Column />
</Table.Header>
<Table.Body className="fs-md">
{data.map((row) => (
<Table.LinkRow key={row[0]} to={`#row${row[0]}`}>
<Table.NumberCell>{row[0]}</Table.NumberCell>
<Table.Cell>{row[1]}</Table.Cell>
<Table.Cell>{row[2]}</Table.Cell>
<Table.Cell />
</Table.LinkRow>
))}
</Table.Body>
Expand All @@ -86,6 +88,7 @@ export const IconBadgeTable: Story = () => (
<Table.Column>Number</Table.Column>
<Table.Column>With icon</Table.Column>
<Table.Column>With badge</Table.Column>
<Table.Column />
</Table.Header>
<Table.Body>
{data.map((row) => (
Expand All @@ -99,6 +102,7 @@ export const IconBadgeTable: Story = () => (
<span>{row[2]}</span>
<Badge type="first_entry_in_progress" showIcon />
</Table.Cell>
<Table.Cell />
</Table.LinkRow>
))}
</Table.Body>
Expand Down
29 changes: 21 additions & 8 deletions frontend/lib/ui/Table/Table.tsx
praseodym marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import cls from "./Table.module.css";
export interface TableProps {
id?: string;
children?: React.ReactNode;
className?: string;
}

export function Table({ id, children }: TableProps) {
export function Table({ id, children, className }: TableProps) {
return (
<table id={id} className={cls.table}>
<table id={id} className={cn(cls.table, className)}>
{children}
</table>
);
Expand All @@ -34,27 +35,39 @@ function Header({ children, className }: { children: React.ReactNode[]; classNam
);
}

function Column({ children, className }: { children: React.ReactNode; className?: string }) {
return <th className={className}>{children}</th>;
function Column({
children,
scope,
className,
}: {
children?: React.ReactNode;
scope?: "col" | "row";
className?: string;
}) {
return (
<th scope={scope || "col"} className={className}>
{children}
</th>
);
}

function Body({ children, className }: { children: React.ReactNode[]; className?: string }) {
return <tbody className={className}>{children}</tbody>;
}

function Row({ children }: { children: React.ReactNode[] }) {
return <tr>{children}</tr>;
function Row({ children, className }: { children: React.ReactNode[]; className?: string }) {
return <tr className={className}>{children}</tr>;
}

function LinkRow({ children, to }: { children: React.ReactNode[]; to: To }) {
function LinkRow({ children, to, className }: { children: React.ReactNode[]; to: To; className?: string }) {
const navigate = useNavigate();

function handleClick() {
void navigate(to);
}

return (
<tr className={cls.rowLink} onClick={handleClick}>
<tr className={cn(cls.rowLink, className)} onClick={handleClick}>
{children}
</tr>
);
Expand Down