mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-15 17:56:21 +01:00
Update SearchBar
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user