This commit is contained in:
Mr Brickly
2019-11-06 19:03:17 +00:00
parent 40452b71bf
commit 39969cde6d
13 changed files with 100 additions and 63 deletions

View File

@@ -3,7 +3,7 @@ import React from 'react';
import Fetch from 'unfetch';
export default class Background extends React.Component {
async getAndSetBackground() {
async setBackground() {
try { // First we try and get an image from the API...
let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors');
data = await data.json();
@@ -19,7 +19,7 @@ export default class Background extends React.Component {
}
componentDidMount() {
this.getAndSetBackground();
this.setBackground();
}
render() {

View File

@@ -17,7 +17,7 @@ export default class Clock extends React.Component {
if (h > 12) h = h - 12;
this.setState({ date: `${('0' + h).slice(-2)}:${('0' + today.getMinutes()).slice(-2)}`, ampm: h >= 12 ? 'PM' : 'AM' });
this.setState({ date: `${('0' + h).slice(-2)}:${('0' + today.getMinutes()).slice(-2)}`, ampm: h >= 12 ? 'AM' : 'PM' });
this.timeout = setTimeout(() => this.startTime(), 500);
}

View File

@@ -14,6 +14,12 @@ export default class Greeting extends React.Component {
let t = 'Good evening'; // Set the default time string to "Good evening"
if (h < 12) t = 'Good morning'; // If it's before 12am, set the time string to "Good morning"
else if (h < 18) t = 'Good afternoon'; // If it's before 6pm, set the time string to "Good afternoon"
// Events
const today = new Date();
if (today.getMonth() === 0 && today.getDate() === 1) t = 'Happy new year';
else if (today.getMonth() === 11 && today.getDate() === 25) t = 'Merry Christmas';
else if (today.getMonth() === 9 && today.getDate() === 31) t = 'Happy Halloween';
this.setState({ greeting: t }); // Set the state to the time string
}

19
src/components/Navbar.jsx Normal file
View File

@@ -0,0 +1,19 @@
//* Imports
import RefreshIcon from '@material-ui/icons/Refresh';
import LocalPizzaIcon from '@material-ui/icons/LocalPizza';
import React from 'react';
export default class Search extends React.Component {
render() {
return (
<div className="navbar-container">
<div className='navbar1'>
<RefreshIcon className='locationicon' />
</div>
<div className='navbar2'>
<LocalPizzaIcon className='pizzaicon'/>
</div>
</div>
);
}
}

View File

@@ -18,8 +18,9 @@ export default class Quote extends React.Component {
data = await data.json();
this.setState({ quote: data.quote, author: data.author });
} catch (e) { // ..and if that fails we load one locally
const num = Math.floor(Math.random() * (20 - 1 + 1)) + 1; // Get random number between 1-20
this.setState({ quote: quotes[num].quote, author: quotes[num].author });
// const num = Math.floor(Math.random() * (20 - 1 + 1)) + 1; // Get random number between 1-20
const quote = quotes[Math.floor(Math.random() * quotes.length)];
this.setState({ quote: quote.quote, author: quote.author });
}
}