mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
feat: add grid
This commit is contained in:
parent
f2b3910432
commit
30beead56c
6 changed files with 96 additions and 19 deletions
24
src/context/SettingsContext.tsx
Normal file
24
src/context/SettingsContext.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { createContext, ReactNode, useState } from "react";
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
grid: false,
|
||||
};
|
||||
|
||||
export const SettingsContext = createContext({
|
||||
settings: defaultSettings,
|
||||
setSetting: <K extends keyof Settings>(key: K, value: Settings[K]) => {},
|
||||
});
|
||||
|
||||
export const SettingsProvider = ({ children }: Props) => {
|
||||
const [settings, setSettings] = useState<Settings>(defaultSettings);
|
||||
|
||||
const setSetting = <K extends keyof Settings>(key: K, value: Settings[K]) => {
|
||||
setSettings((prev) => ({ ...prev, [key]: value }));
|
||||
};
|
||||
|
||||
return <SettingsContext.Provider value={{ settings, setSetting }}>{children}</SettingsContext.Provider>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue