Restyle the status page in Cottage's brand

The page (pages/, components/, styles/) is rewritten in Cottage's brand, replacing Mantine.
- Brand files: tokens, fonts and component CSS copied from Hearth; logo, pod row, status
  pill and banner ported from the brand handbook.
- Themes: light by default, dark when the OS asks.
- Services: grouped; each has a status pill, uptime and 90 daily bars (30 on phones).
- Bars: each bar has a text label, keyboard navigation and a day card.
- Response-time chart: optional, drawn in brand colours.
- Notices: colour-coded posted notices and planned maintenance.
- Incident history: by month, with the brand's empty state.

The check worker, D1 storage, types and Terraform are untouched, so upstream merges stay
clean. uptime.config.ts lists Cottage's services (website, dashboard, apps in US East).
`npm run dev` shows sample data (?sample=outage|maintenance|empty) since there's no D1.

Deploys are gated on the CLOUDFLARE_DEPLOY repository variable until launch, Wrangler
telemetry is off, and a Check workflow lints, type-checks and builds every pull request.
Removed upstream's issue-translation workflow, funding file and translations.
This commit is contained in:
Michael Kinder committed 2026-11-21 14:04:00 -05:00
1 parent 8035521268
commit fdc16007e3
54 files changed
+2197 -2705

No files matched your search

