Skip to content

Commit

Permalink
Merge branch 'master' into 476-analysis-comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboucher authored Jul 18, 2023
2 parents febeaee + d7a00c9 commit 6817f1a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 8 deletions.
2 changes: 0 additions & 2 deletions frontend/src/components/Common/ReportDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const ReportDialog = memo(
showToolbar={false}
>
<ReportDoc
t={t}
exposureLegendDefinition={analysisResult?.legend ?? []}
theme={theme}
tableShowTotal
Expand Down Expand Up @@ -169,7 +168,6 @@ const ReportDialog = memo(
<PDFDownloadLink
document={
<ReportDoc
t={t}
exposureLegendDefinition={analysisResult?.legend ?? []}
theme={theme}
reportTitle={`${t(reportConfig.title)} ${reportDate}`}
Expand Down
27 changes: 21 additions & 6 deletions frontend/src/components/Common/ReportDialog/reportDoc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { memo, useMemo } from 'react';
import {
Document,
Font,
Image,
Page,
StyleSheet,
Expand All @@ -11,20 +12,34 @@ import { Theme } from '@material-ui/core';
import { TableRow as AnalysisTableRow } from 'context/analysisResultStateSlice';
import { getLegendItemLabel } from 'components/MapView/utils';
import { LegendDefinition, ReportType } from 'config/types';
import { TFunction } from 'utils/data-utils';
import { Column } from 'utils/analysis-utils';
import RobotoFont from 'fonts/Roboto-Regular.ttf';
import KhmerFont from 'fonts/Khmer-Regular.ttf';
import { useSafeTranslation } from 'i18n';
import { PDFLegendDefinition } from './types';
import ReportDocLegend from './ReportDocLegend';
import ReportDocTable from './ReportDocTable';
import { getReportFontFamily } from './utils';

const makeStyles = (theme: Theme) =>
// Register all the fonts necessary
Font.register({
family: 'Roboto',
src: RobotoFont,
});

Font.register({
family: 'Khmer',
src: KhmerFont,
});

const makeStyles = (theme: Theme, selectedLanguage: string) =>
StyleSheet.create({
page: {
flexDirection: 'column',
backgroundColor: '#FFF',
paddingBottom: 25,
paddingTop: '1vh',
fontFamily: 'Roboto',
fontFamily: getReportFontFamily(selectedLanguage),
},
section: {
width: '96vw',
Expand Down Expand Up @@ -83,11 +98,12 @@ const ReportDoc = memo(
reportTitle,
reportConfig,
exposureLegendDefinition,
t,
tableData,
columns,
}: ReportDocProps) => {
const styles = makeStyles(theme);
const { t, i18n } = useSafeTranslation();

const styles = makeStyles(theme, i18n.language);

const date = useMemo(() => {
return new Date().toUTCString();
Expand Down Expand Up @@ -272,7 +288,6 @@ interface ReportDocProps {
reportConfig: ReportType;
tableShowTotal: boolean;
exposureLegendDefinition: LegendDefinition;
t: TFunction;
tableData: AnalysisTableRow[];
columns: Column[];
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/Common/ReportDialog/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const getReportFontFamily = (selectedLanguage: string): string => {
switch (selectedLanguage) {
case 'kh':
return 'Khmer';
default:
return 'Roboto';
}
};
1 change: 1 addition & 0 deletions frontend/src/components/MapView/FoldButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const FoldButton = ({
horizontal: 'right',
vertical: 'top',
}}
overlap="rectangular"
badgeContent={badgeContent}
color="secondary"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const LeftPanelTabs = memo(
horizontal: 'left',
vertical: 'top',
}}
overlap="rectangular"
badgeContent={layersBadgeContent}
color="secondary"
>
Expand Down
Binary file added frontend/src/fonts/Khmer-Regular.ttf
Binary file not shown.
Binary file added frontend/src/fonts/Roboto-Regular.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/types/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ declare module 'prism-common';
declare module 'zonal';

declare module 'redux-async-initial-state';

declare module '*.ttf';

0 comments on commit 6817f1a

Please sign in to comment.