Skip to content

Commit 5bcdd9e

Browse files
authored
Merge pull request #34 from Joehuu/toggle-seconds
Add toggle for seconds
2 parents fa89b45 + 210be96 commit 5bcdd9e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Main.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const Main = () => {
2727
const [titleDisplay, setTitleDisplay] = React.useState(TitleDisplay.English);
2828
const [lyricsDisplay, setLyricsDisplay] = React.useState(LyricsDisplay.Original);
2929
const [use24HourClock, set24HourClock] = React.useState(true);
30+
const [showSeconds, setShowSeconds] = React.useState(true);
3031
const audioRef = React.useRef(new Audio());
3132

3233
const playerHandler = () => {
@@ -252,6 +253,7 @@ const Main = () => {
252253
if (properties.titledisplay) setTitleDisplay(properties.titledisplay.value)
253254
if (properties.lyricsdisplay) setLyricsDisplay(properties.lyricsdisplay.value)
254255
if (properties.use24hourclock) set24HourClock(properties.use24hourclock.value)
256+
if (properties.showseconds) setShowSeconds(properties.showseconds.value)
255257
},
256258
setPaused: function (isPaused) {
257259
setWPEPaused(isPaused);
@@ -306,6 +308,7 @@ const Main = () => {
306308
textShadow={SongData[songIndex].clockTextShadow}
307309
textSize={textSize}
308310
use24HourClock={use24HourClock}
311+
showSeconds={showSeconds}
309312
/>
310313
) : null}
311314
{player === "true" ? (

src/components/Clock.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ const Clock = (props) => {
4646
}}
4747
>
4848
{(props.use24HourClock ? hour : (hour === 0 || hour === 12 ? "12" : hour % 12)) + ":"}
49-
{minute > 9 ? minute : "0" + minute}
49+
{minute.toString().padStart(2, "0")}
5050
<span
5151
className={`absolute bottom-[2.5vh]`}
5252
style={{
5353
fontSize: `${secondSize * props.textSize}rem`,
5454
color: `white`,
5555
}}
5656
>
57-
{second > 9 ? second : "0" + second}
57+
{props.showSeconds ? second.toString().padStart(2, "0") : ""}
5858
</span>
5959
<span
6060
className={`absolute top-[5vh]`}

0 commit comments

Comments
 (0)