Skip to content

Commit c104976

Browse files
committed
fix search bar appearance withou login
1 parent 8296fc2 commit c104976

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

src/components/Navbar.jsx

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,48 @@ function Navbar({ loggedin }) {
7474
</ul>
7575
</li>
7676
</ul>
77-
78-
{/* Search Bar */}
79-
<div className="d-flex align-items-center flex-column flex-lg-row">
80-
<div className="me-2 mb-2 mb-lg-0 position-relative">
81-
<form className="input-group" onSubmit={handleSearchSubmit}>
82-
<span className="input-group-text" id="basic-addon1">
83-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-search" viewBox="0 0 16 16">
84-
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"></path>
85-
</svg>
86-
</span>
87-
<input
88-
type="text"
89-
className="form-control"
90-
placeholder="Search"
91-
value={searchTerm}
92-
onChange={handleSearchChange}
93-
/>
94-
</form>
9577

96-
{/* Suggestions Dropdown */}
97-
{suggestions.length > 0 && (
98-
<ul className="list-group position-absolute w-100 mt-1 z-index-1000" style={{ zIndex: '1000' }}>
99-
{suggestions.map((suggestion, index) => (
100-
<li
101-
key={index}
102-
className="list-group-item"
103-
onClick={() => handleSuggestionClick(suggestion)}
104-
style={{ cursor: 'pointer' }}
105-
>
106-
{suggestion.title}
107-
</li>
108-
))}
109-
</ul>
110-
)}
111-
</div>
78+
{/* Profile or Sign up Button */}
79+
{loggedin === 'true' ? (
80+
<div className="d-flex align-items-center flex-column flex-lg-row">
81+
{/* Search Bar */}
82+
<div className="me-2 mb-2 mb-lg-0 position-relative">
83+
<form className="input-group" onSubmit={handleSearchSubmit}>
84+
<span className="input-group-text" id="basic-addon1">
85+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-search" viewBox="0 0 16 16">
86+
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"></path>
87+
</svg>
88+
</span>
89+
<input
90+
type="text"
91+
className="form-control"
92+
placeholder="Search"
93+
value={searchTerm}
94+
onChange={handleSearchChange}
95+
/>
96+
</form>
11297

113-
{/* Profile or Sign up Button */}
114-
{loggedin === 'true' ? (
98+
{/* Suggestions Dropdown */}
99+
{suggestions.length > 0 && (
100+
<ul className="list-group position-absolute w-100 mt-1 z-index-1000" style={{ zIndex: '1000' }}>
101+
{suggestions.map((suggestion, index) => (
102+
<li
103+
key={index}
104+
className="list-group-item"
105+
onClick={() => handleSuggestionClick(suggestion)}
106+
style={{ cursor: 'pointer' }}
107+
>
108+
{suggestion.title}
109+
</li>
110+
))}
111+
</ul>
112+
)}
113+
</div>
115114
<span><Link className="btn btn-primary clk rounded-circle" to="/profile"><i className="fa-regular fa-user"></i></Link> Profile</span>
116-
) : (
117-
<Link className="btn btn-primary clk" to="/login">Sign up</Link>
118-
)}
119-
</div>
115+
</div>
116+
) : (
117+
<Link className="btn btn-primary clk" to="/login">Sign up</Link>
118+
)}
120119
</div>
121120
</div>
122121
</nav>

0 commit comments

Comments
 (0)