Skip to content

Commit 65f51aa

Browse files
committed
ensure minimizer is correctly persisted
closes #5
1 parent 0cd82bb commit 65f51aa

7 files changed

Lines changed: 18 additions & 4 deletions

File tree

.changeset/new-steaks-listen.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@react-trace/kit": patch
3+
"@react-trace/core": patch
4+
---
5+
6+
Ensure minimizer is correctly persisted

apps/website/docs/guide/configuration.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ When using the batteries-included `@react-trace/kit`, the default export accepts
1212
| ----------------- | -------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------- |
1313
| `root` | `string` || **Required.** Absolute path to the project root. |
1414
| `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Where the floating toolbar is placed on screen. |
15+
| `minimized` | `boolean` | `false` | Start with the widget minimized. |
1516
| `editingDisabled` | `boolean` | `false` | Disables inline editing in the preview panel and hides save/expand controls. |
1617
| `editor` | `EditorPreset` | `'vscode'` | Default editor for the "Open in Editor" action. |
1718
| `plugins` | `TracePlugin[]` | `[]` | Additional plugin instances, appended after the 4 built-in plugins. |

packages/core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function Root() {
6363
- `root: string` — absolute project root path
6464
- `plugins?: TracePlugin[]` — plugin instances to mount
6565
- `position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'` — initial toolbar position
66+
- `minimized?: boolean` — whether the widget starts minimized by default
6667

6768
## Plugin model
6869

packages/core/src/components/Trace.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ export function Trace({
2121
root,
2222
plugins = [],
2323
position = 'bottom-right',
24+
minimized = false,
2425
}: TraceProps) {
2526
const [jotaiStore] = useState(() => {
2627
const store = createWidgetStore()
2728
store.set(projectRootAtom, root)
28-
store.set(coreSettingsAtom, { position })
29+
if (!store.get(coreSettingsAtom)) {
30+
store.set(coreSettingsAtom, { position, minimized })
31+
}
2932
return store
3033
})
3134

packages/core/src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const projectRootAtom = atom<string>('')
2323
const settingsAtom = atomFamily((root: string) =>
2424
atomWithStorage<TraceSettings>(
2525
`react-trace:settings:${root}`,
26-
{ core: { position: 'bottom-right' } },
26+
{ core: { position: 'bottom-right', minimized: false } },
2727
createJSONStorage<TraceSettings>(() => localStorage),
2828
{ getOnInit: typeof window !== 'undefined' },
2929
),

packages/core/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ export interface TraceProps {
4444
root: string
4545
plugins?: TracePlugin[]
4646
position?: WidgetPosition
47+
minimized?: boolean
4748
}
4849

4950
export interface TraceSettings {
5051
core: {
5152
position: WidgetPosition
52-
minimized?: boolean
53+
minimized: boolean
5354
}
5455
}

packages/react-trace/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The default export supports the following props today:
5252
| ----------------- | -------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------ |
5353
| `root` | `string` || Required absolute path to the project root. |
5454
| `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Controls where the Trace widget is placed on screen. |
55+
| `minimized` | `boolean` | `false` | Controls whether the widget starts minimized or not. |
5556
| `editingDisabled` | `boolean` | `false` | Disables inline editing in the preview panel and hides the Save and expand controls. |
5657
| `editor` | `EditorPreset` | `'vscode'` | Sets the default editor used by the Open in Editor action. |
5758

@@ -87,8 +88,9 @@ export function Root() {
8788
<Trace
8889
root={import.meta.env.VITE_ROOT}
8990
position="bottom-left"
91+
minimized
9092
editor="cursor"
91-
editingDisabled={false}
93+
editingDisabled
9294
/>
9395
</>
9496
)

0 commit comments

Comments
 (0)