From ab26340ead6eba063734286a374101951d08688b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 28 May 2022 06:58:47 -0700 Subject: Unify report styles --- modern/src/reports/ChartReportPage.js | 16 +++------ modern/src/reports/EventReportPage.js | 19 +++-------- modern/src/reports/RouteReportPage.js | 30 ++-------------- modern/src/reports/StatisticsPage.js | 14 ++------ modern/src/reports/StopReportPage.js | 14 ++------ modern/src/reports/SummaryReportPage.js | 19 +++-------- modern/src/reports/TripReportPage.js | 14 ++------ modern/src/reports/common/useReportStyles.js | 49 +++++++++++++++++++++++++++ modern/src/reports/components/ColumnSelect.js | 6 ++-- modern/src/reports/components/ReportFilter.js | 42 ++++++----------------- 10 files changed, 82 insertions(+), 141 deletions(-) create mode 100644 modern/src/reports/common/useReportStyles.js (limited to 'modern/src') diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index a26c4111..ce50819b 100644 --- a/modern/src/reports/ChartReportPage.js +++ b/modern/src/reports/ChartReportPage.js @@ -2,11 +2,10 @@ import React, { useState } from 'react'; import { FormControl, InputLabel, Select, MenuItem, } from '@mui/material'; -import makeStyles from '@mui/styles/makeStyles'; import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; -import ReportFilter, { useFilterStyles } from './components/ReportFilter'; +import ReportFilter from './components/ReportFilter'; import { formatDate } from '../common/util/formatter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -15,17 +14,10 @@ import usePositionAttributes from '../common/attributes/usePositionAttributes'; import { useCatch } from '../reactHelper'; import { useAttributePreference } from '../common/util/preferences'; import { distanceFromMeters, speedFromKnots, volumeFromLiters } from '../common/util/converter'; - -const useStyles = makeStyles(() => ({ - chart: { - flexGrow: 1, - overflow: 'hidden', - }, -})); +import useReportStyles from './common/useReportStyles'; const ChartReportPage = () => { - const classes = useStyles(); - const filterClasses = useFilterStyles(); + const classes = useReportStyles(); const t = useTranslation(); const positionAttributes = usePositionAttributes(t); @@ -84,7 +76,7 @@ const ChartReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportChart']}> -
+
{t('reportChartType')} ({ - container: { - height: '100%', - display: 'flex', - flexDirection: 'column', - }, - containerMap: { - flexBasis: '40%', - flexShrink: 0, - }, - containerMain: { - overflow: 'auto', - }, - header: { - position: 'sticky', - left: 0, - display: 'flex', - flexDirection: 'column', - alignItems: 'stretch', - }, - columnAction: { - width: '1%', - paddingLeft: theme.spacing(1), - }, -})); +import useReportStyles from './common/useReportStyles'; const RouteReportPage = () => { - const classes = useStyles(); + const classes = useReportStyles(); const t = useTranslation(); const positionAttributes = usePositionAttributes(t); diff --git a/modern/src/reports/StatisticsPage.js b/modern/src/reports/StatisticsPage.js index bb9926f7..5da5b44e 100644 --- a/modern/src/reports/StatisticsPage.js +++ b/modern/src/reports/StatisticsPage.js @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import { Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; -import { makeStyles } from '@mui/styles'; import { formatDate } from '../common/util/formatter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -11,6 +10,7 @@ import ReportFilter from './components/ReportFilter'; import usePersistedState from '../common/util/usePersistedState'; import ColumnSelect from './components/ColumnSelect'; import { useCatch } from '../reactHelper'; +import useReportStyles from './common/useReportStyles'; const columnsArray = [ ['captureTime', 'statisticsCaptureTime'], @@ -26,18 +26,8 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); -const useStyles = makeStyles(() => ({ - header: { - position: 'sticky', - left: 0, - display: 'flex', - flexDirection: 'column', - alignItems: 'stretch', - }, -})); - const StatisticsPage = () => { - const classes = useStyles(); + const classes = useReportStyles(); const t = useTranslation(); const [columns, setColumns] = usePersistedState('statisticsColumns', ['captureTime', 'activeUsers', 'activeDevices', 'messagesStored']); diff --git a/modern/src/reports/StopReportPage.js b/modern/src/reports/StopReportPage.js index 6cf8be07..d2823b06 100644 --- a/modern/src/reports/StopReportPage.js +++ b/modern/src/reports/StopReportPage.js @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import { Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; -import { makeStyles } from '@mui/styles'; import { formatDistance, formatHours, formatDate, formatVolume, } from '../common/util/formatter'; @@ -14,6 +13,7 @@ import ReportsMenu from './components/ReportsMenu'; import ColumnSelect from './components/ColumnSelect'; import usePersistedState from '../common/util/usePersistedState'; import { useCatch } from '../reactHelper'; +import useReportStyles from './common/useReportStyles'; const columnsArray = [ ['startTime', 'reportStartTime'], @@ -26,18 +26,8 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); -const useStyles = makeStyles(() => ({ - header: { - position: 'sticky', - left: 0, - display: 'flex', - flexDirection: 'column', - alignItems: 'stretch', - }, -})); - const StopReportPage = () => { - const classes = useStyles(); + const classes = useReportStyles(); const t = useTranslation(); const distanceUnit = useAttributePreference('distanceUnit'); diff --git a/modern/src/reports/SummaryReportPage.js b/modern/src/reports/SummaryReportPage.js index e2f5e009..a66d1c61 100644 --- a/modern/src/reports/SummaryReportPage.js +++ b/modern/src/reports/SummaryReportPage.js @@ -2,11 +2,10 @@ import React, { useState } from 'react'; import { FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableBody, TableCell, } from '@mui/material'; -import { makeStyles } from '@mui/styles'; import { formatDistance, formatHours, formatDate, formatSpeed, formatVolume, } from '../common/util/formatter'; -import ReportFilter, { useFilterStyles } from './components/ReportFilter'; +import ReportFilter from './components/ReportFilter'; import { useAttributePreference } from '../common/util/preferences'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -14,6 +13,7 @@ import ReportsMenu from './components/ReportsMenu'; import usePersistedState from '../common/util/usePersistedState'; import ColumnSelect from './components/ColumnSelect'; import { useCatch } from '../reactHelper'; +import useReportStyles from './common/useReportStyles'; const columnsArray = [ ['startTime', 'reportStartDate'], @@ -27,19 +27,8 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); -const useStyles = makeStyles(() => ({ - header: { - position: 'sticky', - left: 0, - display: 'flex', - flexDirection: 'column', - alignItems: 'stretch', - }, -})); - const SummaryReportPage = () => { - const classes = useStyles(); - const filterClasses = useFilterStyles(); + const classes = useReportStyles(); const t = useTranslation(); const distanceUnit = useAttributePreference('distanceUnit'); @@ -93,7 +82,7 @@ const SummaryReportPage = () => { } breadcrumbs={['reportTitle', 'reportSummary']}>
-
+
{t('sharedType')} ({ - filter: { - display: 'inline-flex', - flexWrap: 'wrap', - gap: theme.spacing(2), - padding: theme.spacing(3, 2, 2), - }, - item: { - minWidth: 0, - flex: `1 1 ${dimensions.filterFormWidth}`, - }, - buttons: { - display: 'flex', - gap: theme.spacing(1), - flex: `1 1 ${dimensions.filterFormWidth}`, - }, - button: { - flexGrow: 1, - }, -})); +import useReportStyles from '../common/useReportStyles'; const ReportFilter = ({ children, handleSubmit, showOnly, ignoreDevice, }) => { - const classes = useFilterStyles(); + const classes = useReportStyles(); const t = useTranslation(); const devices = useSelector((state) => state.devices.items); @@ -90,7 +68,7 @@ const ReportFilter = ({ return (
{!ignoreDevice && ( -
+
{t('reportDevice')} setPeriod(e.target.value)}> @@ -116,7 +94,7 @@ const ReportFilter = ({
{period === 'custom' && ( -
+
)} {period === 'custom' && ( -
+
)} {children} -
+