router
This commit is contained in:
parent
d648ed1883
commit
38ddd9a832
@ -14,6 +14,7 @@
|
|||||||
"react": "^16.5.0",
|
"react": "^16.5.0",
|
||||||
"react-dom": "^16.5.0",
|
"react-dom": "^16.5.0",
|
||||||
"react-jss": "^8.6.1",
|
"react-jss": "^8.6.1",
|
||||||
|
"react-router": "^4.3.1",
|
||||||
"react-router-dom": "^4.3.1",
|
"react-router-dom": "^4.3.1",
|
||||||
"react-scripts": "1.1.5",
|
"react-scripts": "1.1.5",
|
||||||
"router": "^1.3.3",
|
"router": "^1.3.3",
|
||||||
|
@ -48,7 +48,6 @@ const Main = inject("rootStore") ( observer(
|
|||||||
this.handleSidebarHide = this.handleSidebarHide.bind(this);
|
this.handleSidebarHide = this.handleSidebarHide.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
activeItem: 'Home',
|
|
||||||
visible: false
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +64,10 @@ const Main = inject("rootStore") ( observer(
|
|||||||
this.sheet.detach()
|
this.sheet.detach()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
handleItemClick(e, { name }) {
|
handleItemClick(e, { name }) {
|
||||||
|
this.props.handleItemClick(name);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
activeItem: name,
|
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -87,7 +86,7 @@ const Main = inject("rootStore") ( observer(
|
|||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const activeItem = this.state.activeItem
|
const activeItem = window.location.pathname;
|
||||||
|
|
||||||
if(window.innerWidth > 700) {
|
if(window.innerWidth > 700) {
|
||||||
|
|
||||||
@ -100,11 +99,11 @@ const Main = inject("rootStore") ( observer(
|
|||||||
<img alt="" src={require('../../files/images/logo.svg')} style={{display: 'block', width: '60px', height: '45px'}} />
|
<img alt="" src={require('../../files/images/logo.svg')} style={{display: 'block', width: '60px', height: '45px'}} />
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
||||||
<Menu.Item name='Home' active={activeItem === 'Home'} onClick={this.handleItemClick} as='a'>
|
<Menu.Item name='/' active={activeItem === '/'} onClick={this.handleItemClick} as='a'>
|
||||||
Home
|
Home
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
||||||
<Menu.Item name='Password manager' active={activeItem === 'Password manager'} onClick={this.handleItemClick} as='a'>
|
<Menu.Item name='/passwords' active={activeItem === '/passwords'} onClick={this.handleItemClick} as='a'>
|
||||||
Password manager
|
Password manager
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
||||||
@ -114,7 +113,9 @@ const Main = inject("rootStore") ( observer(
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu.Menu>
|
</Menu.Menu>
|
||||||
</Menu>
|
</Menu>
|
||||||
{this.props.children}
|
<div style={{minHeight: '100vh'}}>
|
||||||
|
{this.props.children}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import jss from 'jss';
|
import jss from 'jss';
|
||||||
import preset from 'jss-preset-default';
|
import preset from 'jss-preset-default';
|
||||||
import { Segment, Container } from 'semantic-ui-react'
|
import { Segment, Container } from 'semantic-ui-react';
|
||||||
|
import { Router, Route, Switch } from "react-router-dom";
|
||||||
|
import history from '../stores/functions/history';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions import
|
* Functions import
|
||||||
@ -11,6 +13,8 @@ import { Segment, Container } from 'semantic-ui-react'
|
|||||||
* Component imports
|
* Component imports
|
||||||
*/
|
*/
|
||||||
import Menu from '../components/Menu/Menu';
|
import Menu from '../components/Menu/Menu';
|
||||||
|
import Home from './home/Home';
|
||||||
|
import PasswordManager from './passwordManager/PasswordManager';
|
||||||
|
|
||||||
jss.setup(preset());
|
jss.setup(preset());
|
||||||
|
|
||||||
@ -39,6 +43,12 @@ class Main extends Component {
|
|||||||
* - /
|
* - /
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
this.handleItemClick = this.handleItemClick.bind(this);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
activeItem: ''
|
||||||
|
}
|
||||||
|
|
||||||
//Styles
|
//Styles
|
||||||
this.styles = this.getStyles();
|
this.styles = this.getStyles();
|
||||||
this.sheet = jss.createStyleSheet(this.styles);
|
this.sheet = jss.createStyleSheet(this.styles);
|
||||||
@ -53,19 +63,25 @@ class Main extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
handleItemClick(name) {
|
||||||
|
history.push(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return(
|
return(
|
||||||
<div>
|
<Router history={history}>
|
||||||
<Menu>
|
<Menu handleItemClick={this.handleItemClick}>
|
||||||
<div style={{minHeight: '100vh'}}>
|
<Container className={this.classes.mainContainer}>
|
||||||
<Container className={this.classes.mainContainer}>
|
<Segment>
|
||||||
<Segment>
|
<Switch>
|
||||||
awdawd
|
<Route exact path="/" component={Home} />
|
||||||
</Segment>
|
<Route path="/passwords" component={PasswordManager} />
|
||||||
</Container>
|
</Switch>
|
||||||
</div>
|
</Segment>
|
||||||
|
</Container>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</Router>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
70
src/pages/home/Home.js
Normal file
70
src/pages/home/Home.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import React, {Component} from 'react';
|
||||||
|
import jss from 'jss';
|
||||||
|
import preset from 'jss-preset-default';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions import
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Component imports
|
||||||
|
*/
|
||||||
|
|
||||||
|
jss.setup(preset());
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
###############################
|
||||||
|
Components -- START
|
||||||
|
###############################
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
###############################
|
||||||
|
Components -- END
|
||||||
|
###############################
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Home extends Component {
|
||||||
|
constructor(props){
|
||||||
|
super(props);
|
||||||
|
//Initial loading screen
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Expected props
|
||||||
|
* - /
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Styles
|
||||||
|
this.styles = this.getStyles();
|
||||||
|
this.sheet = jss.createStyleSheet(this.styles);
|
||||||
|
const {classes} = this.sheet.attach();
|
||||||
|
this.classes = classes;
|
||||||
|
//Styles
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.sheet.detach()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
Home
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getStyles() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Home;
|
70
src/pages/passwordManager/PasswordManager.js
Normal file
70
src/pages/passwordManager/PasswordManager.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import React, {Component} from 'react';
|
||||||
|
import jss from 'jss';
|
||||||
|
import preset from 'jss-preset-default';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions import
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Component imports
|
||||||
|
*/
|
||||||
|
|
||||||
|
jss.setup(preset());
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
###############################
|
||||||
|
Components -- START
|
||||||
|
###############################
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
###############################
|
||||||
|
Components -- END
|
||||||
|
###############################
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordManager extends Component {
|
||||||
|
constructor(props){
|
||||||
|
super(props);
|
||||||
|
//Initial loading screen
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Expected props
|
||||||
|
* - /
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Styles
|
||||||
|
this.styles = this.getStyles();
|
||||||
|
this.sheet = jss.createStyleSheet(this.styles);
|
||||||
|
const {classes} = this.sheet.attach();
|
||||||
|
this.classes = classes;
|
||||||
|
//Styles
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.sheet.detach()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
PasswordManager
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getStyles() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PasswordManager;
|
Loading…
x
Reference in New Issue
Block a user