aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components')
-rw-r--r--frontend/src/components/Sidebar/Content.tsx2
-rw-r--r--frontend/src/components/Sidebar/Search.tsx9
-rw-r--r--frontend/src/components/Sidebar/Sidebar.module.css3
-rw-r--r--frontend/src/components/Sidebar/Sidebar.tsx11
4 files changed, 14 insertions, 11 deletions
diff --git a/frontend/src/components/Sidebar/Content.tsx b/frontend/src/components/Sidebar/Content.tsx
index ceb9e67..6aade15 100644
--- a/frontend/src/components/Sidebar/Content.tsx
+++ b/frontend/src/components/Sidebar/Content.tsx
@@ -18,7 +18,7 @@ interface ContentProps {
18const _Content: React.FC<ContentProps> = ({ isSearching, selectedButtonIndex, handle_sidebar_click }) => { 18const _Content: React.FC<ContentProps> = ({ isSearching, selectedButtonIndex, handle_sidebar_click }) => {
19 19
20 return ( 20 return (
21 <div className="h-full"> 21 <div className="md:h-full">
22 22
23 <div className="px-2 my-2.5"> 23 <div className="px-2 my-2.5">
24 <button onClick={() => handle_sidebar_click(0)} className={`${styles.button} ${selectedButtonIndex == 0 ? styles["button-selected"] : ""} ${isSearching ? styles["button-hidden"] : ""}`}> 24 <button onClick={() => handle_sidebar_click(0)} className={`${styles.button} ${selectedButtonIndex == 0 ? styles["button-selected"] : ""} ${isSearching ? styles["button-hidden"] : ""}`}>
diff --git a/frontend/src/components/Sidebar/Search.tsx b/frontend/src/components/Sidebar/Search.tsx
index 00d9e1e..49bcec7 100644
--- a/frontend/src/components/Sidebar/Search.tsx
+++ b/frontend/src/components/Sidebar/Search.tsx
@@ -1,4 +1,4 @@
1import React, { useRef } from "react"; 1import React from "react";
2import { Link } from "react-router-dom"; 2import { Link } from "react-router-dom";
3 3
4import { Search } from "@customTypes/Search"; 4import { Search } from "@customTypes/Search";
@@ -7,21 +7,20 @@ import { UserProfile } from "@customTypes/Profile";
7 7
8interface SearchProps { 8interface SearchProps {
9 profile?: UserProfile; 9 profile?: UserProfile;
10 searchbarRef: React.RefObject<HTMLInputElement | null>;
10}; 11};
11 12
12const _Search: React.FC<SearchProps> = ({ profile }) => { 13const _Search: React.FC<SearchProps> = ({ profile, searchbarRef }) => {
13 const [searchData, setSearchData] = React.useState<Search | undefined>( 14 const [searchData, setSearchData] = React.useState<Search | undefined>(
14 undefined 15 undefined
15 ); 16 );
16 17
17 const searchbarRef = useRef<HTMLInputElement>(null);
18
19 const _handle_search_change = async (q: string) => { 18 const _handle_search_change = async (q: string) => {
20 const searchResponse = await API.get_search(q); 19 const searchResponse = await API.get_search(q);
21 setSearchData(searchResponse); 20 setSearchData(searchResponse);
22 }; 21 };
23 return ( 22 return (
24 <div className="flex w-full flex-col justify-between p-3"> 23 <div className="flex w-full flex-col p-3 not-md:absolute">
25 <input 24 <input
26 ref={searchbarRef} 25 ref={searchbarRef}
27 type="text" 26 type="text"
diff --git a/frontend/src/components/Sidebar/Sidebar.module.css b/frontend/src/components/Sidebar/Sidebar.module.css
index 9baf415..6e43254 100644
--- a/frontend/src/components/Sidebar/Sidebar.module.css
+++ b/frontend/src/components/Sidebar/Sidebar.module.css
@@ -7,6 +7,7 @@
7 transition: all 0.2s ease; 7 transition: all 0.2s ease;
8 padding: 4px 0px; 8 padding: 4px 0px;
9 height: 48px; 9 height: 48px;
10 gap: 24px;
10} 11}
11 12
12.button:hover, 13.button:hover,
@@ -25,7 +26,7 @@ button>span {
25 font-size: 22px; 26 font-size: 22px;
26 font-family: var(--font-barlow-semicondensed-regular); 27 font-family: var(--font-barlow-semicondensed-regular);
27 white-space: nowrap; 28 white-space: nowrap;
28 margin-left: 16px; 29 transition: all 0.2s ease;
29} 30}
30 31
31.button-hidden>span { 32.button-hidden>span {
diff --git a/frontend/src/components/Sidebar/Sidebar.tsx b/frontend/src/components/Sidebar/Sidebar.tsx
index 77e23a6..f280a59 100644
--- a/frontend/src/components/Sidebar/Sidebar.tsx
+++ b/frontend/src/components/Sidebar/Sidebar.tsx
@@ -1,4 +1,4 @@
1import React, { useCallback } from "react"; 1import React, { useCallback, useRef } from "react";
2import { useLocation } from "react-router-dom"; 2import { useLocation } from "react-router-dom";
3import { UserProfile } from "@customTypes/Profile"; 3import { UserProfile } from "@customTypes/Profile";
4 4
@@ -24,6 +24,8 @@ const Sidebar: React.FC<SidebarProps> = ({
24 const [isSearching, setIsSearching] = React.useState<boolean>(false); 24 const [isSearching, setIsSearching] = React.useState<boolean>(false);
25 const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1); 25 const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1);
26 26
27 const searchbarRef = useRef<HTMLInputElement>(null);
28
27 const location = useLocation(); 29 const location = useLocation();
28 const path = location.pathname; 30 const path = location.pathname;
29 31
@@ -34,6 +36,7 @@ const Sidebar: React.FC<SidebarProps> = ({
34 if (clicked_sidebar_idx == 0 && !isSearching) { 36 if (clicked_sidebar_idx == 0 && !isSearching) {
35 if (!isSearching) { 37 if (!isSearching) {
36 setIsSearching(true); 38 setIsSearching(true);
39 searchbarRef.current?.focus();
37 } 40 }
38 } else { 41 } else {
39 setIsSearching(false); 42 setIsSearching(false);
@@ -57,13 +60,13 @@ const Sidebar: React.FC<SidebarProps> = ({
57 }, [path]); 60 }, [path]);
58 61
59 return ( 62 return (
60 <div className={`h-screen w-80 not-md:w-full text-white bg-block flex flex-col not-md:flex-row not-md:bg-gradient-to-t not-md:from-block not-md:to-bright 63 <div className={`md:h-screen w-80 not-md:w-full text-white bg-block flex flex-col not-md:flex-row not-md:bg-gradient-to-t not-md:from-block not-md:to-bright
61 }`}> 64 }`}>
62 65
63 {/* Header */} 66 {/* Header */}
64 <_Header /> 67 <_Header />
65 68
66 <div className="flex flex-1 overflow-hidden w-full not-md:hidden "> 69 <div className="flex flex-1 overflow-hidden w-full">
67 <div className={`flex flex-col transition-all duration-300 ${isSearching ? "w-[64px]" : "w-full"}`}> 70 <div className={`flex flex-col transition-all duration-300 ${isSearching ? "w-[64px]" : "w-full"}`}>
68 {/* Sidebar Content */} 71 {/* Sidebar Content */}
69 <_Content isSearching={isSearching} selectedButtonIndex={selectedButtonIndex} handle_sidebar_click={handle_sidebar_click} /> 72 <_Content isSearching={isSearching} selectedButtonIndex={selectedButtonIndex} handle_sidebar_click={handle_sidebar_click} />
@@ -73,7 +76,7 @@ const Sidebar: React.FC<SidebarProps> = ({
73 </div> 76 </div>
74 77
75 <div className={`flex bg-panel ${isSearching ? 'w-full' : "w-0"}`}> 78 <div className={`flex bg-panel ${isSearching ? 'w-full' : "w-0"}`}>
76 <_Search profile={profile} /> 79 <_Search profile={profile} searchbarRef={searchbarRef} />
77 </div> 80 </div>
78 81
79 </div> 82 </div>