Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create clock component #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions app/components/Clock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
import { useEffect, useState } from "react"

function Clock() {
return(
<div>clock</div>
//const [today, setToday] = useState(new Date())
const [today, setToday] = useState(0)
console.log(today);
console.log("le type est" ,typeof today);


// useEffect(() => {
// console.log("test into useEffect");

// const timer = setTimeout(() => {
// console.log('This will run after 3 second!')
// }, 3000);
// return () => clearTimeout(timer);
// }, []);

function refreshClock() {
setToday(new Date())
}

useEffect (() => {
console.log("test into useEffect");
// const timerId = setInterval(refreshClock, 1000)
// return function cleanup() {
// clearInterval(timerId)
// }
}, [today])
console.log(useEffect)

// let hour = today.getHours()
// let minute = today.getMinutes()
// let seconde = today.getSeconds()

return (
//<div>{hour}:{minute}:{seconde}</div>
<div>
<button onClick={()=> {setToday(1)}}>push</button>
<h1>{today}</h1>
</div>

)

}
Expand Down
5 changes: 5 additions & 0 deletions app/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Clock from "./Clock"

function Header(props: { name: string }) {

const { name } = props
Expand All @@ -11,6 +13,9 @@ function Header(props: { name: string }) {
: (<p>error no name</p>)
}
</div>
<div className="header-clock">
<Clock />
</div>
</header>
)
}
Expand Down
3 changes: 2 additions & 1 deletion app/styles/smartdisplay.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ header {
line-height: 6rem;
}

.header-agency{
.header-clock{
font-size: 4rem;
font-weight: bold;
}

.departure-row{
Expand Down