diff --git a/client-solid/src/Icons.tsx b/client-solid/src/Icons.tsx index 9e9995e..9e1ab36 100644 --- a/client-solid/src/Icons.tsx +++ b/client-solid/src/Icons.tsx @@ -42,3 +42,76 @@ export function Bars(): JSXElement { ); } + +export function UserCircle(): JSXElement { + return ( + + + + ); +} + +export function Flake(): JSXElement { + return ( + + + + ); +} + +export function Plus(): JSXElement { + return ( + + + + ); +} + +export function Home(): JSXElement { + return ( + + + + ); +} diff --git a/client-solid/src/LoginModal.tsx b/client-solid/src/LoginModal.tsx index 07249e5..5f5b0b4 100644 --- a/client-solid/src/LoginModal.tsx +++ b/client-solid/src/LoginModal.tsx @@ -1,4 +1,4 @@ -import { JSXElement, onCleanup, useContext } from "solid-js"; +import { JSXElement, Show, onCleanup, useContext } from "solid-js"; import { ModalContext } from "./Root"; import { LoginForm } from "./RegLogin/Login"; import { RegisterForm } from "./RegLogin/Register"; @@ -21,47 +21,45 @@ export function LoginModal(): JSXElement { }); return ( - <> - {modal_ctx.loginModalOpen() && ( - - + ); } diff --git a/client-solid/src/Navbar.tsx b/client-solid/src/Navbar.tsx index a862e1e..2ed5fea 100644 --- a/client-solid/src/Navbar.tsx +++ b/client-solid/src/Navbar.tsx @@ -1,7 +1,8 @@ -import { JSXElement, createEffect, createSignal, useContext } from "solid-js"; +import { JSXElement, Show, useContext } from "solid-js"; import { A } from "@solidjs/router"; import { LoginContext } from "./Root"; import { ModalContext } from "./Root"; +import { Flake, Home, Plus, UserCircle } from "./Icons"; // Represents a single list item in the menu bar function MenuItem(props: { href: string; children: JSXElement }): JSXElement { @@ -19,8 +20,14 @@ function Menu(): JSXElement { const login_ctx = useContext(LoginContext); return ( ); } @@ -28,7 +35,6 @@ function Menu(): JSXElement { export function Navbar(): JSXElement { const modal_ctx = useContext(ModalContext); const login_ctx = useContext(LoginContext); - const [buttonText, setButtonText] = createSignal("Login"); const logout = (): void => { localStorage.removeItem("token"); @@ -37,17 +43,6 @@ export function Navbar(): JSXElement { login_ctx?.setUsername(""); }; - // Function to instantly elect 50 cent as president and declare war on north korea - const capitalizeFirst = (str: string): string => { - return str.charAt(0).toUpperCase() + str.slice(1); - }; - - createEffect(() => { - if (login_ctx?.token() != "") - setButtonText(capitalizeFirst(login_ctx?.username() ?? "") + " (Logout)"); - else setButtonText("Login"); - }, 0); - const clickHandler = (): void => { if (login_ctx?.token() != "") logout(); else modal_ctx?.setLoginModalOpen(true); @@ -56,7 +51,8 @@ export function Navbar(): JSXElement { return ( diff --git a/client-solid/src/NewPost.tsx b/client-solid/src/NewPost.tsx index 33f62c5..552e237 100644 --- a/client-solid/src/NewPost.tsx +++ b/client-solid/src/NewPost.tsx @@ -1,4 +1,4 @@ -import { JSXElement, Show, createSignal, useContext } from "solid-js"; +import { JSXElement, Show, createSignal, onMount, useContext } from "solid-js"; import { createPost } from "./api"; import { NewPost } from "./api"; import { useNavigate } from "@solidjs/router"; @@ -28,6 +28,10 @@ export function NewPostInputArea(): JSXElement { } }; + onMount(() => { + if (login_ctx?.token() == "") nav("/"); + }); + return ( - {posts().map((post) => { - return ; - })} + + {(post): JSXElement => } + ); } @@ -27,7 +27,7 @@ export function Posts(): JSXElement { export function PostSegment({ post }: { post: Post }): JSXElement { const nav = useNavigate(); return ( -
+

{post?.content}