From 28fae929b2d709b398f7046c13a16cd72534e938 Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Sun, 23 May 2021 17:21:15 +0200 Subject: [PATCH] last min fixes --- app.js | 18 +++++++--- index.html | 4 +-- src/components/Chat/index.js | 8 ++--- src/components/Chat/styles.js | 24 ++++++++++---- src/components/Info/index.js | 8 +++-- src/components/Info/styles.js | 5 +-- src/components/Logo/index.js | 4 ++- src/components/Text/index.js | 4 +-- src/components/Video/index.js | 10 ++++-- src/components/Video/styles.js | 42 +++++++++++++++++++++++ src/components/VideoOverlay/index.js | 48 +++++++++++++++++++++------ src/components/VideoOverlay/styles.js | 23 +++++++------ src/data/strings.js | 1 + 13 files changed, 151 insertions(+), 48 deletions(-) diff --git a/app.js b/app.js index 931db1f..df75cc2 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,7 @@ import { h } from 'preact' import { useState, useEffect } from 'preact/hooks' import { isWithinInterval, subHours } from 'date-fns' +import { zonedTimeToUtc, utcToZonedTime, format } from 'date-fns-tz' import { addHours } from 'date-fns/esm' import Video from './src/components/Video' @@ -23,18 +24,27 @@ export default () => { useEffect(() => { if (data && data.length) { data.forEach((stream, index) => { + const utcStartDate = zonedTimeToUtc( + new Date(stream.start), + 'Europe/Berlin' + ) + const utcEndDate = zonedTimeToUtc(new Date(stream.end), 'Europe/Berlin') + const { timeZone } = Intl.DateTimeFormat().resolvedOptions() + + const zonedStartDate = utcToZonedTime(utcStartDate, timeZone) + const zonedEndDate = utcToZonedTime(utcEndDate, timeZone) if ( isWithinInterval(new Date(), { - start: subHours(stream.start, 1), - end: addHours(stream.end, 1), + start: subHours(zonedStartDate, 1), + end: addHours(zonedEndDate, 1), }) ) { setCurrentVideo(stream) } if ( isWithinInterval(new Date(), { - start: stream.start, - end: stream.end, + start: zonedStartDate, + end: zonedEndDate, }) ) { setStreamIsLive(true) diff --git a/index.html b/index.html index a4671cd..7172f23 100644 --- a/index.html +++ b/index.html @@ -37,7 +37,7 @@ /> @@ -47,7 +47,7 @@ /> diff --git a/src/components/Chat/index.js b/src/components/Chat/index.js index da07da6..106cd83 100644 --- a/src/components/Chat/index.js +++ b/src/components/Chat/index.js @@ -13,11 +13,11 @@ import { } from './styles' import { colours } from '../../assets/theme' -const Chat = ({}) => { +const Chat = ({ overlayActive }) => { const { width, height } = useWindowDimensions() const [chatIsOpen, toggleChatOpen] = useToggle(true) return chatIsOpen ? ( - +