mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-02 10:53:33 +00:00
[enhancement]: support serach on settings page
This commit is contained in:
parent
683bb0222c
commit
645697367d
21 changed files with 439 additions and 385 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { ReactNode } from 'react';
|
||||
import { SettingsOptions } from '/@/renderer/features/settings/components/settings-option';
|
||||
import { useSettingSearchContext } from '/@/renderer/features/settings/context/search-context';
|
||||
import { Divider } from '@mantine/core';
|
||||
|
||||
export type SettingOption = {
|
||||
control: ReactNode;
|
||||
|
|
@ -10,20 +12,27 @@ export type SettingOption = {
|
|||
};
|
||||
|
||||
interface SettingsSectionProps {
|
||||
divider?: boolean;
|
||||
options: SettingOption[];
|
||||
}
|
||||
|
||||
export const SettingsSection = ({ options }: SettingsSectionProps) => {
|
||||
export const SettingsSection = ({ divider, options }: SettingsSectionProps) => {
|
||||
const keyword = useSettingSearchContext();
|
||||
const hasKeyword = keyword !== '';
|
||||
|
||||
const values = options.filter(
|
||||
(o) => !o.isHidden && (!hasKeyword || o.title.toLocaleLowerCase().includes(keyword)),
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{options
|
||||
.filter((o) => !o.isHidden)
|
||||
.map((option) => (
|
||||
<SettingsOptions
|
||||
key={`option-${option.title}`}
|
||||
{...option}
|
||||
/>
|
||||
))}
|
||||
{values.map((option) => (
|
||||
<SettingsOptions
|
||||
key={`option-${option.title}`}
|
||||
{...option}
|
||||
/>
|
||||
))}
|
||||
{divider !== false && values.length > 0 && <Divider />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue