Skip to content

Commit 99f44b4

Browse files
coderaminscoderamins
coderamins
authored and
coderamins
committed
20191204
1 parent 04b7f7e commit 99f44b4

File tree

7 files changed

+117
-11
lines changed

7 files changed

+117
-11
lines changed

src/components/AppRoute.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { Route, Redirect } from 'react-router-dom';
3+
import { isLogin } from '../utils';
4+
5+
const AppRoute=({component:Component,layout:Layout,...rest})=>(
6+
<Route
7+
{...rest}
8+
render={props=>(
9+
<Layout>
10+
isLogin() ?
11+
<Component {...props}/>:
12+
<Redirect to="/login" />
13+
</Layout>
14+
)}
15+
/>
16+
);
17+
18+
export default AppRoute;

src/components/Header/SiteHeader.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { Component } from "react";
2+
import { Link } from "react-router-dom";
3+
import { Layout, Header, Navigation, Drawer, Content } from "react-mdl";
4+
5+
class SiteHeader extends Component {
6+
render() {
7+
return (
8+
<Header
9+
title={
10+
<span>
11+
<strong>کافه کد</strong>
12+
</span>
13+
}
14+
scroll
15+
img=""
16+
>
17+
<Navigation dir="rtl">
18+
<a href="/home">صفحه نخست</a>
19+
<a href="/tutorials">دوره ها</a>
20+
<a href="/about">درباره ما</a>
21+
<a href="/contact">ارتباط با ما</a>
22+
<div className="clientarea">
23+
<Link to="/signup">ثبت نام</Link>
24+
<span> / </span>
25+
<a href="/login">ورود</a>
26+
</div>
27+
</Navigation>
28+
</Header>
29+
);
30+
}
31+
}
32+
33+
export default SiteHeader;

src/components/Header/index.js

Whitespace-only changes.

src/components/Layouts/MainLayout.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { Component } from "react";
2+
import { Route, Link, Switch, BrowserRouter as Router } from "react-router-dom";
3+
import { Layout, Header, Navigation, Drawer, Content } from "react-mdl";
4+
5+
import Footer from "../../components/footer/footer";
6+
import SiteHeader from "../../components/Header/SiteHeader";
7+
8+
export default ({ children }) => (
9+
<>
10+
<Layout>
11+
<SiteHeader />
12+
<Content>
13+
<div className="page-content" />
14+
</Content>
15+
<Footer />
16+
</Layout>
17+
<Footer />
18+
</>
19+
);
20+
// const MainLayout = ({children, ...rest}) => {
21+
// return (
22+
// <div className="page page-dashboard">
23+
// <div className="sidebar">This is the Second Layout</div>
24+
// <div className="main">{children}</div>
25+
// </div>
26+
// )
27+
// }
28+
29+
// const MainLayoutRoute = ({component: Component, ...rest}) => {
30+
// return (
31+
// <Route {...rest} render={matchProps => (
32+
// <MainLayout>
33+
// <Component {...matchProps} />
34+
// </MainLayout>
35+
// )} />
36+
// )
37+
// };
38+
39+
// export default MainLayoutRoute;

src/components/Layouts/UserLayout.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { Component } from "react";
2+
import { Route, Link, Switch, BrowserRouter as Router } from "react-router-dom";
3+
import { Layout, Header, Navigation, Drawer, Content } from "react-mdl";
4+
5+
import Footer from "../../components/footer/footer";
6+
7+
export default ({ children }) => (
8+
<>
9+
<Layout>
10+
<Content>
11+
<div className="page-content" />
12+
</Content>
13+
<Footer />
14+
</Layout>
15+
<Footer />
16+
</>
17+
);

src/components/PrivateRoute/PrivateRoute.jsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import React from 'react';
22
import { Route, Redirect } from 'react-router-dom';
33
import { isLogin } from '../../utils';
44

5-
const PrivateRoute = ({component: Component, ...rest}) => {
5+
const PrivateRoute = ({component:Component,layout:Layout,...rest}) => {
66
return (
7-
8-
// Show the component only when the user is logged in
9-
// Otherwise, redirect the user to /signin page
107
<Route {...rest} render={props => (
118
isLogin() ?
129
<Component {...props} />

src/components/main.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ import Contact from '../pages/Contactus'
88
import LoginPage from "../pages/LoginPage/LoginPage";
99
import SignUpPage from "../pages/SignUpPage/SignUpPage.jsx";
1010
import PrivateRoute from "../components/PrivateRoute/PrivateRoute";
11+
import MainLayout from "../components/Layouts/MainLayout";
12+
import UserLayout from "../components/Layouts/UserLayout";
1113

1214
const Main =() =>(
1315
<Switch>
14-
<Route exact path="/" component={Home} />
15-
<PrivateRoute path="/home" component={Home} />
16-
<PrivateRoute path="/tutorials" component={Tutorials} />
17-
<PrivateRoute path="/about" component={About} />
18-
<PrivateRoute path="/contact" component={Contact} />
19-
<Route exact path="/signup" component={SignUpPage} />
20-
<Route exact path="/Login" component={LoginPage} />
16+
<Route exact path="/" component={Home} layout={MainLayout} />
17+
<PrivateRoute path="/home" component={Home} layout={MainLayout} />
18+
<PrivateRoute path="/tutorials" component={Tutorials} layout={MainLayout} />
19+
<PrivateRoute path="/about" component={About} layout={MainLayout} />
20+
<PrivateRoute path="/contact" component={Contact} layout={MainLayout} />
21+
<Route exact path="/signup" component={SignUpPage} layout={UserLayout} />
22+
<Route exact path="/Login" component={LoginPage} layout={UserLayout} />
2123
</Switch>
2224
)
2325

0 commit comments

Comments
 (0)