From bdd216d881abc343c2d46dfbe0c64cd890a0c730 Mon Sep 17 00:00:00 2001 From: Carlos Valente <34649812+cpvalente@users.noreply.github.com> Date: Wed, 22 Nov 2023 21:38:35 +0100 Subject: [PATCH 01/14] feat: customise timer elements (#607) * feat: customise timer elements --- .../view-params-editor/constants.ts | 34 ++++- .../src/features/viewers/timer/Timer.tsx | 141 +++++++++++------- 2 files changed, 123 insertions(+), 52 deletions(-) diff --git a/apps/client/src/common/components/view-params-editor/constants.ts b/apps/client/src/common/components/view-params-editor/constants.ts index 3021edb6e..bcb7c363e 100644 --- a/apps/client/src/common/components/view-params-editor/constants.ts +++ b/apps/client/src/common/components/view-params-editor/constants.ts @@ -70,7 +70,39 @@ export const CLOCK_OPTIONS: ParamField[] = [ }, ]; -export const TIMER_OPTIONS: ParamField[] = [TIME_FORMAT_OPTION]; +export const TIMER_OPTIONS: ParamField[] = [ + TIME_FORMAT_OPTION, + { + id: 'hideClock', + title: 'Hide Time Now', + description: 'Hides the Time Now field', + type: 'boolean', + }, + { + id: 'hideCards', + title: 'Hide Cards', + description: 'Hides the Now and Next cards', + type: 'boolean', + }, + { + id: 'hideProgress', + title: 'Hide progress bar', + description: 'Hides the progress bar', + type: 'boolean', + }, + { + id: 'hideMessage', + title: 'Hide Presenter Message', + description: 'Prevents the screen from displaying messages from the presenter', + type: 'boolean', + }, + { + id: 'hideExternal', + title: 'Hide External', + description: 'Prevents the screen from displaying the external field', + type: 'boolean', + }, +]; export const MINIMAL_TIMER_OPTIONS: ParamField[] = [ { diff --git a/apps/client/src/features/viewers/timer/Timer.tsx b/apps/client/src/features/viewers/timer/Timer.tsx index f40f0c31e..e0f1a9c6e 100644 --- a/apps/client/src/features/viewers/timer/Timer.tsx +++ b/apps/client/src/features/viewers/timer/Timer.tsx @@ -1,4 +1,5 @@ import { useEffect } from 'react'; +import { useSearchParams } from 'react-router-dom'; import { AnimatePresence, motion } from 'framer-motion'; import { Message, OntimeEvent, Playback, TimerMessage, TimerType, ViewSettings } from 'ontime-types'; @@ -11,6 +12,7 @@ import ViewParamsEditor from '../../../common/components/view-params-editor/View import { useRuntimeStylesheet } from '../../../common/hooks/useRuntimeStylesheet'; import { TimeManagerType } from '../../../common/models/TimeManager.type'; import { formatTime } from '../../../common/utils/time'; +import { isStringBoolean } from '../../../common/utils/viewUtils'; import { useTranslation } from '../../../translation/TranslationProvider'; import SuperscriptTime from '../common/superscript-time/SuperscriptTime'; import { formatTimerDisplay, getTimerByType } from '../common/viewerUtils'; @@ -52,6 +54,8 @@ export default function Timer(props: TimerProps) { const { isMirrored, pres, eventNow, eventNext, time, viewSettings, external } = props; const { shouldRender } = useRuntimeStylesheet(viewSettings?.overrideStyles && overrideStylesURL); const { getLocalizedString } = useTranslation(); + const [searchParams] = useSearchParams(); + useEffect(() => { document.title = 'ontime - Timer'; }, []); @@ -61,6 +65,26 @@ export default function Timer(props: TimerProps) { return null; } + // USER OPTIONS + const userOptions = { + hideClock: false, + hideCards: false, + hideProgress: false, + hideMessage: false, + }; + + const hideClock = searchParams.get('hideClock'); + userOptions.hideClock = isStringBoolean(hideClock); + + const hideCards = searchParams.get('hideCards'); + userOptions.hideCards = isStringBoolean(hideCards); + + const hideProgress = searchParams.get('hideProgress'); + userOptions.hideProgress = isStringBoolean(hideProgress); + + const hideMessage = searchParams.get('hideMessage'); + userOptions.hideMessage = isStringBoolean(hideMessage); + const clock = formatTime(time.clock, formatOptions); const showOverlay = pres.text !== '' && pres.visible; const isPlaying = time.playback !== Playback.Pause; @@ -108,14 +132,18 @@ export default function Timer(props: TimerProps) {
-
-
{pres.text}
-
+ {!userOptions.hideMessage && ( +
+
{pres.text}
+
+ )} -
-
{getLocalizedString('common.time_now')}
- -
+ {!userOptions.hideClock && ( +
+
{getLocalizedString('common.time_now')}
+ +
+ )}
{showEndMessage ? ( @@ -139,52 +167,63 @@ export default function Timer(props: TimerProps) {
-