From 0a78437e3799b34fde3fac6eb113e04c98959d88 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Thu, 11 Apr 2024 01:49:54 +0800 Subject: [PATCH] feat: support hide size --- src/components/config-panel.tsx | 28 +++++++++++++++++++++------- src/components/preview-panel.tsx | 4 +++- src/state.ts | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/components/config-panel.tsx b/src/components/config-panel.tsx index 9325942..9f3de53 100644 --- a/src/components/config-panel.tsx +++ b/src/components/config-panel.tsx @@ -1,18 +1,18 @@ -import { useToast } from "./ui/use-toast"; import { Config, useConfig, useYDoc } from "../state"; +import { fileToYDoc } from "../utils"; import { ExportButton } from "./export-button"; +import { FullScreenDropZone } from "./full-screen-drop-zone"; +import { LoadButton } from "./load-button"; +import { Label } from "./ui/label"; import { Select, - SelectTrigger, - SelectValue, SelectContent, SelectItem, + SelectTrigger, + SelectValue, } from "./ui/select"; import { Switch } from "./ui/switch"; -import { Label } from "./ui/label"; -import { FullScreenDropZone } from "./full-screen-drop-zone"; -import { LoadButton } from "./load-button"; -import { fileToYDoc } from "../utils"; +import { useToast } from "./ui/use-toast"; export function ConfigPanel() { const [yDoc, setYDoc] = useYDoc(); @@ -58,6 +58,20 @@ export function ConfigPanel() { +
+ + setConfig({ + ...config, + showSize: checked, + }) + } + /> + +
+ @@ -34,6 +35,7 @@ export function PreviewPanel() { // editable={true} // enableAdd={true} // enableDelete={true} + displaySize={config.showSize} theme={theme === "system" ? systemPreferenceTheme : theme} defaultInspectDepth={2} valueTypes={[yDataType]} diff --git a/src/state.ts b/src/state.ts index 9a6ef6f..4f80612 100644 --- a/src/state.ts +++ b/src/state.ts @@ -10,11 +10,13 @@ export const useYDoc = () => { export type Config = { view: "ydoc" | "shared-types"; showDelta: boolean; + showSize: boolean; }; const defaultConfig = { view: "shared-types", showDelta: true, + showSize: true, } satisfies Config; const configAtom = atom(defaultConfig);