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,6 +82,19 @@ export default function SearchBar(props: any) {
} }
})} })}
> >
<Popover
opened={opened}
style={{
width: '100%',
}}
position="bottom"
placement="start"
withArrow
trapFocus={false}
transition="pop-top-left"
onFocusCapture={() => setOpened(true)}
onBlurCapture={() => setOpened(false)}
target={
<TextInput <TextInput
variant="filled" variant="filled"
color="blue" color="blue"
@@ -77,6 +106,13 @@ export default function SearchBar(props: any) {
{...props} {...props}
{...form.getInputProps('querry')} {...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>
); );
} }