diff --git a/src/shared/components/SearchBar.tsx b/src/shared/components/SearchBar.tsx new file mode 100644 index 0000000..cd1e080 --- /dev/null +++ b/src/shared/components/SearchBar.tsx @@ -0,0 +1,29 @@ +import { InputAdornment, TextField } from "@mui/material"; +import SearchIcon from '@mui/icons-material/Search'; +import { useContext, useState } from "react"; +import { urlbar } from "webextension-polyfill"; + +export default function SearchBar() { + const [searchTerm, setSearchTerm] = useState("") + + const handleKeydown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + window.open(`https://www.google.com/search?udm=14&q=${encodeURIComponent(searchTerm)}`) + } + } + + return ( + setSearchTerm(e.target.value)} + onKeyDown={handleKeydown} + InputProps={{ + endAdornment: ( + + + + ) + }} + /> + ) +} \ No newline at end of file diff --git a/src/site/App.tsx b/src/site/App.tsx index 091db36..2826ea3 100644 --- a/src/site/App.tsx +++ b/src/site/App.tsx @@ -8,6 +8,7 @@ import { CurrentPageContext } from '../shared/contexts/CurrentPageContext' import SettingsPage from '../shared/components/settingsPage' import LinkList from '../shared/components/LinkList' import AppSnackBar from '../shared/components/AppSnackBar' +import SearchBar from '../shared/components/SearchBar' const useLocalStorage = (storageKey: string, fallbackState: any) => { const [value, setValue] = React.useState( @@ -29,7 +30,10 @@ function App() { {currentPage === 'home' ? ( - + <> + + + ): null} {currentPage === 'edit' ? (