import logo from './logo.svg'; import './App.css'; import React, { useEffect, useState } from 'react'; // import { ClockFace } from './img' // const MyDiv = () => { // return ( //
// Привет-привет! // //
// ) // } const _ = React.createElement const MyDiv = () => { return _('div', {}, "Testets", _('input')) } const TwoDivs = () =>
const Add = ({ a = 100, b = 1000 }) =>
a + b = {a} + {b} = {+a + +b}
const BlockOfTextWithHeader = ({ children, title = 'No Title' }) => <>

{title}

{children}

// const Timer = () => { // const [count, setCount] = useState(0) // useEffect(() => { // const int = setInterval(() => setCount(count => count + 1), 1000) // return () => clearInterval(int) // }, []) // return ( //
// {count} //
// ) // } const TextLength = ({ text }) =>

{text.length}

const Input = () => { const [text, setText] = useState('testtest') return (
setText(e.target.value.toUpperCase())} />
) } // Spoiler const Spoiler = ({ header = "+", open, children }) => { const [isOpen, setIsOpen] = useState(open) // console.log(open) return (
setIsOpen(!isOpen)}> {header} {isOpen && children}
) } // Timer // const Timer = ({ ms }) => { // const [count, setCount] = useState(ms) // const [isRunning, setIsRunning] = useState(false) // // функция -перевод секунд в нормальный вид // function timerFormat(timestamp) { // const hours = Math.floor(timestamp / 60 / 60) // const minutes = Math.floor(timestamp / 60) - (hours * 60) // const seconds = timestamp % 60 // const plusZero = (param) => (param > 10) ? param : '0' + param // return `${plusZero(hours)} : ${plusZero(minutes)} : ${plusZero(seconds)}` // } // console.log(count) // // таймер // useEffect(() => { // if (isRunning) { // const int = setInterval(() => { // setCount(count => { // if (count <= 0) { // setIsRunning(false) // return 0 // } // return count - 1 // }) // }, 1000) // return () => clearInterval(int) // } // }, [isRunning]) // // console.log(timerFormat(count)) // return ( //
// {timerFormat(count)} //
// //
// ) // } // TimerControl const TimerControl = () => { const [hours, setHours] = useState('') const [minutes, setMinutes] = useState('') const [seconds, setSeconds] = useState('') // переводим время в секунды const ms = +hours * 60 * 60 + +minutes * 60 + +seconds const [count, setCount] = useState() const [isRunning, setIsRunning] = useState(false) useEffect(() => setCount(ms), [ms]) // функция-перевод секунд в нормальный вид function timerFormat(time) { const h = Math.floor(time / 60 / 60) const m = Math.floor(time / 60) - (h * 60) const s = time % 60 const defaultZero = (param) => (param > 9) ? param : '0' + param return `${defaultZero(h)} : ${defaultZero(m)} : ${defaultZero(s)}` } // таймер useEffect(() => { if (isRunning) { const int = setInterval(() => { setCount(count => { if (count <= 0) { setIsRunning(false) return 0 } return count - 1 }) }, 1000) return () => clearInterval(int) } }, [isRunning]) return (
{timerFormat(count)}
setHours(e.target.value)}> setMinutes(e.target.value)}> setSeconds(e.target.value)}>
) } // TimerContainer const SecondsTimer = ({ seconds }) =>

{seconds}

// const TimerContainer = ({ seconds, refresh, render }) => { // const [count, setCount] = useState(seconds) // отслеживаем состояние количества секунд // const [isRunning, setIsRunning] = useState(true) // отслеживаем состояние кнопки стоп/старт для таймера // const Render = render // console.log('count ', count) // // Таймер // useEffect(() => { // эффект, отвечающий за то, когда счетчик прошле в 0, он его переводит в состояние паузы // if (count <= 0) { // setIsRunning(false) // } // }, [count <= 0]) // useEffect(() => { // сам счетчик // if (isRunning) { // const start = performance.now() // const int = setInterval(() => { // const diff = Math.floor((performance.now() - start) / refresh) // setCount(count => count - diff) // }, refresh) // return () => clearInterval(int) // } // }) // return ( //
// // {/* */} //
// ) // } // LCD // TimerContainer для LCD const TimerContainer = ({ seconds, refresh, render }) => { const [count, setCount] = useState(seconds) // отслеживаем состояние количества секунд const [isRunning, setIsRunning] = useState(false) // отслеживаем состояние кнопки стоп/старт для таймера const Render = render console.log('count ', count) // Таймер useEffect(() => { // эффект, отвечающий за то, когда счетчик прошле в 0, он его переводит в состояние паузы if (count <= 0) { setIsRunning(false) } }, [count <= 0]) useEffect(() => { // сам счетчик if (isRunning) { const start = performance.now() const int = setInterval(() => { const diff = Math.floor((performance.now() - start) / refresh) setCount(count => count - diff) }, refresh) return () => clearInterval(int) } }) return (
) } // Timer для LCD const Timer = ({ ms }) => { // функция-перевод секунд в нормальный вид function timerFormat(time) { const h = Math.floor(time / 60 / 60) const m = Math.floor(time / 60) - (h * 60) const s = time % 60 const defaultZero = (param) => (param > 9) ? param : '0' + param return `${defaultZero(h)} : ${defaultZero(m)} : ${defaultZero(s)}` } return (
{timerFormat(ms)}
) } // Watch const Watch = ({ ms }) => { const h = Math.floor(ms / 60 / 60) * 30 // умножаем на 30, чтоы перевести число часов в градусы циферблата const m = (Math.floor(ms / 60) - (h * 60 / 30)) * 6 // умножаем на 6, чтоы перевести число минут в градусы циферблата const s = ms % 60 * 6 // умножаем на 6, чтоы перевести число секунд в градусы циферблата return (
{/* */}
) } // TimerControl + TimerContainer { // TimerControl const TimerControl = () => { const [hours, setHours] = useState('') const [minutes, setMinutes] = useState('') const [seconds, setSeconds] = useState('') // переводим время в секунды const ms = +hours * 60 * 60 + +minutes * 60 + +seconds const [count, setCount] = useState() const [isRunning, setIsRunning] = useState(false) useEffect(() => setCount(ms), [ms]) // функция-перевод секунд в нормальный вид function timerFormat(time) { const h = Math.floor(time / 60 / 60) const m = Math.floor(time / 60) - (h * 60) const s = time % 60 const defaultZero = (param) => (param > 9) ? param : '0' + param return `${defaultZero(h)} : ${defaultZero(m)} : ${defaultZero(s)}` } // таймер useEffect(() => { if (isRunning) { const int = setInterval(() => { setCount(count => { if (count <= 0) { setIsRunning(false) return 0 } return count - 1 }) }, 1000) return () => clearInterval(int) } }, [isRunning]) return (
{timerFormat(count)}
setHours(e.target.value)}> setMinutes(e.target.value)}> setSeconds(e.target.value)}>
) } } function App() { return (
{/* */} {/*20852 милисекунд - это 5 часов, 47 минут,32 секунды */}
===============================================
{/* LCD */}
LCD
==============================================
{/* */} {/* */}
==============================================
{/* TimerControl */} {/* Timer */} {/* */} Заголовок} open> Контент 1

лорем ипсум траливали и тп.

Контент 2

лорем ипсум траливали и тп.

{/* */} {/* */} {/* */} lorem ipsum траливали lorem ipsum траливали 2
); } export default App;