mirror of
https://github.com/mue/mue.git
synced 2026-07-09 13:35:35 +02:00
eat all the cheese, push all the things
This commit is contained in:
@@ -2,9 +2,6 @@
|
||||
import React from 'react';
|
||||
import Fetch from 'unfetch';
|
||||
|
||||
// Pick random number
|
||||
const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; };
|
||||
|
||||
export default class Background extends React.Component {
|
||||
async getAndSetBackground() {
|
||||
try { // First we try and get an image from the API...
|
||||
@@ -17,7 +14,7 @@ export default class Background extends React.Component {
|
||||
} catch (e) { // ..and if that fails we load one locally
|
||||
document.getElementById('backgroundCredits').style.display = 'none';
|
||||
document.getElementById('photographer').innerText = 'Photo from Pexels';
|
||||
document.getElementById('root').style.backgroundImage = `url(../offline-images/${randomInt(1, 25)}.jpeg)`;
|
||||
document.getElementById('root').style.backgroundImage = `url(../offline-images/${Math.floor(Math.random() * (20 - 1 + 1)) + 1})`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,11 @@ export default class Clock extends React.Component {
|
||||
startTime() {
|
||||
const today = new Date(); // Get the current date
|
||||
let h = today.getHours(); // Get hours
|
||||
const ampm = h >= 12 ? 'PM' : 'AM'; // Set AM/PM
|
||||
const m = today.getMinutes(); // Get minutes
|
||||
// const s = today.getSeconds();
|
||||
|
||||
if (h > 12) h = h - 12;
|
||||
|
||||
this.setState({ date: `${('0' + h).slice(-2)}:${('0' + m).slice(-2)}`, ampm: ampm });
|
||||
this.setState({ date: `${('0' + h).slice(-2)}:${('0' + today.getMinutes()).slice(-2)}`, ampm: h >= 12 ? 'PM' : 'AM' });
|
||||
|
||||
this.timeout = setTimeout(() => this.startTime(), 500);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ export default class Search extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className='credits'>
|
||||
{/* <h1 id='location'></h1> */}
|
||||
<h1 id='photographer'></h1>
|
||||
<div id='backgroundCredits' className='tooltip'><RoomIcon className='locationicon'/>
|
||||
<span className='tooltiptext' id='location'></span>
|
||||
{/*<h1 id='location'></h1>*/}
|
||||
<h1 id='photographer'/>
|
||||
<div id='backgroundCredits' className='tooltip'>
|
||||
<RoomIcon className='locationicon'/>
|
||||
<span className='tooltiptext' id='location'/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -22,6 +22,8 @@ export default class Greeting extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
return <h1 className='greeting'>{this.state.greeting}</h1>;
|
||||
return <h1 className='greeting'>
|
||||
{this.state.greeting}
|
||||
</h1>;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@ import React from 'react';
|
||||
import Fetch from 'unfetch';
|
||||
import quotes from '../quotes.json';
|
||||
|
||||
// Pick randon number
|
||||
const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; };
|
||||
|
||||
export default class Quote extends React.Component {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
@@ -21,7 +18,7 @@ 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 = randomInt(1, 20);
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user