diff --git a/public/index.html b/public/index.html index c8ff8e5..4194b35 100644 --- a/public/index.html +++ b/public/index.html @@ -32,7 +32,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - Pomodoro Timer + Clockify Pomodoro Timer diff --git a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx index a7c0425..b6d9734 100644 --- a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx +++ b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx @@ -2,6 +2,7 @@ import React, {useState} from 'react' import uploadToClockifyTimer from '../Clockify/uploadToClockifyTimer' import getAndFormatCurrentTime from '../Clockify/getAndFormatCurrentTime' +import randomText from '../Misc/randomText' const MainPomodoroTimer = (props) => { @@ -230,13 +231,16 @@ const MainPomodoroTimer = (props) => { if (!weAreInBreakTime) { + getFavicon().href = './img/working favicon.ico' - + if (!alreadyCountingStart) { const time = getAndFormatCurrentTime() props.setStartTime(time) - + setAlreadyCountingStart(true) + + document.title = randomText('work') } if (minutes === 0 && seconds === 0) { @@ -275,6 +279,8 @@ const MainPomodoroTimer = (props) => { setAlreadyCountingEnd(true) props.setLetsUpload(true) + + document.title = randomText('rest') } } @@ -324,6 +330,7 @@ const MainPomodoroTimer = (props) => { } if (!props.timerOn) { + document.title = 'Clockify Pomodoro Timer' getFavicon().href = './img/favicon.ico' @@ -374,7 +381,7 @@ const MainPomodoroTimer = (props) => { setAlreadyCountingStart(false) setAlreadyCountingEnd(false) } - }, [props.timerOn, minutes, seconds, breakTime, setMinutes, setSeconds, getAndFormatCurrentTime, setAlreadyCountingEnd, setAlreadyCountingStart, alreadyCountingEnd, alreadyCountingStart, props.setEndTime, props.endTime] + }, [randomText, props.timerOn, minutes, seconds, breakTime, setMinutes, setSeconds, getAndFormatCurrentTime, setAlreadyCountingEnd, setAlreadyCountingStart, alreadyCountingEnd, alreadyCountingStart, props.setEndTime, props.endTime] ) const formatMinutes = () => { diff --git a/src/components/Misc/randomText.js b/src/components/Misc/randomText.js new file mode 100644 index 0000000..6c4f718 --- /dev/null +++ b/src/components/Misc/randomText.js @@ -0,0 +1,42 @@ +const randomText = (typeTimer) => { + + const workPhrases = [ + `It's time to work`, + ] + + const restPhrases = [ + `Rest!, Rest!`, + ] + + if (typeTimer === 'work') { + + const min = 0 + const max = workPhrases.length - 1 + + const selection = Math.random() * (max - min) + min; + + console.log(workPhrases) + console.log(selection) + + return workPhrases[selection] + } + + if (typeTimer === 'rest') { + + const min = 0 + const max = restPhrases.length - 1 + + const selection = Math.random() * (max - min) + min; + + console.log(restPhrases) + console.log(selection) + + return restPhrases[selection] + } + + //! CREDITS: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/random + return 'ERROR' + +} + +export default randomText