mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 15:09:10 +00:00
feat: add time type none
This commit is contained in:
committed by
Carlos Valente
parent
7ccd41eeee
commit
0d8c186c77
@@ -90,6 +90,7 @@ export default function EditorSettingsForm() {
|
|||||||
<option value={TimerType.CountUp}>Count up</option>
|
<option value={TimerType.CountUp}>Count up</option>
|
||||||
<option value={TimerType.TimeToEnd}>Time to end</option>
|
<option value={TimerType.TimeToEnd}>Time to end</option>
|
||||||
<option value={TimerType.Clock}>Clock</option>
|
<option value={TimerType.Clock}>Clock</option>
|
||||||
|
<option value={TimerType.None}>None</option>
|
||||||
</Select>
|
</Select>
|
||||||
</Panel.ListItem>
|
</Panel.ListItem>
|
||||||
<Panel.ListItem>
|
<Panel.ListItem>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { Tooltip } from '@chakra-ui/react';
|
||||||
import { IoArrowDown } from '@react-icons/all-files/io5/IoArrowDown';
|
import { IoArrowDown } from '@react-icons/all-files/io5/IoArrowDown';
|
||||||
import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp';
|
import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp';
|
||||||
|
import { IoBan } from '@react-icons/all-files/io5/IoBan';
|
||||||
import { IoFlag } from '@react-icons/all-files/io5/IoFlag';
|
import { IoFlag } from '@react-icons/all-files/io5/IoFlag';
|
||||||
import { IoTime } from '@react-icons/all-files/io5/IoTime';
|
import { IoTime } from '@react-icons/all-files/io5/IoTime';
|
||||||
import { TimerPhase, TimerType } from 'ontime-types';
|
import { TimerPhase, TimerType } from 'ontime-types';
|
||||||
@@ -8,7 +9,7 @@ import { TimerPhase, TimerType } from 'ontime-types';
|
|||||||
import { useMessagePreview } from '../../../common/hooks/useSocket';
|
import { useMessagePreview } from '../../../common/hooks/useSocket';
|
||||||
import useViewSettings from '../../../common/hooks-query/useViewSettings';
|
import useViewSettings from '../../../common/hooks-query/useViewSettings';
|
||||||
import { handleLinks } from '../../../common/utils/linkUtils';
|
import { handleLinks } from '../../../common/utils/linkUtils';
|
||||||
import { cx } from '../../../common/utils/styleUtils';
|
import { cx, timerPlaceholder } from '../../../common/utils/styleUtils';
|
||||||
import { tooltipDelayMid } from '../../../ontimeConfig';
|
import { tooltipDelayMid } from '../../../ontimeConfig';
|
||||||
import { Corner } from '../../editors/editor-utils/EditorUtils';
|
import { Corner } from '../../editors/editor-utils/EditorUtils';
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ export default function TimerPreview() {
|
|||||||
if (phase === TimerPhase.Pending) return 'Standby to start';
|
if (phase === TimerPhase.Pending) return 'Standby to start';
|
||||||
if (phase === TimerPhase.Overtime && data.endMessage) return 'Custom end message';
|
if (phase === TimerPhase.Overtime && data.endMessage) return 'Custom end message';
|
||||||
if (timerType === TimerType.TimeToEnd) return 'Time to end';
|
if (timerType === TimerType.TimeToEnd) return 'Time to end';
|
||||||
|
if (timerType === TimerType.None) return timerPlaceholder;
|
||||||
return 'Timer';
|
return 'Timer';
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -74,6 +76,9 @@ export default function TimerPreview() {
|
|||||||
<Tooltip label='Time type: Time to end' openDelay={tooltipDelayMid} shouldWrapChildren>
|
<Tooltip label='Time type: Time to end' openDelay={tooltipDelayMid} shouldWrapChildren>
|
||||||
<IoFlag className={style.statusIcon} data-active={timerType === TimerType.TimeToEnd} />
|
<IoFlag className={style.statusIcon} data-active={timerType === TimerType.TimeToEnd} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<Tooltip label='Time type: None' openDelay={tooltipDelayMid} shouldWrapChildren>
|
||||||
|
<IoBan className={style.statusIcon} data-active={timerType === TimerType.None} />
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { memo, useEffect, useState } from 'react';
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { Tooltip } from '@chakra-ui/react';
|
||||||
import { IoArrowDown } from '@react-icons/all-files/io5/IoArrowDown';
|
import { IoArrowDown } from '@react-icons/all-files/io5/IoArrowDown';
|
||||||
import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp';
|
import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp';
|
||||||
|
import { IoBan } from '@react-icons/all-files/io5/IoBan';
|
||||||
import { IoFlag } from '@react-icons/all-files/io5/IoFlag';
|
import { IoFlag } from '@react-icons/all-files/io5/IoFlag';
|
||||||
import { IoPeople } from '@react-icons/all-files/io5/IoPeople';
|
import { IoPeople } from '@react-icons/all-files/io5/IoPeople';
|
||||||
import { IoPlay } from '@react-icons/all-files/io5/IoPlay';
|
import { IoPlay } from '@react-icons/all-files/io5/IoPlay';
|
||||||
@@ -158,6 +159,9 @@ function TimerIcon(props: { type: TimerType; className: string }) {
|
|||||||
if (type === TimerType.Clock) {
|
if (type === TimerType.Clock) {
|
||||||
return <IoTime className={className} />;
|
return <IoTime className={className} />;
|
||||||
}
|
}
|
||||||
|
if (type === TimerType.None) {
|
||||||
|
return <IoBan className={className} />;
|
||||||
|
}
|
||||||
if (type === TimerType.TimeToEnd) {
|
if (type === TimerType.TimeToEnd) {
|
||||||
const classes = cx([style.active, className]);
|
const classes = cx([style.active, className]);
|
||||||
return <IoFlag className={classes} />;
|
return <IoFlag className={classes} />;
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
|
|||||||
<option value={TimerType.CountUp}>Count up</option>
|
<option value={TimerType.CountUp}>Count up</option>
|
||||||
<option value={TimerType.TimeToEnd}>Time to end</option>
|
<option value={TimerType.TimeToEnd}>Time to end</option>
|
||||||
<option value={TimerType.Clock}>Clock</option>
|
<option value={TimerType.Clock}>Clock</option>
|
||||||
|
<option value={TimerType.None}>None</option>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export function getTimerByType(freezeEnd: boolean, timerObject?: TimerTypeParams
|
|||||||
return Math.abs(timerObject.elapsed ?? 0);
|
return Math.abs(timerObject.elapsed ?? 0);
|
||||||
case TimerType.Clock:
|
case TimerType.Clock:
|
||||||
return timerObject.clock;
|
return timerObject.clock;
|
||||||
|
case TimerType.None:
|
||||||
|
return null;
|
||||||
default: {
|
default: {
|
||||||
const exhaustiveCheck: never = timerObject.timerType;
|
const exhaustiveCheck: never = timerObject.timerType;
|
||||||
return exhaustiveCheck;
|
return exhaustiveCheck;
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
|
|
||||||
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
||||||
const timerOptions = getTimerOptions(defaultFormat, customFields);
|
const timerOptions = getTimerOptions(defaultFormat, customFields);
|
||||||
|
const disableProgress = timerIsTimeOfDay || time.timerType === TimerType.None;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={showFinished ? `${baseClasses} stage-timer--finished` : baseClasses} data-testid='timer-view'>
|
<div className={showFinished ? `${baseClasses} stage-timer--finished` : baseClasses} data-testid='timer-view'>
|
||||||
@@ -205,7 +206,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
{!userOptions.hideProgress && (
|
{!userOptions.hideProgress && (
|
||||||
<MultiPartProgressBar
|
<MultiPartProgressBar
|
||||||
className={isPlaying ? 'progress-container' : 'progress-container progress-container--paused'}
|
className={isPlaying ? 'progress-container' : 'progress-container progress-container--paused'}
|
||||||
now={timerIsTimeOfDay ? null : time.current}
|
now={disableProgress ? null : time.current}
|
||||||
complete={totalTime}
|
complete={totalTime}
|
||||||
normalColor={viewSettings.normalColor}
|
normalColor={viewSettings.normalColor}
|
||||||
warning={eventNow?.timeWarning}
|
warning={eventNow?.timeWarning}
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ export enum TimerType {
|
|||||||
CountUp = 'count-up',
|
CountUp = 'count-up',
|
||||||
TimeToEnd = 'time-to-end',
|
TimeToEnd = 'time-to-end',
|
||||||
Clock = 'clock',
|
Clock = 'clock',
|
||||||
|
None = 'none',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user