Update SearchBar

This commit is contained in:
Thomas "ajnart" Camlong
2022-04-28 17:27:39 +02:00
parent 8d7c03eaf9
commit 7c93ff8a29

View File

@@ -1,11 +1,28 @@
import { Input, TextInput, Text, ActionIcon, useMantineTheme, Center } from '@mantine/core'; import {
Input,
TextInput,
Text,
ActionIcon,
useMantineTheme,
Center,
Popover,
} from '@mantine/core';
import { useForm } from '@mantine/hooks'; import { useForm } from '@mantine/hooks';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { Search, ArrowRight, ArrowLeft, BrandYoutube, Download } from 'tabler-icons-react'; import {
Search,
ArrowRight,
ArrowLeft,
BrandYoutube,
Download,
InfoCircle,
FileX,
} from 'tabler-icons-react';
import { Config, loadConfig } from '../../tools/config'; import { Config, loadConfig } from '../../tools/config';
export default function SearchBar(props: any) { export default function SearchBar(props: any) {
const [opened, setOpened] = useState(false);
const [icon, setIcon] = useState(<Search />); const [icon, setIcon] = useState(<Search />);
const theme = useMantineTheme(); const theme = useMantineTheme();
const [config, setConfig] = useState<Config>({ const [config, setConfig] = useState<Config>({
@@ -20,7 +37,6 @@ export default function SearchBar(props: any) {
querry: '', querry: '',
}, },
}); });
useEffect(() => { useEffect(() => {
const config = loadConfig('settings'); const config = loadConfig('settings');
if (config) { if (config) {
@@ -66,17 +82,37 @@ export default function SearchBar(props: any) {
} }
})} })}
> >
<TextInput <Popover
variant="filled" opened={opened}
color="blue" style={{
icon={<Search size={18} />} width: '100%',
radius="md" }}
rightSection={icon} position="bottom"
size="md" placement="start"
placeholder="Search the web" withArrow
{...props} trapFocus={false}
{...form.getInputProps('querry')} transition="pop-top-left"
/> onFocusCapture={() => setOpened(true)}
onBlurCapture={() => setOpened(false)}
target={
<TextInput
variant="filled"
color="blue"
icon={<Search size={18} />}
radius="md"
rightSection={icon}
size="md"
placeholder="Search the web"
{...props}
{...form.getInputProps('querry')}
/>
}
>
<Text>
tip: You can prefix your querry with <b>!yt</b> or <b>!t</b> to research on youtube or for
a torrent
</Text>
</Popover>
</form> </form>
); );
} }