From 259f36390194e2bbfbb6f2d849783ff1d483e6b0 Mon Sep 17 00:00:00 2001 From: Benjamin Bolte Date: Thu, 1 Aug 2024 22:22:13 -0700 Subject: [PATCH] fix ui bugs --- .../src/components/listing/ListingBody.tsx | 30 ++++++ .../src/components/listing/ListingFooter.tsx | 20 ++++ .../src/components/listing/ListingHeader.tsx | 37 +++++++ .../src/components/listing/ListingTitle.tsx | 16 --- frontend/src/components/nav/Navbar.tsx | 15 +-- frontend/src/components/nav/Sidebar.tsx | 102 ++++++++++++------ frontend/src/pages/APIKeys.tsx | 26 +++-- frontend/src/pages/Home.tsx | 2 +- frontend/src/pages/ListingDetails.tsx | 42 ++------ frontend/src/pages/Profile.tsx | 26 +++-- 10 files changed, 200 insertions(+), 116 deletions(-) create mode 100644 frontend/src/components/listing/ListingBody.tsx create mode 100644 frontend/src/components/listing/ListingFooter.tsx create mode 100644 frontend/src/components/listing/ListingHeader.tsx delete mode 100644 frontend/src/components/listing/ListingTitle.tsx diff --git a/frontend/src/components/listing/ListingBody.tsx b/frontend/src/components/listing/ListingBody.tsx new file mode 100644 index 00000000..7ce6c67d --- /dev/null +++ b/frontend/src/components/listing/ListingBody.tsx @@ -0,0 +1,30 @@ +import { paths } from "gen/api"; +import ListingArtifacts from "./ListingArtifacts"; +import ListingChildren from "./ListingChildren"; +import ListingDescription from "./ListingDescription"; + +type ListingResponse = + paths["/listings/{id}"]["get"]["responses"][200]["content"]["application/json"]; + +interface ListingBodyProps { + listing: ListingResponse; +} + +const ListingBody = (props: ListingBodyProps) => { + const { listing } = props; + return ( +
+ + + +
+ ); +}; + +export default ListingBody; diff --git a/frontend/src/components/listing/ListingFooter.tsx b/frontend/src/components/listing/ListingFooter.tsx new file mode 100644 index 00000000..e262e26c --- /dev/null +++ b/frontend/src/components/listing/ListingFooter.tsx @@ -0,0 +1,20 @@ +import ListingDeleteButton from "./ListingDeleteButton"; + +interface Props { + listing_id: string; + edit: boolean; +} + +const ListingFooter = ({ listing_id, edit }: Props) => { + if (!edit) { + return <>; + } + + return ( +
+ +
+ ); +}; + +export default ListingFooter; diff --git a/frontend/src/components/listing/ListingHeader.tsx b/frontend/src/components/listing/ListingHeader.tsx new file mode 100644 index 00000000..96358714 --- /dev/null +++ b/frontend/src/components/listing/ListingHeader.tsx @@ -0,0 +1,37 @@ +import { Button } from "components/ui/Button/Button"; +import { FaTimes } from "react-icons/fa"; +import { useNavigate } from "react-router-dom"; + +interface Props { + title: string; + edit: boolean; +} + +const CloseButton = () => { + const navigate = useNavigate(); + + return ( + + ); +}; + +const ListingHeader = (props: Props) => { + const { title } = props; + return ( +
+
+

{title}

+ +
+
+ ); +}; + +export default ListingHeader; diff --git a/frontend/src/components/listing/ListingTitle.tsx b/frontend/src/components/listing/ListingTitle.tsx deleted file mode 100644 index feebe3e5..00000000 --- a/frontend/src/components/listing/ListingTitle.tsx +++ /dev/null @@ -1,16 +0,0 @@ -interface Props { - title: string; - // TODO: If can edit, allow the user to update the title. - edit: boolean; -} - -const ListingTitle = (props: Props) => { - const { title } = props; - return ( -
-

{title}

-
- ); -}; - -export default ListingTitle; diff --git a/frontend/src/components/nav/Navbar.tsx b/frontend/src/components/nav/Navbar.tsx index 7cd32f1e..793d08a9 100644 --- a/frontend/src/components/nav/Navbar.tsx +++ b/frontend/src/components/nav/Navbar.tsx @@ -1,4 +1,3 @@ -import { useAuthentication } from "hooks/auth"; import { useDarkMode } from "hooks/dark_mode"; import { useState } from "react"; import { FaMoon, FaSun, FaUserCircle } from "react-icons/fa"; @@ -10,7 +9,6 @@ const SIZE = 20; const Navbar = () => { const [showSidebar, setShowSidebar] = useState(false); const { darkMode, setDarkMode } = useDarkMode(); - const { isAuthenticated } = useAuthentication(); const navigate = useNavigate(); return ( @@ -29,22 +27,13 @@ const Navbar = () => { - - {isAuthenticated && ( - setShowSidebar(false)} /> - )} + setShowSidebar(false)} /> ); }; diff --git a/frontend/src/components/nav/Sidebar.tsx b/frontend/src/components/nav/Sidebar.tsx index e8182664..8f6d554a 100644 --- a/frontend/src/components/nav/Sidebar.tsx +++ b/frontend/src/components/nav/Sidebar.tsx @@ -1,7 +1,9 @@ import clsx from "clsx"; +import { useAuthentication } from "hooks/auth"; import { FaBookOpen, FaDoorClosed, + FaDoorOpen, FaHome, FaKey, FaLock, @@ -17,15 +19,25 @@ interface SidebarItemProps { title: string; icon?: JSX.Element; onClick?: () => void; + size?: "sm" | "md" | "lg"; } -const SidebarItem = ({ icon, title, onClick }: SidebarItemProps) => { +const SidebarItem = ({ icon, title, onClick, size }: SidebarItemProps) => { return (
  • -
  • @@ -47,6 +59,7 @@ interface Props { const Sidebar = ({ show, onClose }: Props) => { const navigate = useNavigate(); + const { isAuthenticated } = useAuthentication(); return (
    { Close menu
    -
      +
        } @@ -80,6 +93,7 @@ const Sidebar = ({ show, onClose }: Props) => { navigate("/"); onClose(); }} + size="md" /> { navigate("/browse"); onClose(); }} + size="md" /> { navigate("/create"); onClose(); }} + size="md" /> - } - onClick={() => { - navigate("/profile"); - onClose(); - }} - /> - } - onClick={() => { - navigate("/keys"); - onClose(); - }} - /> - } - onClick={() => { - navigate("/logout"); - onClose(); - }} - /> - + {isAuthenticated && ( + } + onClick={() => { + navigate("/profile"); + onClose(); + }} + size="md" + /> + )} + {isAuthenticated && ( + } + onClick={() => { + navigate("/keys"); + onClose(); + }} + size="md" + /> + )} + {isAuthenticated ? ( + } + onClick={() => { + navigate("/logout"); + onClose(); + }} + size="md" + /> + ) : ( + } + onClick={() => { + navigate("/login"); + onClose(); + }} + size="md" + /> + )} +
      +
    + {/* Aligned to bottom */} +
    +
      } @@ -130,6 +169,7 @@ const Sidebar = ({ show, onClose }: Props) => { navigate("/about"); onClose(); }} + size="sm" /> { navigate("/privacy"); onClose(); }} + size="sm" /> { navigate("/tos"); onClose(); }} + size="sm" />
    diff --git a/frontend/src/pages/APIKeys.tsx b/frontend/src/pages/APIKeys.tsx index 7602ee62..6816229e 100644 --- a/frontend/src/pages/APIKeys.tsx +++ b/frontend/src/pages/APIKeys.tsx @@ -1,16 +1,20 @@ +import RequireAuthentication from "components/auth/RequireAuthentication"; + const APIKeys = () => { return ( -
    -
    -

    - API Key -

    -

    - This page is under construction. You will be able to generate API keys - here. -

    -
    -
    + +
    +
    +

    + API Key +

    +

    + This page is under construction. You will be able to generate API + keys here. +

    +
    +
    +
    ); }; diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 1016969b..aaad8f41 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -15,7 +15,7 @@ const Home = () => { Buy and sell robots and robot parts, share hardware and software, and connect with other robot enthusiasts, all in one place.

    -
    +
    - - - - - +
    + + +
    ); }; diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx index e7b15efb..8871af0b 100644 --- a/frontend/src/pages/Profile.tsx +++ b/frontend/src/pages/Profile.tsx @@ -1,16 +1,20 @@ +import RequireAuthentication from "components/auth/RequireAuthentication"; + const Profile = () => { return ( -
    -
    -

    - Profile -

    -

    - This page is under construction. You will be able to view and edit - your profile here. -

    -
    -
    + +
    +
    +

    + Profile +

    +

    + This page is under construction. You will be able to view and edit + your profile here. +

    +
    +
    +
    ); };