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

WIA Report Page Styling #4110

Merged
merged 6 commits into from
Oct 24, 2023
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
2 changes: 1 addition & 1 deletion apps/admin/frontend/src/components/election_manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { BallotListScreen } from '../screens/ballot_list_screen';
import { PrintTestDeckScreen } from '../screens/print_test_deck_screen';
import { UnconfiguredScreen } from '../screens/unconfigured_screen';
import { TallyScreen } from '../screens/tally_screen';
import { TallyWriteInReportScreen } from '../screens/write_in_adjudication_report_screen';
import { TallyWriteInReportScreen } from '../screens/reporting/write_in_adjudication_report_screen';
import { DefinitionViewerScreen } from '../screens/definition_viewer_screen';
import { ManualDataSummaryScreen } from '../screens/manual_data_summary_screen';
import { ManualDataEntryScreen } from '../screens/manual_data_entry_screen';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { ElectionDefinition, Tabulation } from '@votingworks/types';
import {
BallotCountReport,
Button,
Caption,
Font,
H5,
H6,
Icons,
Loading,
Expand All @@ -13,7 +10,6 @@ import {
printElementToPdf,
} from '@votingworks/ui';
import React, { useContext, useMemo, useRef, useState } from 'react';
import styled from 'styled-components';
import { Optional, assert, assertDefined } from '@votingworks/basics';
import { isElectionManagerAuth } from '@votingworks/utils';
import type { ScannerBatch } from '@votingworks/admin-backend';
Expand All @@ -32,69 +28,16 @@ import {
import { ExportReportPdfButton } from './export_report_pdf_button';
import { FileType } from '../save_frontend_file_modal';
import { ExportBallotCountReportCsvButton } from './export_ballot_count_report_csv_button';

const ExportActions = styled.div`
margin-top: 1rem;
margin-bottom: 0.5rem;
display: flex;
justify-content: start;
gap: 1rem;
`;

const PreviewContainer = styled.div`
position: relative;
min-height: 11in;
margin-top: 0.5rem;
padding: 0.5rem;
background: rgba(0, 0, 0, 10%);
border-radius: 0.5rem;
display: flex;
flex-direction: column;
align-items: center;
`;

const PreviewOverlay = styled.div`
position: absolute;
inset: 0;
z-index: 1;
background: black;
opacity: 0.3;
`;

const PreviewReportPages = styled.div`
section {
background: white;
position: relative;
box-shadow: 0 3px 10px rgb(0, 0, 0, 20%);
margin-top: 1rem;
margin-bottom: 2rem;
width: 8.5in;
min-height: 11in;
padding: 0.5in;
}
`;

const PreviewActionContainer = styled.div`
position: absolute;
inset: 0;
margin-left: auto;
margin-right: auto;
margin-top: 4rem;
display: flex;
justify-content: center;
align-items: start;
z-index: 2;
`;

const LoadingTextContainer = styled.div`
background: white;
width: 35rem;
border-radius: 0.5rem;
`;

const NoResultsNotice = styled(H5)`
margin-top: 2rem;
`;
import {
ExportActions,
NoResultsNotice,
PaginationNote,
PreviewActionContainer,
PreviewContainer,
PreviewLoading,
PreviewOverlay,
PreviewReportPages,
} from './shared';

function Report({
electionDefinition,
Expand Down Expand Up @@ -330,11 +273,7 @@ export function BallotCountReportViewer({
disabled={disabled || areQueryResultsEmpty}
/>
</ExportActions>

<Caption>
<Icons.Info /> <Font weight="bold">Note:</Font> Printed reports may be
paginated to more than one piece of paper.
</Caption>
<PaginationNote />
<PreviewContainer>
{!disabled && (
<React.Fragment>
Expand All @@ -347,13 +286,7 @@ export function BallotCountReportViewer({
</NoResultsNotice>
)}
{!previewIsFresh && <PreviewOverlay />}
{isFetchingForPreview && (
<PreviewActionContainer>
<LoadingTextContainer>
<Loading>Generating Report</Loading>
</LoadingTextContainer>
</PreviewActionContainer>
)}
{isFetchingForPreview && <PreviewLoading />}
{!isFetchingForPreview && !previewIsFresh && (
<PreviewActionContainer>
{previewReport ? (
Expand Down
93 changes: 93 additions & 0 deletions apps/admin/frontend/src/components/reporting/shared.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Caption, Font, H5, Icons, LinkButton, Loading } from '@votingworks/ui';
import styled from 'styled-components';
import { routerPaths } from '../../router_paths';

export const ExportActions = styled.div`
margin-top: 1rem;
margin-bottom: 0.5rem;
display: flex;
justify-content: start;
gap: 1rem;
`;

export const PreviewContainer = styled.div`
position: relative;
min-height: 11in;
margin-top: 0.5rem;
padding: 0.5rem;
background: rgba(0, 0, 0, 10%);
border-radius: 0.5rem;
display: flex;
flex-direction: column;
align-items: center;
`;

export const PreviewOverlay = styled.div`
position: absolute;
inset: 0;
z-index: 1;
background: black;
opacity: 0.3;
`;

export const PreviewReportPages = styled.div`
section {
background: white;
position: relative;
box-shadow: 0 3px 10px rgb(0, 0, 0, 20%);
margin-top: 1rem;
margin-bottom: 2rem;
width: 8.5in;
min-height: 11in;
padding: 0.5in;
}
`;

export const PreviewActionContainer = styled.div`
position: absolute;
inset: 0;
margin-left: auto;
margin-right: auto;
margin-top: 4rem;
display: flex;
justify-content: center;
align-items: start;
z-index: 2;
`;

export const LoadingTextContainer = styled.div`
background: white;
width: 35rem;
border-radius: 0.5rem;
`;

export const NoResultsNotice = styled(H5)`
margin-top: 2rem;
`;

export function PreviewLoading(): JSX.Element {
return (
<PreviewActionContainer>
<LoadingTextContainer>
<Loading>Generating Report</Loading>
</LoadingTextContainer>
</PreviewActionContainer>
);
}

export function ReportBackButton(): JSX.Element {
return (
<LinkButton small to={routerPaths.reports}>
<Icons.Previous /> Back
</LinkButton>
);
}

export function PaginationNote(): JSX.Element {
return (
<Caption>
<Icons.Info /> <Font weight="bold">Note:</Font> Printed reports may be
paginated to more than one piece of paper.
</Caption>
);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { ElectionDefinition, Tabulation } from '@votingworks/types';
import {
Button,
Caption,
Font,
H5,
H6,
Icons,
Loading,
Expand All @@ -12,7 +9,6 @@ import {
printElementToPdf,
} from '@votingworks/ui';
import React, { useContext, useMemo, useRef, useState } from 'react';
import styled from 'styled-components';
import { Optional, assert, assertDefined } from '@votingworks/basics';
import {
combineGroupSpecifierAndFilter,
Expand All @@ -38,69 +34,16 @@ import {
import { ExportReportPdfButton } from './export_report_pdf_button';
import { ExportTallyReportCsvButton } from './export_tally_report_csv_button';
import { FileType } from '../save_frontend_file_modal';

const ExportActions = styled.div`
margin-top: 1rem;
margin-bottom: 0.5rem;
display: flex;
justify-content: start;
gap: 1rem;
`;

const PreviewContainer = styled.div`
position: relative;
min-height: 11in;
margin-top: 0.5rem;
padding: 0.5rem;
background: rgba(0, 0, 0, 10%);
border-radius: 0.5rem;
display: flex;
flex-direction: column;
align-items: center;
`;

const PreviewOverlay = styled.div`
position: absolute;
inset: 0;
z-index: 1;
background: black;
opacity: 0.3;
`;

const PreviewReportPages = styled.div`
section {
background: white;
position: relative;
box-shadow: 0 3px 10px rgb(0, 0, 0, 20%);
margin-top: 1rem;
margin-bottom: 2rem;
width: 8.5in;
min-height: 11in;
padding: 0.5in;
}
`;

const PreviewActionContainer = styled.div`
position: absolute;
inset: 0;
margin-left: auto;
margin-right: auto;
margin-top: 4rem;
display: flex;
justify-content: center;
align-items: start;
z-index: 2;
`;

const LoadingTextContainer = styled.div`
background: white;
width: 35rem;
border-radius: 0.5rem;
`;

const NoResultsNotice = styled(H5)`
margin-top: 2rem;
`;
import {
ExportActions,
NoResultsNotice,
PaginationNote,
PreviewActionContainer,
PreviewContainer,
PreviewLoading,
PreviewOverlay,
PreviewReportPages,
} from './shared';

function Reports({
electionDefinition,
Expand Down Expand Up @@ -339,11 +282,7 @@ export function TallyReportViewer({
disabled={disabled || areQueryResultsEmpty}
/>
</ExportActions>

<Caption>
<Icons.Info /> <Font weight="bold">Note:</Font> Printed reports may be
paginated to more than one piece of paper.
</Caption>
<PaginationNote />
<PreviewContainer>
{!disabled && (
<React.Fragment>
Expand All @@ -356,13 +295,7 @@ export function TallyReportViewer({
</NoResultsNotice>
)}
{!previewIsFresh && <PreviewOverlay />}
{isFetchingForPreview && (
<PreviewActionContainer>
<LoadingTextContainer>
<Loading>Generating Report</Loading>
</LoadingTextContainer>
</PreviewActionContainer>
)}
{isFetchingForPreview && <PreviewLoading />}
{!isFetchingForPreview && !previewIsFresh && (
<PreviewActionContainer>
{previewReport ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Icons, LinkButton, P } from '@votingworks/ui';
import { P } from '@votingworks/ui';
import { useContext } from 'react';
import { assert } from '@votingworks/basics';
import { isElectionManagerAuth } from '@votingworks/utils';
import { AppContext } from '../../contexts/app_context';
import { NavigationScreen } from '../../components/navigation_screen';
import { routerPaths } from '../../router_paths';
import { TallyReportViewer } from '../../components/reporting/tally_report_viewer';
import { ReportBackButton } from '../../components/reporting/shared';

export const SCREEN_TITLE = 'All Precincts Tally Report';

Expand All @@ -17,9 +17,7 @@ export function AllPrecinctsTallyReportScreen(): JSX.Element {
return (
<NavigationScreen title={SCREEN_TITLE}>
<P>
<LinkButton small to={routerPaths.reports}>
<Icons.Previous /> Back
</LinkButton>
<ReportBackButton />
</P>
<TallyReportViewer
filter={{}}
Expand Down
Loading