diff --git a/public/world-clocks-vector-436373.jpg:Zone.Identifier b/public/world-clocks-vector-436373.jpg:Zone.Identifier new file mode 100644 index 00000000..581d0419 --- /dev/null +++ b/public/world-clocks-vector-436373.jpg:Zone.Identifier @@ -0,0 +1,4 @@ +[ZoneTransfer] +ZoneId=3 +ReferrerUrl=https://www.google.com/ +HostUrl=https://cdn4.vectorstock.com/i/1000x1000/63/73/world-clocks-vector-436373.jpg diff --git a/src/App.css b/src/App.css index 97b7c578..d064d8bd 100644 --- a/src/App.css +++ b/src/App.css @@ -3,7 +3,8 @@ } .App-logo { - height: 40vmin; + height: 30vmin; + width: 40vmin; pointer-events: none; } @@ -14,6 +15,6 @@ flex-direction: column; align-items: center; justify-content: center; - font-size: calc(10px + 2vmin); + font-size: calc(5px + 1vmin); color: white; } diff --git a/src/App.js b/src/App.js index 4a6f800f..ae162868 100644 --- a/src/App.js +++ b/src/App.js @@ -1,20 +1,26 @@ import React from "react"; -import logo from "./logo.png"; +import logo from "./clock.jpg"; import "./App.css"; +import Clock from "./clock"; class App extends React.Component { + // call clearInterval tear down the tier + render() { return (
logo -

- Edit src/App.js and save to reload. -

+

Coordinated Universal Time

+ {/* Render date value that is stored in state */} + + + {[1, 1, 1, 1, 1].map(() => ( + + ))}
); } } - export default App; diff --git a/src/WorldClock.js b/src/WorldClock.js new file mode 100644 index 00000000..e69de29b diff --git a/src/clock.jpg b/src/clock.jpg new file mode 100644 index 00000000..71a9d0ef Binary files /dev/null and b/src/clock.jpg differ diff --git a/src/clock.js b/src/clock.js new file mode 100644 index 00000000..666eda25 --- /dev/null +++ b/src/clock.js @@ -0,0 +1,44 @@ +import React from "react"; + +class Clock extends React.Component { + constructor(props) { + super(props); + this.timeZone = props.timeZone; + // Initialise component state to contain "date" attribute with current date and time + this.state = { date: new Date() }; + console.log(props.timeZone); + } + + componentDidMount() { + // Set date value in state every second to current date and time + // Save setInterval timer ID in class variable for teardown in another class method + function updateDate() { + this.setState({date: new Date()}) + console.log("hi") + } + setInterval(updateDate, 10000); + + this.timerId = setInterval(() => { + // callback function + this.setState({ + date: new Date(), + }); + }, 1000); + } + + componentWillUnmount() { + // Teardown setInterval timer with timer ID saved as class variable + clearInterval(this.timerId); + } + + render() { + return ( + // Render date value that is stored in state +

+ {this.state.date.toLocaleString("en-GB", { timeZone: this.timeZone })} +

+ ); + } +} + +export default Clock; diff --git a/src/container.js b/src/container.js new file mode 100644 index 00000000..ab8a6114 --- /dev/null +++ b/src/container.js @@ -0,0 +1,21 @@ +// import Container from "react-bootstrap/Container"; +// import Row from "react-bootstrap/Row"; +// import Col from "react-bootstrap/Col"; + + +// function container() { +// return ( +// +// +// 1 of 2 +// 2 of 2 +// +// +// 1 of 3 +// 2 of 3 +// +// +// ); +// } + +// export default container; diff --git a/src/index.js b/src/index.js index a64e7d56..9b8ac2f8 100644 --- a/src/index.js +++ b/src/index.js @@ -3,5 +3,7 @@ import ReactDOM from "react-dom/client"; import "./index.css"; import App from "./App"; + const root = ReactDOM.createRoot(document.getElementById("root")); root.render(); +