+5 -6
View File
@@ -1,15 +1,14 @@
import '@mantine/core/styles.css'
import type { AppProps } from 'next/app'
import { MantineProvider } from '@mantine/core'
import NoSsr from '@/components/NoSsr'
import '@/util/i18n'
import '@/styles/brand/fonts.css'
import '@/styles/brand/tokens.css'
import '@/styles/brand/bundle.css'
import '@/styles/status.css'
export default function App({ Component, pageProps }: AppProps) {
return (
<NoSsr>
<MantineProvider defaultColorScheme="auto">
<Component {...pageProps} />
</MantineProvider>
<Component {...pageProps} />
</NoSsr>
)
}
+10 -3
View File
@@ -1,11 +1,18 @@
import { Html, Head, Main, NextScript } from 'next/document'
import { ColorSchemeScript } from '@mantine/core'
// Cottage is light-first; dark ("evening") follows the OS setting. The tokens switch on
// data-theme, set here before first paint so there's no flash.
const themeScript = `(function(){var m=window.matchMedia('(prefers-color-scheme: dark)');function s(){document.documentElement.setAttribute('data-theme',m.matches?'dark':'light')}s();m.addEventListener('change',s)})()`
export default function Document() {
return (
<Html lang="en">
<Html lang="en" data-theme="light">
<Head>
<ColorSchemeScript defaultColorScheme="auto" />
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
<link rel="preload" href="/fonts/HankenGrotesk-400-700.woff2" as="font" type="font/woff2" crossOrigin="anonymous" />
<link rel="preload" href="/fonts/Fraunces-400-700.woff2" as="font" type="font/woff2" crossOrigin="anonymous" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<meta name="color-scheme" content="light dark" />
</Head>
<body>
<Main />
+101 -118
View File
@@ -1,144 +1,127 @@
import Head from 'next/head'
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 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 { MaintenanceConfig, MonitorTarget } from '@/types/config'
import { maintenances as configMaintenances, pageConfig } from '@/uptime.config'
import Header from '@/components/Header'
import Footer from '@/components/Footer'
import Notice from '@/components/Notice'
import { EmptyState } from '@/components/brand'
export const runtime = 'experimental-edge'
const inter = Inter({ subsets: ['latin'] })
function getSelectedMonth() {
const monthKey = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`
function selectedMonth() {
const hash = window.location.hash.replace('#', '')
if (!hash) {
const now = new Date()
return now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0')
}
return hash.split('-').splice(0, 2).join('-')
return /^\d{4}-\d{2}$/.test(hash) ? hash : monthKey(new Date())
}
function filterIncidentsByMonth(
incidents: MaintenanceConfig[],
monthStr: string,
function shift(month: string, by: number) {
const [y, m] = month.split('-').map(Number)
return monthKey(new Date(y, m - 1 + by))
}
function monthName(month: string) {
const [y, m] = month.split('-').map(Number)
return new Date(y, m - 1).toLocaleDateString(undefined, { month: 'long', year: 'numeric' })
}
export default function Incidents({
monitors,
maintenances,
}: {
monitors: MonitorTarget[]
): (Omit<MaintenanceConfig, 'monitors'> & { monitors: MonitorTarget[] })[] {
return incidents
.filter((incident) => {
const d = new Date(incident.start)
const incidentMonth = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0')
return incidentMonth === monthStr
})
.map((e) => ({
...e,
monitors: (e.monitors || []).map((e) => monitors.find((mon) => mon.id === e)!),
}))
.sort((a, b) => (new Date(a.start) > new Date(b.start) ? -1 : 1))
}
function getPrevNextMonth(monthStr: string) {
const [year, month] = monthStr.split('-').map(Number)
const date = new Date(year, month - 1)
const prev = new Date(date)
prev.setMonth(prev.getMonth() - 1)
const next = new Date(date)
next.setMonth(next.getMonth() + 1)
return {
prev: prev.getFullYear() + '-' + String(prev.getMonth() + 1).padStart(2, '0'),
next: next.getFullYear() + '-' + String(next.getMonth() + 1).padStart(2, '0'),
}
}
export default function IncidentsPage({ monitors }: { monitors: MonitorTarget[] }) {
const { t } = useTranslation('common')
const [selectedMonitor, setSelectedMonitor] = useState<string | null>('')
const [selectedMonth, setSelectedMonth] = useState(getSelectedMonth())
maintenances: MaintenanceConfig[]
}) {
const [month, setMonth] = useState(selectedMonth)
const [service, setService] = useState('')
useEffect(() => {
const onHashChange = () => setSelectedMonth(getSelectedMonth())
window.addEventListener('hashchange', onHashChange)
return () => window.removeEventListener('hashchange', onHashChange)
const onHash = () => setMonth(selectedMonth())
window.addEventListener('hashchange', onHash)
return () => window.removeEventListener('hashchange', onHash)
}, [])
const filteredIncidents = filterIncidentsByMonth(maintenances, selectedMonth, monitors)
const monitorFilteredIncidents = selectedMonitor
? filteredIncidents.filter((i) => i.monitors.find((e) => e.id === selectedMonitor))
: filteredIncidents
const { prev, next } = getPrevNextMonth(selectedMonth)
const monitorOptions = [
{ value: '', label: t('All') },
...monitors.map((monitor) => ({
value: monitor.id,
label: monitor.name,
})),
]
const list = maintenances
.filter((n) => monthKey(new Date(n.start)) === month)
.filter((n) => !service || n.monitors?.includes(service))
.sort((a, b) => +new Date(b.start) - +new Date(a.start))
const isCurrentMonth = month === monthKey(new Date())
return (
<>
<Head>
<title>{pageConfig.title}</title>
<link rel="icon" href={pageConfig.favicon ?? '/favicon.png'} />
<title>{`Incident history · ${pageConfig.title}`}</title>
</Head>
<Header current="incidents" />
<main className="st-main">
<div className="st-container st-container--narrow">
<div className="st-pagehead">
<h1 className="ct-h1">Incident history</h1>
<p className="ct-lede">
Every incident update and planned maintenance we&rsquo;ve posted, by month.
</p>
</div>
<main className={inter.className}>
<Header
style={{
marginBottom: '40px',
}}
/>
<Center>
<Container size="md" style={{ width: '100%' }}>
<Group justify="end" mb="md">
<Select
placeholder={t('Select monitor')}
data={monitorOptions}
value={selectedMonitor}
onChange={setSelectedMonitor}
clearable
style={{ maxWidth: 300, float: 'right' }}
/>
</Group>
<Box>
{monitorFilteredIncidents.length === 0 ? (
<NoIncidentsAlert />
) : (
monitorFilteredIncidents.map((incident, i) => (
<MaintenanceAlert key={i} maintenance={incident} />
))
)}
</Box>
<Group justify="space-between" mt="md">
<Button variant="default" onClick={() => (window.location.hash = prev)}>
{t('Backwards')}
</Button>
<Box style={{ alignSelf: 'center', fontWeight: 500, fontSize: 18 }}>
{selectedMonth}
</Box>
<Button variant="default" onClick={() => (window.location.hash = next)}>
{t('Forward')}
</Button>
</Group>
</Container>
</Center>
<Footer />
<div className="st-toolbar">
<div className="st-monthnav">
<a className="ct-btn ct-btn--secondary ct-btn--sm" href={`#${shift(month, -1)}`} aria-label="Previous month">
<svg viewBox="0 0 16 16" width={16} height={16} aria-hidden>
<path d="M10 4 6 8l4 4" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round" />
</svg>
</a>
<h2 className="st-monthnav__label" aria-live="polite">
{monthName(month)}
</h2>
<a
className={`ct-btn ct-btn--secondary ct-btn--sm${isCurrentMonth ? ' is-disabled' : ''}`}
href={isCurrentMonth ? undefined : `#${shift(month, 1)}`}
aria-label="Next month"
aria-disabled={isCurrentMonth}
>
<svg viewBox="0 0 16 16" width={16} height={16} aria-hidden>
<path d="m6 4 4 4-4 4" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round" />
</svg>
</a>
</div>
<label className="st-select">
<span className="st-visually-hidden">Service</span>
<select value={service} onChange={(e) => setService(e.target.value)}>
<option value="">All services</option>
{monitors.map((m) => (
<option key={m.id} value={m.id}>
{m.name}
</option>
))}
</select>
</label>
</div>
{list.length === 0 ? (
<EmptyState title={`Nothing to report for ${monthName(month)}`}>
We post here whenever something affects Cottage, and before planned maintenance.
Short blips our checks caught show on each service&rsquo;s uptime bars.
</EmptyState>
) : (
<div className="st-notices">
{list.map((n, i) => (
<Notice key={i} notice={n} monitors={monitors} upcoming={new Date(n.start) > new Date()} />
))}
</div>
)}
</div>
</main>
<Footer />
</>
)
}
export async function getServerSideProps() {
export async function getServerSideProps({ query }: { query: Record<string, string | string[] | undefined> }) {
const { workerConfig } = await import('@/uptime.config')
// Only present these values to client
const monitors: MonitorTarget[] = workerConfig.monitors.map((monitor) => ({
id: monitor.id,
name: monitor.name,
})) as MonitorTarget[]
return { props: { monitors } }
const monitors = workerConfig.monitors.map((m) => ({ id: m.id, name: m.name }))
if (process.env.NODE_ENV === 'development' && !(process.env as any).UPTIMEFLARE_D1) {
const { sampleNotices } = await import('@/dev/sample')
return { props: { monitors, maintenances: sampleNotices(String(query.sample ?? '')) } }
}
return { props: { monitors, maintenances: configMaintenances } }
}
+46 -56
View File
@@ -1,43 +1,39 @@
import Head from 'next/head'
import { Inter } from 'next/font/google'
import { MonitorTarget } from '@/types/config'
import { maintenances, pageConfig } from '@/uptime.config'
import Link from 'next/link'
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
import { maintenances as configMaintenances, 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 MonitorDetail from '@/components/MonitorDetail'
import Footer from '@/components/Footer'
import { useTranslation } from 'react-i18next'
import UptimeBars from '@/components/UptimeBars'
import { CompactedMonitorStateWrapper, getFromStore } from '@/worker/src/store'
export const runtime = 'experimental-edge'
const inter = Inter({ subsets: ['latin'] })
export default function Home({
compactedStateStr,
monitors,
maintenances,
}: {
compactedStateStr: string
compactedStateStr: string | null
monitors: MonitorTarget[]
tooltip?: string
statusPageLink?: string
maintenances: MaintenanceConfig[]
}) {
const { t } = useTranslation('common')
let state = new CompactedMonitorStateWrapper(compactedStateStr).uncompact()
const state = new CompactedMonitorStateWrapper(compactedStateStr).uncompact()
// Specify monitorId in URL hash to view a specific monitor (can be used in iframe)
// #monitor-id shows one service's bars on its own (for embedding in an iframe).
const monitorId = window.location.hash.substring(1)
if (monitorId) {
const monitor = monitors.find((monitor) => monitor.id === monitorId)
if (!monitor || !state) {
return <Text fw={700}>{t('Monitor not found', { id: monitorId })}</Text>
}
const monitor = monitors.find((m) => m.id === monitorId)
return (
<div style={{ maxWidth: '810px' }}>
<MonitorDetail monitor={monitor} state={state} />
</div>
<main className="st-embed">
{monitor && state.incident[monitor.id] ? (
<UptimeBars monitor={monitor} state={state} />
) : (
<p>No service called &ldquo;{monitorId}&rdquo;.</p>
)}
</main>
)
}
@@ -45,47 +41,41 @@ export default function Home({
<>
<Head>
<title>{pageConfig.title}</title>
<link rel="icon" href={pageConfig.favicon ?? '/favicon.png'} />
<meta name="description" content="Live status of Cottage's website, dashboard and app hosting, checked every minute." />
</Head>
<main className={inter.className}>
<Header />
{state.lastUpdate === 0 ? (
<Center>
<Text fw={700}>{t('Monitor State not defined')}</Text>
</Center>
) : (
<div>
<OverallStatus state={state} monitors={monitors} maintenances={maintenances} />
<MonitorList monitors={monitors} state={state} />
</div>
)}
<Footer />
<Header current="status" />
<main className="st-main">
<div className="st-container st-container--narrow">
<OverallStatus state={state} monitors={monitors} maintenances={maintenances} />
<MonitorList monitors={monitors} state={state} maintenances={maintenances} />
<p className="st-note">
Uptime covers the last 90 days. Planned maintenance and incident updates are listed under{' '}
<Link href="/incidents">Incident history</Link>.
</p>
</div>
</main>
<Footer />
</>
)
}
export async function getServerSideProps() {
export async function getServerSideProps({ query }: { query: Record<string, string | string[] | undefined> }) {
const { workerConfig } = await import('@/uptime.config')
// Read state as string from storage, to avoid hitting server-side cpu time limit
const monitors = workerConfig.monitors.map((m) => ({
id: m.id,
name: m.name,
tooltip: m.tooltip ?? null,
statusPageLink: m.statusPageLink ?? null,
hideLatencyChart: m.hideLatencyChart ?? null,
}))
// `npm run dev` has no D1 database: show sample data instead (dev/sample.ts).
if (process.env.NODE_ENV === 'development' && !(process.env as any).UPTIMEFLARE_D1) {
const { sampleState, sampleNotices } = await import('@/dev/sample')
return { props: { compactedStateStr: sampleState(workerConfig.monitors, String(query.sample ?? '')), monitors, maintenances: sampleNotices(String(query.sample ?? '')) } }
}
// Read the state as a string, so the server stays inside its CPU limit.
const compactedStateStr = await getFromStore(process.env as any, 'state')
// Only present these values to client
const monitors = workerConfig.monitors.map((monitor) => {
return {
id: monitor.id,
name: monitor.name,
// @ts-ignore
tooltip: monitor?.tooltip,
// @ts-ignore
statusPageLink: monitor?.statusPageLink,
// @ts-ignore
hideLatencyChart: monitor?.hideLatencyChart,
}
})
return { props: { compactedStateStr, monitors } }
return { props: { compactedStateStr, monitors, maintenances: configMaintenances } }
}