Skip to content

Commit

Permalink
Separate components files
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslanchek committed Nov 11, 2019
1 parent 54b2cd6 commit 0b69553
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 57 deletions.
64 changes: 7 additions & 57 deletions src/App.tsx
@@ -1,66 +1,16 @@
import React from 'react';
import { BrowserRouter, Route, Switch, NavLink } from 'react-router-dom';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import './index.css';

const HomePage = () => (
<div>
<h1>Home</h1>
<p>Welcome!</p>
</div>
);

const PublicPage = () => (
<div>
<h1>Public page</h1>
<p>Nothing special here</p>
</div>
);

const PrivatePage = () => (
<div>
<h1>Private page</h1>
<p>Wake up, Neo...</p>
</div>
);

const AuthorizePage = () => (
<div>
<h1>Authorize</h1>
<button>Press to login</button>
</div>
);
import { Nav } from './Nav';
import { HomePage } from './HomePage';
import { PublicPage } from './PublicPage';
import { PrivatePage } from './PrivatePage';
import { AuthorizePage } from './AuthorizePage';

const App: React.FC = () => {
return (
<BrowserRouter>
<header>
<ul>
<li>
<NavLink exact activeClassName='active' to='/'>
Home
</NavLink>
</li>
<li>
<NavLink exact activeClassName='active' to='/public'>
Public
</NavLink>
</li>
<li>
<NavLink exact activeClassName='active' to='/private'>
Private
</NavLink>
</li>
</ul>

<ul>
<li>
<NavLink exact activeClassName='active' to='/authorize'>
Authorize
</NavLink>
</li>
</ul>
</header>

<Nav />
<main>
<Switch>
<Route exact path='/' component={HomePage} />
Expand Down
8 changes: 8 additions & 0 deletions src/AuthorizePage.tsx
@@ -0,0 +1,8 @@
import React from 'react';

export const AuthorizePage = () => (
<div>
<h1>Authorize</h1>
<button>Press to login</button>
</div>
);
8 changes: 8 additions & 0 deletions src/HomePage.tsx
@@ -0,0 +1,8 @@
import React from 'react';

export const HomePage = () => (
<div>
<h1>Home</h1>
<p>Welcome!</p>
</div>
);
33 changes: 33 additions & 0 deletions src/Nav.tsx
@@ -0,0 +1,33 @@
import React from 'react';
import { NavLink } from 'react-router-dom';

export const Nav: React.FC = () => {
return (
<header>
<ul>
<li>
<NavLink exact activeClassName='active' to='/'>
Home
</NavLink>
</li>
<li>
<NavLink exact activeClassName='active' to='/public'>
Public
</NavLink>
</li>
<li>
<NavLink exact activeClassName='active' to='/private'>
Private
</NavLink>
</li>
</ul>
<ul>
<li>
<NavLink exact activeClassName='active' to='/authorize'>
Authorize
</NavLink>
</li>
</ul>
</header>
);
};
8 changes: 8 additions & 0 deletions src/PrivatePage.tsx
@@ -0,0 +1,8 @@
import React from 'react';

export const PrivatePage = () => (
<div>
<h1>Private page</h1>
<p>Wake up, Neo...</p>
</div>
);
8 changes: 8 additions & 0 deletions src/PublicPage.tsx
@@ -0,0 +1,8 @@
import React from 'react';

export const PublicPage = () => (
<div>
<h1>Public page</h1>
<p>Nothing special here</p>
</div>
);

0 comments on commit 0b69553

Please sign in to comment.