Skip to content

Commit

Permalink
feat: add skeleton navbar and routing capability (#35)
Browse files Browse the repository at this point in the history
* feat: add skeleton navbar and routing capability

* style: add missing semicolon in index.tsx

* style: add missing semicolon in LandingPage.tsx
  • Loading branch information
nareha authored Feb 5, 2024
1 parent f004663 commit 13aeb66
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 75 deletions.
39 changes: 39 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
Expand Down
38 changes: 0 additions & 38 deletions frontend/src/App.css

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/App.test.tsx

This file was deleted.

40 changes: 14 additions & 26 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
import React from 'react';
import axios from 'axios';
import logo from './logo.svg';
import './App.css';
import { Routes, Route } from 'react-router-dom';

const apiCall = () => {
axios.get('http://localhost:9000').then((data) => {
console.log(data.data)
})
}
import Navbar from './components/Navbar/Navbar';
import LandingPage from './components/LandingPage/LandingPage';
import ProfilePage from './components/ProfilePage/ProfilePage';
import NotFoundPage from './components/404Page/404Page';

function App() {
const App: React.FC = () => {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<button onClick={apiCall}>Make API Call</button>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<>
<Navbar />
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="/profile" element={<ProfilePage />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</>
);
}

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/404Page/404Page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

const NotFoundPage: React.FC = () => <p>404: Not Found</p>;

export default NotFoundPage;
18 changes: 18 additions & 0 deletions frontend/src/components/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import axios from 'axios';

const apiCall = () => {
axios.get('http://localhost:9000').then((data) => {
console.log(data.data);
})
}

const LandingPage: React.FC = () => {
return (
<div>
<button onClick={apiCall}>Get a message from Mickey!</button>
</div>
);
}

export default LandingPage;
13 changes: 13 additions & 0 deletions frontend/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { NavLink } from 'react-router-dom';

const Navbar: React.FC = () => {
return (
<nav>
<NavLink to="/"><p>Home</p></NavLink>
<NavLink to="/profile"><p>Profile</p></NavLink>
</nav>
);
}

export default Navbar;
6 changes: 6 additions & 0 deletions frontend/src/components/ProfilePage/ProfilePage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.info-container {
margin: auto;
width: 50%;
border-style: solid;
border-color: black;
}
13 changes: 13 additions & 0 deletions frontend/src/components/ProfilePage/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import './ProfilePage.css';

const ProfilePage: React.FC = () => {
return (
<div className="info-container">
<p>Name: Mickey Mouse</p>
<p>Email: [email protected]</p>
</div>
);
}

export default ProfilePage;
7 changes: 6 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';

import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);

root.render(
<React.StrictMode>
<App />
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);

Expand Down
1 change: 0 additions & 1 deletion frontend/src/logo.svg

This file was deleted.

0 comments on commit 13aeb66

Please sign in to comment.