|
1 | | -import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; |
| 1 | +import { useState } from "react"; |
| 2 | +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; |
2 | 3 | import { |
3 | 4 | faBars, |
4 | 5 | faBook, faBoxesStacked, faClock, |
5 | 6 | faCode, faFolder, |
6 | 7 | faMagnifyingGlass, |
7 | 8 | faPalette |
8 | 9 | } from "@fortawesome/free-solid-svg-icons"; |
9 | | -import {faGithub} from "@fortawesome/free-brands-svg-icons"; |
| 10 | +import { faGithub } from "@fortawesome/free-brands-svg-icons"; |
10 | 11 |
|
11 | 12 | export interface Props { |
12 | 13 | searchCallback: (search: string) => void |
13 | 14 | } |
14 | 15 |
|
15 | 16 | export default function NavBar(props: Props) { |
| 17 | + const [searchFocused, setSearchFocused] = useState(false); |
| 18 | + |
16 | 19 | const onThemeChange = () => { |
17 | 20 | const theme = (document.querySelector('input[name="theme-dropdown"]:checked')! as HTMLInputElement).value; |
18 | 21 | localStorage.setItem('theme', JSON.stringify(theme)); |
@@ -43,11 +46,10 @@ export default function NavBar(props: Props) { |
43 | 46 | } |
44 | 47 | } |
45 | 48 |
|
46 | | - |
47 | 49 | return ( |
48 | 50 | <> |
49 | 51 | <div> |
50 | | - <div className="navbar bg-base-100 fixed z-10 border-b-2 border-b-base-300 h-14" id="navbar_anchor"> |
| 52 | + <div className="navbar bg-base-100 fixed z-10 border-b-2 border-b-base-300 h-[4.5rem]" id="navbar_anchor"> |
51 | 53 | <div className="navbar-start"> |
52 | 54 | <div className="dropdown"> |
53 | 55 | <div tabIndex={0} role="button" className="btn btn-ghost btn-circle"> |
@@ -118,10 +120,19 @@ export default function NavBar(props: Props) { |
118 | 120 | </div> |
119 | 121 | </div> |
120 | 122 | <div className="navbar-center"> |
121 | | - <label className="cursor-text input input-bordered hidden items-center gap-2 lg:w-96 lg:flex"> |
| 123 | + <label |
| 124 | + className={`cursor-text input input-bordered hidden items-center gap-2 lg:w-96 lg:flex${searchFocused ? " input-primary" : ""}`} |
| 125 | + > |
122 | 126 | <FontAwesomeIcon icon={faMagnifyingGlass}/> |
123 | | - <input type="text" className="grow" id="search_bar" placeholder="Search" |
124 | | - onKeyUp={() => props.searchCallback((document.getElementById("search_bar")! as HTMLInputElement).value)}/> |
| 127 | + <input |
| 128 | + type="text" |
| 129 | + className="grow" |
| 130 | + id="search_bar" |
| 131 | + placeholder="Search" |
| 132 | + onKeyUp={() => props.searchCallback((document.getElementById("search_bar")! as HTMLInputElement).value)} |
| 133 | + onFocus={() => setSearchFocused(true)} |
| 134 | + onBlur={() => setSearchFocused(false)} |
| 135 | + /> |
125 | 136 | <kbd className="kbd kbd-sm select-none cursor-text">ctrl</kbd> |
126 | 137 | <kbd className="kbd kbd-sm select-none cursor-text">k</kbd> |
127 | 138 | </label> |
|
0 commit comments