Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created October 3, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesTheHacker/305e59d07b63da9df894d0ec4f8fbe1c to your computer and use it in GitHub Desktop.
Save JamesTheHacker/305e59d07b63da9df894d0ec4f8fbe1c to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
import { library, dom } from '@fortawesome/fontawesome-svg-core'
import { faSnapchat } from "@fortawesome/free-brands-svg-icons"
import {
faGlobe,
faMars,
faVenus,
faCameraRetro,
faPlus
} from "@fortawesome/free-solid-svg-icons"
import { Provider } from 'mobx-react'
import { RouterStore, syncHistoryWithStore } from 'mobx-react-router'
import { Router } from 'react-router-dom'
import createBrowserHistory from 'history/createBrowserHistory'
// React Components
import userStore from './App/stores/UserStore'
import App from './App/index'
// SCSS
import './scss/base'
library.add(
faSnapchat,
faGlobe,
faMars,
faVenus,
faCameraRetro,
faPlus
)
dom.watch()
/*
* Main application
*/
const appContainer = document.getElementById('app');
if(appContainer) {
const browserHistory = createBrowserHistory()
const routingStore = new RouterStore();
const stores = {
users: userStore,
routing: routingStore
}
const history = syncHistoryWithStore(browserHistory, routingStore);
ReactDOM.render(
(
<Provider {...stores}>
<Router history={history}>
<App />
</Router>
</Provider>
),
appContainer);
}
/*
* Burger Menu
*/
const burgerMenu = document.querySelector('.navbar-burger');
if (burgerMenu) {
burgerMenu.addEventListener('click', ev => {
const target = ev.target
const menu = document.querySelector('.navbar-menu')
target.classList.toggle('is-active')
menu.classList.toggle('is-active')
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment