Merge a0251229f6 into 8035521268
commit
15f6b96ed1
|
|
@ -1,11 +1,13 @@
|
|||
import { Container, Group, Image } from '@mantine/core'
|
||||
import { Container, Group, Image, useComputedColorScheme } from '@mantine/core'
|
||||
import classes from '@/styles/Header.module.css'
|
||||
import { pageConfig } from '@/uptime.config'
|
||||
import { PageConfigLink } from '@/types/config'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { getLogo } from '@/util/colorScheme'
|
||||
|
||||
export default function Header({ style }: { style?: React.CSSProperties }) {
|
||||
const { t } = useTranslation('common')
|
||||
const colorScheme = useComputedColorScheme('light', { getInitialValueInEffect: false })
|
||||
const linkToElement = (link: PageConfigLink, i: number) => {
|
||||
return (
|
||||
<a
|
||||
|
|
@ -31,7 +33,7 @@ export default function Header({ style }: { style?: React.CSSProperties }) {
|
|||
target={location.pathname == '/' ? '_blank' : undefined}
|
||||
>
|
||||
<Image
|
||||
src={pageConfig.logo ?? '/logo.svg'}
|
||||
src={getLogo(pageConfig, colorScheme)}
|
||||
h={56}
|
||||
w={{ base: 140, sm: 190 }}
|
||||
fit="contain"
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ import type { AppProps } from 'next/app'
|
|||
import { MantineProvider } from '@mantine/core'
|
||||
import NoSsr from '@/components/NoSsr'
|
||||
import '@/util/i18n'
|
||||
import { pageConfig } from '@/uptime.config'
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<NoSsr>
|
||||
<MantineProvider defaultColorScheme="auto">
|
||||
<MantineProvider defaultColorScheme={pageConfig.colorScheme ?? 'auto'}>
|
||||
<Component {...pageProps} />
|
||||
</MantineProvider>
|
||||
</NoSsr>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { Html, Head, Main, NextScript } from 'next/document'
|
||||
import { ColorSchemeScript } from '@mantine/core'
|
||||
import { pageConfig } from '@/uptime.config'
|
||||
|
||||
export default function Document() {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head>
|
||||
<ColorSchemeScript defaultColorScheme="auto" />
|
||||
<ColorSchemeScript defaultColorScheme={pageConfig.colorScheme ?? 'auto'} />
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
|
|
|||
|
|
@ -4,12 +4,21 @@ import { Inter } from 'next/font/google'
|
|||
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
|
||||
import { maintenances, pageConfig } from '@/uptime.config'
|
||||
import Header from '@/components/Header'
|
||||
import { Box, Button, Center, Container, Group, Select } from '@mantine/core'
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Container,
|
||||
Group,
|
||||
Select,
|
||||
useComputedColorScheme,
|
||||
} from '@mantine/core'
|
||||
import Footer from '@/components/Footer'
|
||||
import { useEffect, useState } from 'react'
|
||||
import MaintenanceAlert from '@/components/MaintenanceAlert'
|
||||
import NoIncidentsAlert from '@/components/NoIncidents'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { getFavicon } from '@/util/colorScheme'
|
||||
|
||||
export const runtime = 'experimental-edge'
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
|
@ -56,6 +65,8 @@ function getPrevNextMonth(monthStr: string) {
|
|||
|
||||
export default function IncidentsPage({ monitors }: { monitors: MonitorTarget[] }) {
|
||||
const { t } = useTranslation('common')
|
||||
const colorScheme = useComputedColorScheme('light', { getInitialValueInEffect: false })
|
||||
const favicon = getFavicon(pageConfig, colorScheme)
|
||||
const [selectedMonitor, setSelectedMonitor] = useState<string | null>('')
|
||||
const [selectedMonth, setSelectedMonth] = useState(getSelectedMonth())
|
||||
|
||||
|
|
@ -84,7 +95,7 @@ export default function IncidentsPage({ monitors }: { monitors: MonitorTarget[]
|
|||
<>
|
||||
<Head>
|
||||
<title>{pageConfig.title}</title>
|
||||
<link rel="icon" href={pageConfig.favicon ?? '/favicon.png'} />
|
||||
<link rel="icon" href={favicon} />
|
||||
</Head>
|
||||
|
||||
<main className={inter.className}>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ import { maintenances, pageConfig } from '@/uptime.config'
|
|||
import OverallStatus from '@/components/OverallStatus'
|
||||
import Header from '@/components/Header'
|
||||
import MonitorList from '@/components/MonitorList'
|
||||
import { Center, Text } from '@mantine/core'
|
||||
import { Center, Text, useComputedColorScheme } from '@mantine/core'
|
||||
import MonitorDetail from '@/components/MonitorDetail'
|
||||
import Footer from '@/components/Footer'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CompactedMonitorStateWrapper, getFromStore } from '@/worker/src/store'
|
||||
import { getFavicon } from '@/util/colorScheme'
|
||||
|
||||
export const runtime = 'experimental-edge'
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
|
@ -25,6 +26,14 @@ export default function Home({
|
|||
statusPageLink?: string
|
||||
}) {
|
||||
const { t } = useTranslation('common')
|
||||
const colorScheme = useComputedColorScheme('light', { getInitialValueInEffect: false })
|
||||
const favicon = getFavicon(pageConfig, colorScheme)
|
||||
const pageHead = (
|
||||
<Head>
|
||||
<title>{pageConfig.title}</title>
|
||||
<link rel="icon" href={favicon} />
|
||||
</Head>
|
||||
)
|
||||
let state = new CompactedMonitorStateWrapper(compactedStateStr).uncompact()
|
||||
|
||||
// Specify monitorId in URL hash to view a specific monitor (can be used in iframe)
|
||||
|
|
@ -32,21 +41,26 @@ export default function Home({
|
|||
if (monitorId) {
|
||||
const monitor = monitors.find((monitor) => monitor.id === monitorId)
|
||||
if (!monitor || !state) {
|
||||
return <Text fw={700}>{t('Monitor not found', { id: monitorId })}</Text>
|
||||
return (
|
||||
<>
|
||||
{pageHead}
|
||||
<Text fw={700}>{t('Monitor not found', { id: monitorId })}</Text>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div style={{ maxWidth: '810px' }}>
|
||||
<MonitorDetail monitor={monitor} state={state} />
|
||||
</div>
|
||||
<>
|
||||
{pageHead}
|
||||
<div style={{ maxWidth: '810px' }}>
|
||||
<MonitorDetail monitor={monitor} state={state} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{pageConfig.title}</title>
|
||||
<link rel="icon" href={pageConfig.favicon ?? '/favicon.png'} />
|
||||
</Head>
|
||||
{pageHead}
|
||||
|
||||
<main className={inter.className}>
|
||||
<Header />
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ export type PageConfig = {
|
|||
title?: string
|
||||
links?: PageConfigLink[]
|
||||
group?: PageConfigGroup
|
||||
colorScheme?: 'auto' | 'light' | 'dark'
|
||||
favicon?: string
|
||||
darkFavicon?: string
|
||||
logo?: string
|
||||
darkLogo?: string
|
||||
maintenances?: {
|
||||
upcomingColor?: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,19 @@ const pageConfig: PageConfig = {
|
|||
'🌐 Public (example group name)': ['foo_monitor', 'bar_monitor', 'more monitor ids...'],
|
||||
'🔐 Private': ['test_tcp_monitor'],
|
||||
},
|
||||
// [OPTIONAL] Set the color scheme to 'auto', 'light', or 'dark'
|
||||
// Defaults to 'auto', which follows the system color scheme
|
||||
// colorScheme: 'auto',
|
||||
// [OPTIONAL] Set the path to your favicon, default to '/favicon.png' if not specified
|
||||
// favicon: 'https://example.com/favicon.ico',
|
||||
// [OPTIONAL] Set a separate favicon for dark mode
|
||||
// Falls back to `favicon` when omitted
|
||||
// darkFavicon: 'https://example.com/favicon-dark.ico',
|
||||
// [OPTIONAL] Set the path to your logo, default to '/logo.svg' if not specified
|
||||
// logo: 'https://example.com/logo.svg',
|
||||
// [OPTIONAL] Set a separate logo for dark mode
|
||||
// Falls back to `logo` when omitted
|
||||
// darkLogo: 'https://example.com/logo-dark.svg',
|
||||
// [OPTIONAL] Maintenance related settings
|
||||
maintenances: {
|
||||
// [OPTIONAL] The color of upcoming maintenance alerts, default to 'gray'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import { PageConfig } from '@/types/config'
|
||||
|
||||
type ComputedColorScheme = 'light' | 'dark'
|
||||
|
||||
export function getLogo(pageConfig: PageConfig, colorScheme: ComputedColorScheme) {
|
||||
return colorScheme === 'dark'
|
||||
? pageConfig.darkLogo ?? pageConfig.logo ?? '/logo.svg'
|
||||
: pageConfig.logo ?? '/logo.svg'
|
||||
}
|
||||
|
||||
export function getFavicon(pageConfig: PageConfig, colorScheme: ComputedColorScheme) {
|
||||
return colorScheme === 'dark'
|
||||
? pageConfig.darkFavicon ?? pageConfig.favicon ?? '/favicon.png'
|
||||
: pageConfig.favicon ?? '/favicon.png'
|
||||
}
|
||||
Loading…
Reference in New Issue