diff --git a/src/components/Timer/Countdown.module.css b/src/components/Timer/Countdown.module.css index b977b5ae22..4c314d6243 100644 --- a/src/components/Timer/Countdown.module.css +++ b/src/components/Timer/Countdown.module.css @@ -324,4 +324,17 @@ input[type='number']::-webkit-inner-spin-button { opacity, transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 300ms; +} + +.refreshIcon { + position: absolute; + top: 0.55rem; + right: 2.2rem; + cursor: pointer; + font-size: 1.2rem; + opacity: 0.9; +} + +.refreshIcon:hover { + color: #ed688a; } \ No newline at end of file diff --git a/src/components/Timer/Timer.jsx b/src/components/Timer/Timer.jsx index 16473011e1..bf58b2f709 100644 --- a/src/components/Timer/Timer.jsx +++ b/src/components/Timer/Timer.jsx @@ -4,7 +4,7 @@ import { useState, useCallback, useEffect, useRef, useMemo } from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Progress } from 'reactstrap'; import useWebSocket, { ReadyState } from 'react-use-websocket'; -import { BsAlarmFill } from 'react-icons/bs'; +import { BsAlarmFill, BsArrowClockwise } from 'react-icons/bs'; import { FaPlusCircle, FaMinusCircle, @@ -239,6 +239,10 @@ function Timer({ authUser, darkMode, isPopout }) { [timerState], ); + const handleRefreshTimer = useCallback(() => { + window.location.reload(); + }, []); + // Initialize session ID on component mount useEffect(() => { // Use cryptographically secure random values for session ID generation @@ -886,6 +890,7 @@ function Timer({ authUser, darkMode, isPopout }) { readyState={customReadyState} message={message} toggleTimer={() => window.close()} + handleRefreshTimer={handleRefreshTimer} /> )} @@ -912,6 +917,7 @@ function Timer({ authUser, darkMode, isPopout }) { +
@@ -928,7 +934,18 @@ function Timer({ authUser, darkMode, isPopout }) { {previewTimeDisplay} ) : ( -
Disconnected
+
+ Disconnected + +
)}
{customReadyState === ReadyState.OPEN && ( @@ -1081,6 +1098,7 @@ function Timer({ authUser, darkMode, isPopout }) { readyState={customReadyState} message={message} toggleTimer={toggleTimer} + handleRefreshTimer={handleRefreshTimer} /> )} diff --git a/src/components/Timer/Timer.module.css b/src/components/Timer/Timer.module.css index 08c5595f0f..2729de4633 100644 --- a/src/components/Timer/Timer.module.css +++ b/src/components/Timer/Timer.module.css @@ -44,13 +44,36 @@ } .disconnected { - font-size: 1.2rem; - font-weight: bold; - width: fit-content; + width: 140px; + min-height: 42px; background-color: rgb(82 92 102 / 100%); color: rgb(238 10 10); border-radius: 0 0 0.5rem 0.5rem; - padding: 0.25rem; + padding: 0.25rem 0.5rem; + display: flex; + align-items: center; + justify-content: center; + gap: 0.35rem; + font-size: 1rem; + font-weight: bold; + box-sizing: border-box; + white-space: nowrap; +} + +.disconnectedRefreshBtn { + display: flex; + align-items: center; + justify-content: center; + background: transparent; + border: none; + color: white; + cursor: pointer; + padding: 0; + line-height: 1; +} + +.disconnectedRefreshBtn:hover { + color: #ed688a; } .preview { diff --git a/src/components/Timer/TimerStatus.jsx b/src/components/Timer/TimerStatus.jsx index c5a0d1f615..0281ff3230 100644 --- a/src/components/Timer/TimerStatus.jsx +++ b/src/components/Timer/TimerStatus.jsx @@ -1,9 +1,9 @@ import { ReadyState } from 'react-use-websocket'; -import { BsXLg } from 'react-icons/bs'; +import { BsXLg, BsArrowClockwise } from 'react-icons/bs'; import cs from 'classnames'; import css from './Countdown.module.css'; -export default function TimerStatus({ readyState, toggleTimer }) { +export default function TimerStatus({ readyState, toggleTimer, handleRefreshTimer }) { /* This is the status of the connection with the timer service We just use the readyState of the websocket connection to show the status @@ -16,6 +16,8 @@ export default function TimerStatus({ readyState, toggleTimer }) { [ReadyState.UNINSTANTIATED]: 'Uninstantiated', }[readyState]; + const showRefreshButton = readyState === ReadyState.CLOSED; + /* Here is the component to show the timer status If the connection is not open we show the connection status @@ -27,6 +29,13 @@ export default function TimerStatus({ readyState, toggleTimer }) { return ( <> + {showRefreshButton && ( + + )} +
{connectionStatus}
);