diff --git a/src/s2-homeworks/hw05/pages/Junior.tsx b/src/s2-homeworks/hw05/pages/Junior.tsx index 1edd987..55cdaef 100644 --- a/src/s2-homeworks/hw05/pages/Junior.tsx +++ b/src/s2-homeworks/hw05/pages/Junior.tsx @@ -2,6 +2,7 @@ import React from 'react' import HW6 from '../../hw06/HW6' import HW7 from '../../hw07/HW7' import HW8 from '../../hw08/HW8' +import HW9 from '../../hw09/HW9' function Junior() { return ( @@ -10,7 +11,7 @@ function Junior() { - {/**/} + ) } diff --git a/src/s2-homeworks/hw09/Clock.tsx b/src/s2-homeworks/hw09/Clock.tsx new file mode 100644 index 0000000..ab276bc --- /dev/null +++ b/src/s2-homeworks/hw09/Clock.tsx @@ -0,0 +1,81 @@ +import React, {useState} from 'react' +import SuperButton from '../hw04/common/c2-SuperButton/SuperButton' +import {restoreState} from '../hw06/localStorage/localStorage' + +function Clock() { + const [timerId, setTimerId] = useState(undefined) + const [date, setDate] = useState(new Date(restoreState('hw9-date', 0))) // for autotests + const [show, setShow] = useState(false) + + const stop = () => { // пишут студенты + if (timerId) { + clearInterval(timerId) + setTimerId(undefined) + } + } + const start = () => { // пишут студенты + const id: number = +setInterval(() => { + setDate(new Date()) + }, 1000) + setTimerId(id) + } + + const onMouseEnter = () => { + setShow(true) + } + const onMouseLeave = () => { + setShow(false) + } + + // логику напишет Андрей :) // |v| видел такое в реальных часах |v| + const stringTime = date?.toLocaleTimeString() ||
// часы24:минуты:секунды (01:02:03)/(23:02:03)/(24:00:00)/(00:00:01) // пишут студенты + const stringDate = date?.toLocaleDateString() ||
// день.месяц.год (01.02.2022) // пишут студенты, варианты 01.02.0123/01.02.-123/01.02.12345 не рассматриваем + // день недели на английском, месяц на английском + const stringDay = 'Monday' ||
// пишут студенты + const stringMonth = 'May' ||
// пишут студенты + + return ( +
+
+
{stringDay}
+
{stringTime}
+
+ +
+ {show ? ( + <> +
{stringMonth}
+
{stringDate}
+ + ) : ( + <> +
+
+ + )} +
+ + + + start + + + stop + +
+ ) +} + +export default Clock diff --git a/src/s2-homeworks/hw09/HW9.tsx b/src/s2-homeworks/hw09/HW9.tsx new file mode 100644 index 0000000..431ef8a --- /dev/null +++ b/src/s2-homeworks/hw09/HW9.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import Clock from './Clock' +import s2 from '../../s1-main/App.module.css' + +const HW9 = () => { + return ( +
+
+ {/*можно убрать этот тег*/} + + {/*should work (должно работать)*/} + + +
+ {/*можно убрать этот тег*/} +
+ {/*можно убрать этот тег*/} +
+ ) +} + +export default HW9