Showing
7 changed files
with
110 additions
and
32 deletions
1 | -import { Outlet, useLocation } from "react-router-dom"; | ||
2 | // components | 1 | // components |
3 | import Bottombar from "./components/Bottombar"; | 2 | import Bottombar from "./components/Bottombar"; |
4 | import Topbar from "./components/Topbar"; | 3 | import Topbar from "./components/Topbar"; |
5 | 4 | ||
6 | function App() { | 5 | function App() { |
7 | - let location = useLocation(); | ||
8 | - | ||
9 | - const renderByLocation = () => { | ||
10 | - if (location.pathname != "/") { | ||
11 | - return <Outlet />; | ||
12 | - } | ||
13 | - return ( | ||
14 | - <div> | ||
15 | - <h1>chatroom</h1> | ||
16 | - </div> | ||
17 | - ); | ||
18 | - }; | ||
19 | - | ||
20 | return ( | 6 | return ( |
21 | <div> | 7 | <div> |
22 | <Topbar /> | 8 | <Topbar /> |
23 | - {renderByLocation()} | 9 | + <h1>Chatroom</h1> |
24 | <Bottombar /> | 10 | <Bottombar /> |
25 | </div> | 11 | </div> |
26 | ); | 12 | ); | ... | ... |
1 | import React from "react"; | 1 | import React from "react"; |
2 | import ReactDOM from "react-dom/client"; | 2 | import ReactDOM from "react-dom/client"; |
3 | -import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom"; | 3 | +import { BrowserRouter, Routes, Route } from "react-router-dom"; |
4 | import reportWebVitals from "./reportWebVitals"; | 4 | import reportWebVitals from "./reportWebVitals"; |
5 | import App from "./App"; | 5 | import App from "./App"; |
6 | // routes | 6 | // routes |
... | @@ -14,12 +14,12 @@ const root = ReactDOM.createRoot(document.getElementById("root")); | ... | @@ -14,12 +14,12 @@ const root = ReactDOM.createRoot(document.getElementById("root")); |
14 | root.render( | 14 | root.render( |
15 | <BrowserRouter> | 15 | <BrowserRouter> |
16 | <Routes> | 16 | <Routes> |
17 | - <Route path="/" element={<App />}> | 17 | + // root route is for chatroom |
18 | - <Route path="/userroom" element={<Userroom />} /> | 18 | + <Route path="/" element={<App />} /> |
19 | - <Route path="/settings" element={<Settings />} /> | ||
20 | - </Route> | ||
21 | <Route path="/login" element={<Login />} /> | 19 | <Route path="/login" element={<Login />} /> |
22 | <Route path="/signup" element={<Signup />} /> | 20 | <Route path="/signup" element={<Signup />} /> |
21 | + <Route path="/userroom" element={<Userroom />} /> | ||
22 | + <Route path="/settings" element={<Settings />} /> | ||
23 | </Routes> | 23 | </Routes> |
24 | </BrowserRouter> | 24 | </BrowserRouter> |
25 | ); | 25 | ); | ... | ... |
1 | +// styles | ||
2 | +import { Link } from "react-router-dom"; | ||
3 | +import "../styles/layout.scss"; | ||
4 | + | ||
1 | function Login() { | 5 | function Login() { |
6 | + const handleSubmit = (e) => { | ||
7 | + e.preventDefault(); | ||
8 | + console.log("login form submit called"); | ||
9 | + }; | ||
10 | + | ||
2 | return ( | 11 | return ( |
3 | - <div> | 12 | + <div className="container"> |
4 | - <h1>Login page</h1> | 13 | + <h1>Welcome back to Weather-Chatbot/Messanger!</h1> |
14 | + <h2>Stay connected with weather/friends all the time</h2> | ||
15 | + | ||
16 | + <button>Login with Google</button> | ||
17 | + <button>Login with GitHub</button> | ||
18 | + | ||
19 | + <br /> | ||
20 | + | ||
21 | + <form className="authForm" onSubmit={(e) => handleSubmit(e)}> | ||
22 | + <label htmlFor="email"> | ||
23 | + email: <input type="text" id="email" /> | ||
24 | + </label> | ||
25 | + <label htmlFor="password"> | ||
26 | + password: <input type="text" id="password" /> | ||
27 | + </label> | ||
28 | + <label htmlFor="submit"> | ||
29 | + <input type="submit" id="submit" /> | ||
30 | + </label> | ||
31 | + </form> | ||
32 | + | ||
33 | + <br /> | ||
34 | + | ||
35 | + <p> | ||
36 | + Don't have an account? <Link to="/signup">Create account</Link> | ||
37 | + </p> | ||
5 | </div> | 38 | </div> |
6 | ); | 39 | ); |
7 | } | 40 | } | ... | ... |
1 | +// components | ||
2 | +import Bottombar from "../components/Bottombar"; | ||
3 | +import Topbar from "../components/Topbar"; | ||
4 | + | ||
1 | function Settings() { | 5 | function Settings() { |
2 | return ( | 6 | return ( |
3 | - <div> | 7 | + <> |
4 | - <h1>Settings page</h1> | 8 | + <Topbar /> |
5 | - <div>username</div> | 9 | + <div> |
6 | - <div>email</div> | 10 | + <h1>Settings page</h1> |
7 | - <div>birthday</div> | 11 | + <div>username</div> |
8 | - <br /> | 12 | + <div>email</div> |
9 | - <button>notification</button> | 13 | + <div>birthday</div> |
10 | - </div> | 14 | + <br /> |
15 | + <button>notification</button> | ||
16 | + </div> | ||
17 | + <Bottombar /> | ||
18 | + </> | ||
11 | ); | 19 | ); |
12 | } | 20 | } |
13 | 21 | ... | ... |
1 | +import { Link } from "react-router-dom"; | ||
2 | +// styles | ||
3 | +import "../styles/layout.scss"; | ||
4 | + | ||
1 | function Signup() { | 5 | function Signup() { |
6 | + const handleSubmit = (e) => { | ||
7 | + e.preventDefault(); | ||
8 | + console.log("signup form submit called"); | ||
9 | + }; | ||
10 | + | ||
2 | return ( | 11 | return ( |
3 | - <div> | 12 | + <div className="container"> |
4 | - <h1>Signup page</h1> | 13 | + <h1>Welcome to Weather-Chatbot/Messanger!</h1> |
14 | + <h2>Stay connected with weather/friends all the time</h2> | ||
15 | + | ||
16 | + <button>Create account with Google</button> | ||
17 | + <button>Create account with GitHub</button> | ||
18 | + | ||
19 | + <br /> | ||
20 | + | ||
21 | + <form className="authForm" onSubmit={(e) => handleSubmit(e)}> | ||
22 | + <label htmlFor="username"> | ||
23 | + username: <input type="text" id="username" /> | ||
24 | + </label> | ||
25 | + <label htmlFor="email"> | ||
26 | + email: <input type="text" id="email" /> | ||
27 | + </label> | ||
28 | + <label htmlFor="password"> | ||
29 | + password: <input type="text" id="password" /> | ||
30 | + </label> | ||
31 | + <label htmlFor="submit"> | ||
32 | + <input type="submit" id="submit" /> | ||
33 | + </label> | ||
34 | + </form> | ||
35 | + | ||
36 | + <br /> | ||
37 | + | ||
38 | + <p> | ||
39 | + Have an account? <Link to="/login">Login</Link> | ||
40 | + </p> | ||
5 | </div> | 41 | </div> |
6 | ); | 42 | ); |
7 | } | 43 | } | ... | ... |
1 | +// components | ||
2 | +import Bottombar from "../components/Bottombar"; | ||
3 | +import Topbar from "../components/Topbar"; | ||
4 | + | ||
1 | function Userroom() { | 5 | function Userroom() { |
2 | return ( | 6 | return ( |
3 | <div> | 7 | <div> |
8 | + <Topbar /> | ||
4 | <h1>Userroom page</h1> | 9 | <h1>Userroom page</h1> |
10 | + <Bottombar /> | ||
5 | </div> | 11 | </div> |
6 | ); | 12 | ); |
7 | } | 13 | } | ... | ... |
-
Please register or login to post a comment