mirror of
https://github.com/muerwre/markdown-home-tab.git
synced 2025-04-25 00:46:41 +07:00
made simple settings page
This commit is contained in:
parent
ece7395b26
commit
00a11d05e0
9 changed files with 116 additions and 19 deletions
|
@ -3,8 +3,10 @@ import { Modal } from "~/modules/modal/containers/Modal";
|
|||
import { SettingsContainer } from "../../containers/SettingsContainer";
|
||||
import {
|
||||
SettingsContext,
|
||||
SettingsValue,
|
||||
defaultSettings,
|
||||
} from "../../context/SettingsContext";
|
||||
import { ModalPage } from "~/modules/modal/components/ModalPage";
|
||||
|
||||
const SettingsProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
const [settings, setSettings] = useState(defaultSettings);
|
||||
|
@ -12,12 +14,18 @@ const SettingsProvider: FC<PropsWithChildren> = ({ children }) => {
|
|||
|
||||
const show = useCallback(() => setSettingsModalVisible(true), []);
|
||||
const hide = useCallback(() => setSettingsModalVisible(false), []);
|
||||
const update = useCallback(
|
||||
(val: Partial<SettingsValue>) => setSettings((v) => ({ ...v, ...val })),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<SettingsContext.Provider value={{ settings, setSettings, show, hide }}>
|
||||
<SettingsContext.Provider value={{ settings, update, show, hide }}>
|
||||
{settingsModalVisible && (
|
||||
<Modal onClose={hide}>
|
||||
<SettingsContainer />
|
||||
<ModalPage onClose={hide}>
|
||||
<SettingsContainer />
|
||||
</ModalPage>
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue