Skip to content

Commit

Permalink
UI fix for succinct eta
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed May 29, 2024
1 parent 7d13e2f commit 67b9cb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
11 changes: 4 additions & 7 deletions src/ErrorFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ interface Props {
error: Error;
}


const ErrorFallback = ({error}: Props) => {

const ErrorFallback = ({ error }: Props) => {
useEffect(() => {
if (error.name === "ChunkLoadError" || error.name === "TypeError") {
setTimeout(() => {
window.location.reload();
}, 500);
}
}, [error])


}, [error]);

if (error.name === "ChunkLoadError" || error.name === "TypeError") {
return (
<div style={{ color: "#fff", fontSize: 18 }}>
Expand All @@ -36,6 +33,6 @@ const ErrorFallback = ({error}: Props) => {
<pre>{error.stack ?? "Unknown error"}</pre>
</div>
);
}
};

export default ErrorFallback;
35 changes: 14 additions & 21 deletions src/components/home/SuccinctEtas.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from "react";
import { Box, ListItemText, SxProps, Theme, Typography } from "@mui/material";
import { Box, SxProps, Theme, Typography } from "@mui/material";
import { useTranslation } from "react-i18next";
import { useEtas } from "../../hooks/useEtas";
import AppContext from "../../context/AppContext";
Expand Down Expand Up @@ -107,21 +107,17 @@ const SuccinctEtas = ({
};

return (
<ListItemText
primary={
<Typography component="h5" color="textPrimary" sx={primarySx}>
{etas ? getEtaString(etas[0], 0, true) : ""}
</Typography>
}
secondary={
<Typography variant="h6" color="textSecondary" sx={secondarySx}>
{etas ? getEtaString(etas[1], 1) : ""}
<br />
{etas ? getEtaString(etas[2], 2) : ""}
</Typography>
}
sx={rootSx}
/>
<Box display="flex" flexDirection="column" textAlign="right">
<Typography component="h5" color="textPrimary" sx={primarySx}>
{etas ? getEtaString(etas[0], 0, true) : ""}
</Typography>
<Typography component="h6" color="textSecondary" sx={secondarySx}>
{etas ? getEtaString(etas[1], 1) : ""}
</Typography>
<Typography component="h6" color="textSecondary" sx={secondarySx}>
{etas ? getEtaString(etas[2], 2) : ""}
</Typography>
</Box>
);
};

Expand Down Expand Up @@ -158,16 +154,13 @@ export const DoubleTrainIcon = () => (

export default SuccinctEtas;

const rootSx: SxProps<Theme> = {
textAlign: "right",
};

const primarySx: SxProps<Theme> = {
whiteSpace: "nowrap",
fontSize: "1em",
};

const secondarySx: SxProps<Theme> = {
fontSize: "0.875rem !important",
fontSize: "0.875em",
fontWeight: "400",
lineHeight: "1.43",
whiteSpace: "nowrap",
Expand Down

0 comments on commit 67b9cb7

Please sign in to comment.