mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-07 05:55:48 +01:00
@@ -1,15 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import {
|
import { Text, AspectRatio, Card, Image, Center, Grid, createStyles } from '@mantine/core';
|
||||||
Text,
|
|
||||||
AspectRatio,
|
|
||||||
Card,
|
|
||||||
Image,
|
|
||||||
useMantineTheme,
|
|
||||||
Center,
|
|
||||||
Grid,
|
|
||||||
createStyles,
|
|
||||||
} from '@mantine/core';
|
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { serviceItem } from '../../tools/types';
|
import { serviceItem } from '../../tools/types';
|
||||||
import AppShelfMenu from './AppShelfMenu';
|
import AppShelfMenu from './AppShelfMenu';
|
||||||
|
|||||||
@@ -90,22 +90,6 @@ function SettingsMenu(props: any) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
<Group direction="column">
|
|
||||||
<Switch
|
|
||||||
size="md"
|
|
||||||
onChange={(e) =>
|
|
||||||
setConfig({
|
|
||||||
...config,
|
|
||||||
settings: {
|
|
||||||
...config.settings,
|
|
||||||
searchBar: e.currentTarget.checked,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
checked={config.settings.searchBar}
|
|
||||||
label="Enable search bar"
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
<ModuleEnabler />
|
<ModuleEnabler />
|
||||||
<ColorSchemeSwitch />
|
<ColorSchemeSwitch />
|
||||||
<ConfigChanger />
|
<ConfigChanger />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createStyles, Header as Head, Group, Box } from '@mantine/core';
|
import { createStyles, Header as Head, Group, Box } from '@mantine/core';
|
||||||
import { Logo } from './Logo';
|
import { Logo } from './Logo';
|
||||||
import SearchBar from '../SearchBar/SearchBar';
|
import SearchBar from '../modules/search/SearchModule';
|
||||||
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
|
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
|
||||||
import { SettingsMenuButton } from '../Settings/SettingsMenu';
|
import { SettingsMenuButton } from '../Settings/SettingsMenu';
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './date';
|
export * from './date';
|
||||||
export * from './calendar';
|
export * from './calendar';
|
||||||
|
export * from './search';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import SearchBar from './SearchBar';
|
import SearchBar from './SearchModule';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Search bar',
|
title: 'Search bar',
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { TextInput, Kbd, createStyles, useMantineTheme, Text, Popover } from '@mantine/core';
|
import { TextInput, Kbd, createStyles, Text, Popover } from '@mantine/core';
|
||||||
import { useForm, useHotkeys } from '@mantine/hooks';
|
import { useForm, useHotkeys } from '@mantine/hooks';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { Search, BrandYoutube, Download } from 'tabler-icons-react';
|
import { Search, BrandYoutube, Download } from 'tabler-icons-react';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
|
import { IModule } from '../modules';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
hide: {
|
hide: {
|
||||||
@@ -14,6 +15,13 @@ const useStyles = createStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const SearchModule: IModule = {
|
||||||
|
title: 'Search Bar',
|
||||||
|
description: 'Show the current time and date in a card',
|
||||||
|
icon: Search,
|
||||||
|
component: SearchBar,
|
||||||
|
};
|
||||||
|
|
||||||
export default function SearchBar(props: any) {
|
export default function SearchBar(props: any) {
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
@@ -23,7 +31,6 @@ export default function SearchBar(props: any) {
|
|||||||
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
|
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
|
||||||
|
|
||||||
const { classes, cx } = useStyles();
|
const { classes, cx } = useStyles();
|
||||||
const theme = useMantineTheme();
|
|
||||||
const rightSection = (
|
const rightSection = (
|
||||||
<div className={classes.hide}>
|
<div className={classes.hide}>
|
||||||
<Kbd>Ctrl</Kbd>
|
<Kbd>Ctrl</Kbd>
|
||||||
@@ -38,7 +45,8 @@ export default function SearchBar(props: any) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.settings.searchBar === false) {
|
// If enabled modules doesn't contain the module, return null
|
||||||
|
if (!config.settings.enabledModules.includes(SearchModule.title)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
1
src/components/modules/search/index.ts
Normal file
1
src/components/modules/search/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { SearchModule } from './SearchModule';
|
||||||
Reference in New Issue
Block a user