Skip to content

Commit

Permalink
refactor: Change makeHtmlErrorPage theme param from string to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Ldoppea committed Jul 25, 2023
1 parent 25294a0 commit 91415ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/app/view/Error/Pages/GenericErrorPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ErrorPageGenerator,
ErrorPageGeneratorArguments,
Theme,
makeHtmlErrorPage
} from '/app/view/Error/Pages/makeHtmlErrorPage'
import { t } from '/locales/i18n'
Expand All @@ -27,5 +28,5 @@ export const GenericErrorPage: ErrorPageGenerator = ({
backgroundColor,
errorDetails: error?.details,
reset: true,
invertedTheme: false
theme: Theme.light
})
14 changes: 10 additions & 4 deletions src/app/view/Error/Pages/makeHtmlErrorPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { getDimensions } from '/libs/dimensions'
import { themeCss } from '/screens/login/components/assets/common/css/cssTheme'
import { t } from '/locales/i18n'

export enum Theme {
light,
inverted
}

export interface ErrorPageGeneratorArguments {
backgroundColor?: string
error?: {
Expand Down Expand Up @@ -51,7 +56,7 @@ interface MakeErrorPageProps {
reset?: boolean
backgroundColor?: string
errorDetails?: string
invertedTheme?: boolean
theme?: Theme
}

export const makeHtmlErrorPage = ({
Expand All @@ -63,13 +68,14 @@ export const makeHtmlErrorPage = ({
reset,
backgroundColor,
errorDetails,
invertedTheme = true
theme = Theme.inverted
}: MakeErrorPageProps): string => {
const dimensions = getDimensions()
const navbarHeight = dimensions.navbarHeight
const statusBarHeight = dimensions.statusBarHeight

const theme = invertedTheme ? 'theme-inverted' : 'theme-light'
const themeString =
theme === Theme.inverted ? 'theme-inverted' : 'theme-light'

return `
<!DOCTYPE html>
Expand Down Expand Up @@ -100,7 +106,7 @@ export const makeHtmlErrorPage = ({
</style>
</head>
<body class="${theme}" style="padding-top: ${statusBarHeight}px; padding-bottom: ${navbarHeight}px;">
<body class="${themeString}" style="padding-top: ${statusBarHeight}px; padding-bottom: ${navbarHeight}px;">
<main class="wrapper">
<header class="wrapper-top d-flex flex-row align-items-center">${
header ? headerTemplate : ''
Expand Down

0 comments on commit 91415ee

Please sign in to comment.