Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(board): added clock to board #1102

Merged
merged 8 commits into from
Jul 6, 2023
2 changes: 1 addition & 1 deletion next-tavla/pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function BoardPage({ settings }: { settings: TSettings }) {
return (
<div className={classes.root} data-theme={settings.theme || 'dark'}>
<div className={classes.rootContainer}>
<Header theme={settings.theme} />
<Header theme={settings.theme} showClock={true} />
<Board settings={settings} />
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions next-tavla/src/Board/scenarios/Table/components/Clock/index.tsx
vildeopp marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useEffect, useState } from 'react'
import classes from './styles.module.css'

function Clock() {
const [currentTime, setCurrentTime] = useState(Date.now())

useEffect(() => {
const intervalId = setInterval(() => setCurrentTime(Date.now()), 1000)
return () => clearInterval(intervalId)
}, [])

const time = new Intl.DateTimeFormat('no-NB', {
timeStyle: 'short',
timeZone: 'Europe/Oslo',
}).format(currentTime)

return <span className={classes.clock}>{time}</span>
}

export { Clock }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.clock {
color: var(--main-text-color);
vildeopp marked this conversation as resolved.
Show resolved Hide resolved
}
50 changes: 29 additions & 21 deletions next-tavla/src/Shared/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,38 @@ import TavlaLogoLight from 'assets/logos/Tavla-blue.svg'
import Image from 'next/image'
import classes from './styles.module.css'
import { TTheme } from 'types/settings'
import { Clock } from 'Board/scenarios/Table/components/Clock'

function Header({ theme }: { theme?: TTheme }) {
function Header({ theme, showClock }: { theme?: TTheme; showClock?: boolean }) {
return (
<div>
{theme === 'light' ? (
<Image
src={TavlaLogoLight}
alt="Entur Tavla logo"
width={117}
height={20}
className={classes.logo}
/>
) : (
<Image
src={TavlaLogo}
alt="Entur Tavla logo"
width={117}
height={20}
className={classes.logo}
/>
<div className={classes.headerWrapper}>
<div className={classes.logoWrapper}>
vildeopp marked this conversation as resolved.
Show resolved Hide resolved
{theme === 'light' ? (
<Image
src={TavlaLogoLight}
alt="Entur Tavla logo"
width={117}
height={20}
className={classes.logo}
/>
) : (
<Image
src={TavlaLogo}
alt="Entur Tavla logo"
width={117}
height={20}
className={classes.logo}
/>
)}
<p className={classes.tagText}>
Finn din rute på entur.no eller i Entur-appen
</p>
</div>
{showClock && (
<div className={classes.clockWrapper}>
<Clock />
</div>
vildeopp marked this conversation as resolved.
Show resolved Hide resolved
)}
<p className={classes.tagText}>
Finn din rute på entur.no eller i Entur-appen
</p>
</div>
)
}
Expand Down
7 changes: 7 additions & 0 deletions next-tavla/src/Shared/components/Header/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
.tagText {
font-size: 0.5em;
color: var(--main-text-color);
margin: 0;
}
.headerWrapper {
vildeopp marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}