Added sections via react router

This commit is contained in:
Alejandro Celaya 2018-06-03 13:15:52 +02:00
parent 39a78414eb
commit 2cad352045
9 changed files with 58 additions and 14 deletions

View file

@ -38,6 +38,8 @@
"react": "^16.3.2",
"react-dev-utils": "^5.0.1",
"react-dom": "^16.3.2",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"reactstrap": "^6.0.1",
"resolve": "1.6.0",
"style-loader": "0.19.0",

View file

@ -1,6 +1,9 @@
import React from 'react';
import './App.scss';
import { Route, Switch } from 'react-router-dom';
import Home from './common/Home';
import MainHeader from './common/MainHeader';
import CreateServer from './servers/CreateServer';
export default class App extends React.Component {
render() {
@ -8,8 +11,10 @@ export default class App extends React.Component {
<div>
<MainHeader/>
<div className="app">
<h1 className="app__title">Welcome to Shlink</h1>
<h5 className="App__intro">Please, select a server.</h5>
<Switch>
<Route path="/server/create" component={CreateServer} />
<Route path="/" component={Home} />
</Switch>
</div>
</div>
);

View file

@ -1,12 +1,5 @@
.app {
text-align: center;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-flow: column;
}
@import "./utils/base";
.app__title {
font-size: 36px;
.app {
padding-top: $headerHeight;
}

11
src/common/Home.js Normal file
View file

@ -0,0 +1,11 @@
import React from 'react';
import './Home.scss';
export default () => {
return (
<div className="home-container">
<h1 className="home-container__title">Welcome to Shlink</h1>
<h5 className="home-container__intro">Please, select a server.</h5>
</div>
);
};

14
src/common/Home.scss Normal file
View file

@ -0,0 +1,14 @@
@import "../utils/base";
.home-container {
text-align: center;
height: calc(100vh - #{$headerHeight});
display: flex;
align-items: center;
justify-content: center;
flex-flow: column;
}
.home-container__title {
font-size: 36px;
}

View file

@ -14,6 +14,7 @@ import {
} from 'reactstrap';
import './MainHeader.scss';
import shlinkLogo from './shlink-logo-white.png';
import { Link } from 'react-router-dom';
export default class MainHeader extends React.Component {
constructor(props) {
@ -40,7 +41,7 @@ export default class MainHeader extends React.Component {
<Collapse navbar isOpen={this.state.isOpen}>
<Nav navbar className="ml-auto">
<NavItem>
<NavLink href="#">
<NavLink tag={Link} to ="/server/create">
<FontAwesomeIcon icon={plusIcon}/>&nbsp; Add server
</NavLink>
</NavItem>

View file

@ -2,8 +2,14 @@ import React from 'react';
import ReactDOM from 'react-dom';
import 'bootstrap/dist/css/bootstrap.min.css';
import './index.scss';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
registerServiceWorker();

View file

@ -0,0 +1,7 @@
import React from 'react';
export default () => {
return (
<div>Create server</div>
);
};

View file

@ -1 +1,6 @@
// Colors
$mainColor: #4696e5;
// Misc
$headerHeight: 57px;