From 8d23f17f76a4a00dee8bb47031b87263258e27a3 Mon Sep 17 00:00:00 2001 From: Imbus Date: Mon, 13 Nov 2023 09:34:32 +0100 Subject: [PATCH] Better login modal, post layout fixing --- client-solid/src/Icons.tsx | 17 ++++ client-solid/src/LoginModal.tsx | 67 ++++++++++++++ client-solid/src/Navbar.tsx | 88 +++++++----------- client-solid/src/Posts.tsx | 21 +++-- client-solid/src/{ => RegLogin}/Login.tsx | 62 ++++++------- client-solid/src/RegLogin/Register.tsx | 103 ++++++++++++++++++++++ client-solid/src/Root.tsx | 9 +- client-solid/src/SinglePost.tsx | 2 - client-solid/src/api.ts | 1 - 9 files changed, 269 insertions(+), 101 deletions(-) create mode 100644 client-solid/src/Icons.tsx create mode 100644 client-solid/src/LoginModal.tsx rename client-solid/src/{ => RegLogin}/Login.tsx (63%) create mode 100644 client-solid/src/RegLogin/Register.tsx diff --git a/client-solid/src/Icons.tsx b/client-solid/src/Icons.tsx new file mode 100644 index 0000000..b4ce6fb --- /dev/null +++ b/client-solid/src/Icons.tsx @@ -0,0 +1,17 @@ +export function Arrow() { + return ( + + + + ); +} diff --git a/client-solid/src/LoginModal.tsx b/client-solid/src/LoginModal.tsx new file mode 100644 index 0000000..4e9f2f2 --- /dev/null +++ b/client-solid/src/LoginModal.tsx @@ -0,0 +1,67 @@ +import { onCleanup, useContext } from "solid-js"; +import { ModalContext } from "./Root"; +import { LoginForm } from "./RegLogin/Login"; +import { RegisterForm } from "./RegLogin/Register"; + +export function LoginModal() { + const modal_ctx = useContext(ModalContext); + + if (!modal_ctx) { + // Handle the case where ModalContext is not available + return null; + } + + const closeModal = () => { + modal_ctx.setLoginModalOpen(false); + }; + + // Close the modal when the component is unmounted + onCleanup(() => { + modal_ctx.setLoginModalOpen(false); + }); + + return ( + <> + {modal_ctx.loginModalOpen() && ( + + + + + )} + + ); +} diff --git a/client-solid/src/Navbar.tsx b/client-solid/src/Navbar.tsx index 832165d..c4485b8 100644 --- a/client-solid/src/Navbar.tsx +++ b/client-solid/src/Navbar.tsx @@ -2,26 +2,23 @@ import { useContext } from "solid-js"; import { A } from "@solidjs/router"; import { LoginContext } from "./Root"; import { ModalContext } from "./Root"; -import { LoginForm } from "./Login"; + +function MenuItem(props: { href: string; children: any }) { + return ( +
  • + + {props.children} + +
  • + ); +} function Menu() { let login_ctx = useContext(LoginContext); return ( -