Skip to content

Commit 7c0eda8

Browse files
committed
Added collapsed prop to SuperDebug.
Fixes #279.
1 parent 9713bdc commit 7c0eda8

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- By declaring `namespace Superforms` with a `type Message` in `app.d.ts`, the [status messages](https://superforms.rocks/concepts/messages) will always be set to that type. ([#261](https://github.com/ciscoheat/sveltekit-superforms/issues/261))
12+
- In `app.d.ts`, by declaring `namespace global.Superforms` with a `type Message`, the [status messages](https://superforms.rocks/concepts/messages) will always be set to that type. ([#261](https://github.com/ciscoheat/sveltekit-superforms/issues/261))
1313
- Added `FormResult<T>`, which can be used in [onResult](https://superforms.rocks/concepts/events#onresult) to make the ActionResult strongly typed.
14+
- [SuperDebug](https://superforms.rocks/super-debug) now has a `collapsed` prop, to make it initially collapsed. Use together with `collapsible`. ([#279](https://github.com/ciscoheat/sveltekit-superforms/issues/279))
1415

1516
## [1.8.0]
1617

src/lib/client/SuperDebug.svelte

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,17 @@
103103
///// Collapse behavior ///////////////////////////////////////////
104104
105105
/**
106-
* Will show a collapse bar at the bottom of the component, that can be used to hide and show the output.
107-
*
108-
* Default is `false`.
106+
* Will show a collapse bar at the bottom of the component, that can be used to hide and show the output. Default is `false`.
107+
* When toggled, the state is saved in session storage for all SuperDebug components on the page.
109108
*/
110109
export let collapsible = false;
111110
112-
let collapsed = false;
111+
/**
112+
* Initial state for the collapsed component. Use together with the `collapsible` prop.
113+
* On subsequent page loads, the session storage will determine the state of all SuperDebug components on the page.
114+
*/
115+
export let collapsed = false;
116+
113117
if (browser && collapsible) setCollapse();
114118
115119
/**
@@ -127,11 +131,11 @@
127131
data = { collapsed: data && data.collapsed ? data.collapsed : {} };
128132
129133
data.collapsed[route] =
130-
status === undefined ? data.collapsed[route] ?? false : status;
134+
status === undefined ? data.collapsed[route] ?? collapsed : status;
131135
} catch {
132136
data = {
133137
collapsed: {
134-
[route]: false
138+
[route]: collapsed
135139
}
136140
};
137141
}

src/routes/super-debug/+page.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@
105105
<p>Label is useful when using multiple instance of SuperDebug.</p>
106106
<SuperDebug label="Sample User" data={$form} collapsible />
107107
</section>
108+
<section>
109+
<h4>SuperDebug, initially collapsed</h4>
110+
<p>
111+
Use the <code>collapsible</code> and <code>collapsed</code> props for this.
112+
</p>
113+
<SuperDebug label="Sample User" data={$form} collapsible collapsed />
114+
</section>
108115
<section>
109116
<h4>SuperDebug without status</h4>
110117
<SuperDebug label="Sample User" status={false} data={$form} />

0 commit comments

Comments
 (0)