Skip to content

Commit 79fa165

Browse files
committed
Update demo app and readme
1 parent 0902c44 commit 79fa165

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ The only *required* value is `data` (although you will need to provide a `setDat
112112
| `enableClipboard` | `boolean\|CopyFunction` | `true` | Whether or not to enable the "Copy to clipboard" button in the UI. If a function is provided, `true` is assumed and this function will be run whenever an item is copied. |
113113
| `indent` | `number` | `3` | Specify the amount of indentation for each level of nesting in the displayed data. |
114114
| `collapse` | `boolean\|number\|FilterFunction` | `false` | Defines which nodes of the JSON tree will be displayed "opened" in the UI on load. If `boolean`, it'll be either all or none. A `number` specifies a nesting depth after which nodes will be closed. For more fine control a function can be provided — see [Filter functions](#filter-functions). |
115+
| `collapseAnimationTime` | `number` | `500` | Time (in milliseconds) for the transition animation when collapsing collection nodes. |
115116
| `restrictEdit` | `boolean\|FilterFunction` | `false` | If `true`, no editing is permitted. A function can be provided for more specificity — see [Filter functions](#filter-functions) |
116117
| `restrictDelete` | `boolean\|FilterFunction` | `false` | As with `restrictEdit` but for deletion |
117118
| `restrictAdd` | `boolean\|FilterFunction` | `false` | As with `restrictEdit` but for adding new properties |

demo/src/App.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface AppState {
5151
rootName: string
5252
indent: number
5353
collapseLevel: number
54+
collapseTime: number
5455
showCount: 'Yes' | 'No' | 'When closed'
5556
theme: ThemeName | Theme
5657
allowEdit: boolean
@@ -75,6 +76,7 @@ function App() {
7576
rootName: dataDefinition.rootName ?? 'data',
7677
indent: 3,
7778
collapseLevel: dataDefinition.collapse ?? 2,
79+
collapseTime: 500,
7880
showCount: 'When closed',
7981
theme: 'default',
8082
allowEdit: true,
@@ -116,6 +118,7 @@ function App() {
116118
theme,
117119
indent,
118120
collapseLevel,
121+
collapseTime,
119122
showCount,
120123
showIndices,
121124
sortKeys,
@@ -330,7 +333,7 @@ function App() {
330333
}
331334
showErrorMessages={dataDefinition.showErrorMessages}
332335
collapse={collapseLevel}
333-
// collapseAnimationTime={100}
336+
collapseAnimationTime={collapseTime}
334337
showCollectionCount={
335338
showCount === 'Yes' ? true : showCount === 'When closed' ? 'when-closed' : false
336339
}
@@ -478,6 +481,20 @@ function App() {
478481
</NumberInputStepper>
479482
</NumberInput>
480483
</HStack>
484+
<HStack className="inputRow">
485+
<FormLabel className="labelWidth" textAlign="right">
486+
Collapse animation time
487+
</FormLabel>
488+
<NumberInput
489+
id="collapseTime"
490+
className="inputWidth"
491+
min={0}
492+
value={collapseTime}
493+
onChange={(value) => updateState({ collapseTime: Number(value) })}
494+
>
495+
<NumberInputField />
496+
</NumberInput>
497+
</HStack>
481498
<HStack className="inputRow">
482499
<FormLabel className="labelWidth" textAlign="right">
483500
Indent level

0 commit comments

Comments
 (0)