From aea617500cbc52dd45ab28a7a1b41a0d344de038 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sat, 25 Feb 2023 23:11:14 +0800 Subject: [PATCH] Added buttons to header and added login page --- src/Components/Header/Header.tsx | 9 ++- src/Components/HomeIcon/HomeIcon.tsx | 44 +++++++++++++ .../Login.tsx => LoginButton/LoginButton.tsx} | 6 +- src/Routes/Login/Login.tsx | 65 +++++++++++++++++++ src/index.tsx | 5 ++ src/styles.tsx | 31 +++++++++ 6 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 src/Components/HomeIcon/HomeIcon.tsx rename src/Components/{Login/Login.tsx => LoginButton/LoginButton.tsx} (81%) create mode 100644 src/Routes/Login/Login.tsx diff --git a/src/Components/Header/Header.tsx b/src/Components/Header/Header.tsx index a895f1e..3372d35 100644 --- a/src/Components/Header/Header.tsx +++ b/src/Components/Header/Header.tsx @@ -2,7 +2,8 @@ import * as React from "react"; import styles from "../../styles"; import AppIcon from "../AppIcon/AppIcon"; -import Login from "../Login/Login"; +import Login from "../LoginButton/LoginButton"; +import HomeIcon from "../HomeIcon/HomeIcon"; export default function Header() { return ( @@ -14,7 +15,10 @@ export default function Header() { ...{ flex: 2 }, }} > - + + + +
+

Clip Notes

navigate("/")} + > +
+ + + + + + +
+ + ); +} diff --git a/src/Components/Login/Login.tsx b/src/Components/LoginButton/LoginButton.tsx similarity index 81% rename from src/Components/Login/Login.tsx rename to src/Components/LoginButton/LoginButton.tsx index ca07cc3..70448c8 100644 --- a/src/Components/Login/Login.tsx +++ b/src/Components/LoginButton/LoginButton.tsx @@ -1,10 +1,12 @@ import * as React from "react"; import { useState } from "react"; import { Button } from "@mui/material"; +import { useNavigate } from "react-router-dom"; import styles from "../../styles"; -export default function Login() { +export default function LoginButton() { const [logged_in, setLoggedIn] = useState(false); + const navigate = useNavigate(); if (!logged_in) { return (
@@ -14,7 +16,7 @@ export default function Login() { style={styles.button_green} variant="contained" onClick={() => { - setLoggedIn(true); + navigate("/Login"); }} > Login diff --git a/src/Routes/Login/Login.tsx b/src/Routes/Login/Login.tsx new file mode 100644 index 0000000..e12b6c6 --- /dev/null +++ b/src/Routes/Login/Login.tsx @@ -0,0 +1,65 @@ +import * as React from "react"; +import styles from "../../styles"; + +import { useLocation, useNavigate } from "react-router-dom"; +import Header from "../../Components/Header/Header"; +import { useState } from "react"; +import { Button } from "@mui/material"; + +export default function Login() { + const navigate = useNavigate(); + const [user, setUser] = useState({ + username: "", + password: "", + }); + console.log("We are in the" + useLocation()); + return ( +
+
+
+

Login to Clip Notes

+
+

Username

+
+ { + setUser({ ...user, username: e.target.value }); + }} + maxLength={20} + /> +
+
+

Password

+
+ { + setUser({ ...user, password: e.target.value }); + }} + maxLength={20} + /> +
+ + +
+
+ ); +} diff --git a/src/index.tsx b/src/index.tsx index 320d3b5..969107b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,6 +6,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom"; import Home from "./Routes/Home/Home"; import NewNote from "./Routes/NewNote/NewNote"; +import Login from "./Routes/Login/Login"; import { QueryClient, QueryClientProvider } from "react-query"; @@ -20,6 +21,10 @@ const router = createBrowserRouter([ path: "/NewNote", element: , }, + { + path: "/Login", + element: , + }, ]); const root = ReactDOM.createRoot( diff --git a/src/styles.tsx b/src/styles.tsx index e4fc715..970e2b6 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -22,6 +22,17 @@ const styles: { [key: string]: React.CSSProperties } = { alignItems: "center", justifyContent: "center", }, + window: { + alignSelf: "center", + width: "60%", + minHeight: "128px", + display: "flex", + flexDirection: "column", + backgroundColor: "#0087e4", + margin: 16, + padding: 16, + borderRadius: 16, + }, note: { display: "flex", flexDirection: "column", @@ -78,6 +89,17 @@ const styles: { [key: string]: React.CSSProperties } = { display: "flex", flexDirection: "row", width: "256x", + marginTop: 4, + marginBottom: 4, + }, + button_yellow: { + backgroundColor: "#e2b465", + alignSelf: "center", + display: "flex", + flexDirection: "row", + width: "256x", + marginTop: 4, + marginBottom: 4, }, button_red: { backgroundColor: "#bc231e", @@ -85,6 +107,8 @@ const styles: { [key: string]: React.CSSProperties } = { display: "flex", flexDirection: "row", width: "256px", + marginTop: 4, + marginBottom: 4, }, text_small: { color: "white", @@ -92,6 +116,13 @@ const styles: { [key: string]: React.CSSProperties } = { fontWeight: "bold", textAlign: "center", }, + text_small_red: { + color: "#bc231e", + fontSize: "2vh", + fontWeight: "bold", + textAlign: "center", + }, + text_medium: { color: "white", fontSize: "4vh",