-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.js
122 lines (114 loc) · 4.91 KB
/
Home.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, {Component} from 'react';
import 'antd/dist/antd.css';
import { NavLink, Route, HashRouter } from 'react-router-dom'
import { Tabs, Layout, Button, Menu } from 'antd';
import {
DesktopOutlined,
PieChartOutlined,
FileOutlined,
} from '@ant-design/icons';
import Cal from './Calendar.js'
import mem from './Messages.js'
import editor from './Editor.js'
import board from './Homeboard.js'
import prac from './Practice.js'
import quiz from './Quizs.js'
import mac from './ModifyAcc'
const { TabPane } = Tabs;
const { Header, Content, Footer, Sider } = Layout;
const HomeContent= () =>(
<div>404!!!</div>
)
const AboutContent= () =>(
<div>505!!!</div>
)
const initialPanes = [
{ title: 'Calendar', key: '/calendar', component: Cal},
{ title: 'Homeboard', key: '/homeboard', component: board},
{ title: 'Messages', key: '/messages', component: mem},
{ title: 'Editor', key: '/editor', component: editor},
{ title: 'Practice', key: '/practice', component: prac},
{ title: 'Quiz', key: '/quizs', component: quiz}
];
class Home extends Component {
state = {
panes: initialPanes,
collapsed: false,
pane: [],
};
onCollapse = collapsed => {
console.log(collapsed);
this.setState({ collapsed });
};
onEdit = (targetKey, action) => {
this[action](targetKey);
};
onTabChanged = (key) => {
this.setState({tabKey:key});
this.props.history.replace({pathname:'/home' + key, state:{
tabKey: key
}});
};
render() {
return (
<HashRouter>
<Layout style={{ minHeight: '100vh' }}>
<Button onClick={() => this.props.history.goBack()}>Rollback</Button>
<Sider collapsible collapsed={this.state.collapsed} onCollapse={this.onCollapse}>
<div className="logo" />
<Menu theme="light" mode="inline">
<Menu.Item key="1" icon={<PieChartOutlined />} onClick={() => this.state.pane.push(this.state.panes[0])&&console.log(this.pane)}>
<NavLink to="/home/calendar" >Calendar</NavLink>
</Menu.Item>
<Menu.Item key="2" icon={<DesktopOutlined />} onClick={() => this.state.pane.push(this.state.panes[1])&&this.setState(this.pane)}>
<NavLink to="/home/homeboard">Homeboard</NavLink>
</Menu.Item>
<Menu.Item key="3" icon={<PieChartOutlined />} onClick={() => this.state.pane.push(this.state.panes[2])&&this.setState(this.pane)}>
<NavLink to="/home/messages">Messages</NavLink>
</Menu.Item>
<Menu.Item key="4" icon={<DesktopOutlined />} onClick={() => this.state.pane.push(this.state.panes[3])&&this.setState(this.pane)}>
<NavLink to="/home/editor">Editor</NavLink>
</Menu.Item>
<Menu.Item key="5" icon={<PieChartOutlined />} onClick={() => this.state.pane.push(this.state.panes[4])&&this.setState(this.pane)}>
<NavLink to="/home/practice">Practice</NavLink>
</Menu.Item>
<Menu.Item key="6" icon={<DesktopOutlined />} onClick={() => this.state.pane.push(this.state.panes[5])&&this.setState(this.pane)}>
<NavLink to="/home/quizs">Quiz</NavLink>
</Menu.Item>
<Menu.Item key="7" icon={<FileOutlined />} />
</Menu>
</Sider>
<Layout className="site-layout">
<Header className="site-layout-background" style={{ padding: 0 }}>
<Tabs type="editable-card" activeKey={(this.props.location.state && this.props.location.state.tabKey) ? this.props.location.state.tabKey : ''} onChange={this.onTabChanged}>
<TabPane tab="Home" key="" closable={false} />
<TabPane tab="About" key="/about" closable={false} />
{this.state.pane.map((pan) => (
<TabPane tab={pan.title} key={pan.key} closable={true}>
</TabPane>))}
</Tabs>
<NavLink to="/home/modify">
<Button>Modify Account</Button>
</NavLink>
</Header>
<Content style={{ margin: '0 1px' }}>
<div className="site-layout-background" style={{ padding: 24, minHeight: 800 }}>
<Route path='/home' exact component = { HomeContent } />
<Route path='/home/about' component = { AboutContent } />
<Route path='/home/calendar' component = { Cal } />
<Route path='/home/homeboard' component = { board } />
<Route path='/home/messages' component = { mem } />
<Route path='/home/editor' component = { editor } />
<Route path='/home/practice' component = { prac } />
<Route path='/home/quizs' component = { quiz } />
<Route path='/home/modify' component = { mac } />
</div>
</Content>
<Footer style={{ textAlign: 'center' }}></Footer>
</Layout>
</Layout>
</HashRouter>
);
}
}
export default Home;