dynamic imports fancy for background

This commit is contained in:
talksik
2019-08-20 23:16:22 -07:00
parent a6c9324d89
commit 76df237db6
7 changed files with 23 additions and 13 deletions

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+12 -11
View File
@@ -175,8 +175,8 @@ class MainCommand extends Component {
handleSubmitCommand = e => { handleSubmitCommand = e => {
// TODO: make executing api calls modular with helpers/services // TODO: make executing api calls modular with helpers/services
const processedData = this.state.commandProcessedData; const processedData = this.state.commandProcessedData;
const commandInput = this.state.commandInput;
console.log(this.state.command);
if (this.state.command == 'gmail') { if (this.state.command == 'gmail') {
const message = const message =
`From: ${this.state.googleAuthUser.U3}\r\n` + `From: ${this.state.googleAuthUser.U3}\r\n` +
@@ -203,21 +203,22 @@ class MainCommand extends Component {
console.log('Sent the Email!', response); console.log('Sent the Email!', response);
}); });
} else if (this.state.command == 'google') { } else if (this.state.command == 'google') {
window.open( // if they type chase.com it will go straight there
'https://www.google.com/search?q=' + this.state.commandInput, if (commandInput.includes('.com')) {
'_blank' window.open(commandInput, '_blank');
); } else {
window.open(
'https://www.google.com/search?q=' + commandInput,
'_blank'
);
}
} else if (this.state.command == 'utube') { } else if (this.state.command == 'utube') {
window.open( window.open(
'https://www.youtube.com/results?search_query=' + 'https://www.youtube.com/results?search_query=' + commandInput,
this.state.commandInput,
'_blank' '_blank'
); );
} else if (this.state.command == 'reddit') { } else if (this.state.command == 'reddit') {
window.open( window.open('https://www.reddit.com/r/' + commandInput, '_blank');
'https://www.reddit.com/r/' + this.state.commandInput,
'_blank'
);
} }
this.setState(INITIAL_COMMAND_STATE, () => { this.setState(INITIAL_COMMAND_STATE, () => {
+11 -2
View File
@@ -2,13 +2,22 @@ import React from 'react';
import { Switch, Route } from 'react-router-dom'; import { Switch, Route } from 'react-router-dom';
import styles from './root.less'; import styles from './root.less';
import backgroundImage from '../assets/images/mainbg.jpg'; // import backgroundImage from '../assets/images/mainbg.jpg';
import TipCard from './TipCard'; import TipCard from './TipCard';
import MainCommand from './MainCommand'; import MainCommand from './MainCommand';
import AvailableCommandsIcons from './AvailableCommandsIcons'; import AvailableCommandsIcons from './AvailableCommandsIcons';
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
const Root = props => { const Root = props => {
//dynamically getting particular bg
var bgNum = getRandomInt(5);
const images = require.context('../assets/images', true);
let bgImg = images('./mainbg' + bgNum + '.jpg');
return ( return (
<React.Fragment> <React.Fragment>
{/* Toast for notifications */} {/* Toast for notifications */}
@@ -20,7 +29,7 @@ const Root = props => {
<AvailableCommandsIcons /> <AvailableCommandsIcons />
<img className={styles.backgroundImage} src={backgroundImage} /> <img className={styles.backgroundImage} src={bgImg} />
</div> </div>
<Switch /> <Switch />