diff --git a/src/App.tsx b/src/App.tsx index 9abcf53..4bb7a62 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,23 @@ import { useStore } from "zustand"; import { displayOptionStore, yDocOptionStore } from "./lib/store"; export default function App() { - const { apiVersion, inputBuffer } = useStore(yDocOptionStore); + return ( +
+ +
+ +
+ + +
+
+
+ ); +} + +function InputContainer() { + const apiVersion = useStore(yDocOptionStore, (s) => s.apiVersion); + const inputBuffer = useStore(yDocOptionStore, (s) => s.inputBuffer); useEffect(() => { const prev = displayOptionStore.getState().display; @@ -34,24 +50,15 @@ export default function App() { }, [inputBuffer, apiVersion]); return ( -
- -
- - yDocOptionStore.setState({ inputBuffer: e.target.value }) - } - className="mb-4 bg-gray-800 text-white border-gray-700" - /> -
- - -
-
-
+ + yDocOptionStore.setState({ inputBuffer: e.target.value }) + } + className="mb-4 bg-gray-800 text-white border-gray-700" + /> ); } diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index 67485ce..c44a142 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -21,7 +21,8 @@ export function Sidebar() { } function YDocOptions() { - const { apiVersion, getApiType } = useStore(yDocOptionStore); + const apiVersion = useStore(yDocOptionStore, (s) => s.apiVersion); + const getApiType = useStore(yDocOptionStore, (s) => s.getApiType); return ( <>

Y.Doc Options

@@ -85,8 +86,17 @@ function YDocOptions() { } function DisplayOptions() { - const { indentWidth, enableClipboard, displayDataTypes, displaySize } = - useStore(displayOptionStore); + const indentWidth = useStore(displayOptionStore, (s) => s.indentWidth); + const enableClipboard = useStore( + displayOptionStore, + (s) => s.enableClipboard, + ); + const displayDataTypes = useStore( + displayOptionStore, + (s) => s.displayDataTypes, + ); + const displaySize = useStore(displayOptionStore, (s) => s.displaySize); + return ( <>

Display Options