Skip to content

Commit

Permalink
Merge pull request #4 from WildCodeSchool/feature/router
Browse files Browse the repository at this point in the history
ajout des différents fichiers (pages et dossiers) et mise en place du…
  • Loading branch information
Etimo285 authored Feb 12, 2025
2 parents f6926b7 + e8d0f42 commit cc29087
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 159 deletions.
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="fr">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
Expand Down
70 changes: 69 additions & 1 deletion frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.5"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
Expand Down
42 changes: 0 additions & 42 deletions frontend/src/App.css

This file was deleted.

52 changes: 15 additions & 37 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,17 @@
import { useState } from 'react';
import reactLogo from './assets/react.svg';
import viteLogo from '/vite.svg';
import './App.css';
import { Routes, Route, BrowserRouter } from 'react-router-dom';
import Layout from './pages/Layout';
import Home from './pages/home/Home';

function App() {
const [count, setCount] = useState(0);
const App = () => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />}/>
</Route>
</Routes>
</BrowserRouter>
);
};

return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img
src={reactLogo}
className="logo react"
alt="React logo"
/>
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
);
}

export default App;
export default App;
1 change: 0 additions & 1 deletion frontend/src/assets/react.svg

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
68 changes: 0 additions & 68 deletions frontend/src/index.css

This file was deleted.

19 changes: 11 additions & 8 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App.tsx';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
const rootElement = document.getElementById('root') as HTMLElement;

const root = ReactDOM.createRoot(rootElement);

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
11 changes: 11 additions & 0 deletions frontend/src/pages/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Outlet } from "react-router-dom"

const Layout = () => {
return(
<main className="main-content">
<Outlet />
</main>
)
}

export default Layout
10 changes: 10 additions & 0 deletions frontend/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Home = () => {
return (
<div>
<h1>Home</h1>
<p>Welcome to the home page!</p>
</div>
);
}

export default Home;
Empty file.

0 comments on commit cc29087

Please sign in to comment.