diff --git a/src/hooks/useTimer.tsx b/src/hooks/useTimer.tsx index 66d8ff9..4eb8bd7 100644 --- a/src/hooks/useTimer.tsx +++ b/src/hooks/useTimer.tsx @@ -9,7 +9,7 @@ const useTimer = ({ endTime }: UseTimerProps) => { const INTERVAL = 1000; const [timeLeft, setTimeLeft] = useState(REST_TIME); const [isFinished, setIsFinished] = useState(false); - const [isOneHour, setIsOneHour] = useState(false); + const [isLessThanOneHour, setIsLessThanOneHour] = useState(false); const hours = String(Math.floor((timeLeft / (1000 * 60 * 60)) % 24)).padStart(2, '0'); const minutes = String(Math.floor((timeLeft / (1000 * 60)) % 60)).padStart(2, '0'); @@ -23,12 +23,10 @@ const useTimer = ({ endTime }: UseTimerProps) => { if (timeLeft <= 0) { clearInterval(timer); setIsFinished(true); - console.log('타이머가 종료되었습니다.'); } - if (!isOneHour && timeLeft <= 1000 * 60 * 60) { - setIsOneHour(true); - console.log('타이머가 1시간 이내 입니다.'); + if (!isLessThanOneHour && timeLeft <= 1000 * 60 * 60) { + setIsLessThanOneHour(true); } return () => { @@ -36,7 +34,7 @@ const useTimer = ({ endTime }: UseTimerProps) => { }; }, [timeLeft]); - return { timeString: `${hours} : ${minutes} : ${second}`, isFinished, isOneHour }; + return { displayTime: `${hours} : ${minutes} : ${second}`, isFinished, isLessThanOneHour }; }; export default useTimer; diff --git a/src/routes/Home/Home.styles.tsx b/src/routes/Home/Home.styles.tsx index 90ca14a..39f1bf8 100644 --- a/src/routes/Home/Home.styles.tsx +++ b/src/routes/Home/Home.styles.tsx @@ -76,7 +76,7 @@ export const TimerContainer = styled.div` margin-top: 37px; `; -export const Timer = styled.div` +export const Timer = styled.div<{ isLessThanOneHour: boolean }>` display: flex; align-items: center; justify-content: center; @@ -84,9 +84,9 @@ export const Timer = styled.div` height: 37px; font-size: 1.5rem; font-weight: 700; - color: rgb(255 255 255 / 40%); + color: ${(props) => (props.isLessThanOneHour ? '#3C3457' : 'rgb(255 255 255 / 40%)')}; text-align: center; - background-color: #3c3457; + background-color: ${(props) => (props.isLessThanOneHour ? '#A46FF3' : '#3c3457')}; border-radius: 50px; `; diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 478eba7..766f291 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -57,14 +57,7 @@ const Home = () => { 이런 토픽은 안볼래요 - - {timer.timeString} - + {timer.displayTime}