wip: frontend header & overall status
This commit is contained in:
1 parent
cdd43685f2
commit
f9212c88a6
13 files changed
+1002
-403
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { useState } from 'react';
|
||||
import { Container, Group, Burger } from '@mantine/core';
|
||||
import { useDisclosure } from '@mantine/hooks';
|
||||
import { MantineLogo } from '@mantine/ds';
|
||||
import classes from '@/styles/Header.module.css';
|
||||
|
||||
const links = [
|
||||
{ link: '/about', label: 'Features' },
|
||||
{ link: '/pricing', label: 'Pricing' },
|
||||
{ link: '/learn', label: 'Learn' },
|
||||
{ link: '/community', label: 'Community' },
|
||||
];
|
||||
|
||||
export default function Header() {
|
||||
const [opened, { toggle }] = useDisclosure(false);
|
||||
const [active, setActive] = useState(links[0].link);
|
||||
|
||||
const items = links.map((link) => (
|
||||
<a
|
||||
key={link.label}
|
||||
href={link.link}
|
||||
className={classes.link}
|
||||
data-active={active === link.link || undefined}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
setActive(link.link);
|
||||
}}
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
));
|
||||
|
||||
return (
|
||||
<header className={classes.header}>
|
||||
<Container size="md" className={classes.inner}>
|
||||
<MantineLogo size={28} />
|
||||
<Group gap={5} visibleFrom="xs">
|
||||
{items}
|
||||
</Group>
|
||||
|
||||
<Burger opened={opened} onClick={toggle} hiddenFrom="xs" size="sm" />
|
||||
</Container>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Center, Space, Title } from '@mantine/core'
|
||||
import { IconCircleCheck, IconAlertCircle } from '@tabler/icons-react'
|
||||
|
||||
export default function OverallStatus({ state }: { state: { overallUp: number, overallDown: number, lastUpdate: number }}) {
|
||||
|
||||
let statusString = ''
|
||||
let icon = <IconAlertCircle style={{ width: 64, height: 64 }} />
|
||||
if (state.overallUp === 0 && state.overallDown === 0) {
|
||||
statusString = 'No data yet'
|
||||
} else if (state.overallUp === 0) {
|
||||
statusString = 'All down'
|
||||
} else if (state.overallDown === 0) {
|
||||
statusString = 'All up'
|
||||
icon = <IconCircleCheck style={{ width: 64, height: 64 }} />
|
||||
} else {
|
||||
statusString = `${state.overallUp} up, ${state.overallDown} down`
|
||||
}
|
||||
|
||||
return (<>
|
||||
<Center>
|
||||
{icon}
|
||||
</Center>
|
||||
<Space h="md"/>
|
||||
<Center>
|
||||
<Title order={1}>{statusString}</Title>
|
||||
</Center>
|
||||
<Center>
|
||||
<Title order={5}>Last updated on: {new Date(state.lastUpdate * 1000).toLocaleString()}</Title>
|
||||
</Center>
|
||||
</>)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user