Reset array limit when not expanded, and create a "show more" button

This commit is contained in:
josdejong 2020-06-03 08:43:33 +02:00
parent 44eb417e4f
commit f17c575c60
3 changed files with 25 additions and 2 deletions

View File

@ -124,6 +124,24 @@
} }
} }
div.limit {
margin-left: $indentation-width;
button {
background: none;
border: none;
padding: 0;
color: $black;
text-decoration: underline;
cursor: pointer;
&:hover,
&:focus {
color: $red;
}
}
}
div.empty { div.empty {
&:not(:focus) { &:not(:focus) {
outline: 1px dotted lightgray; outline: 1px dotted lightgray;

View File

@ -178,6 +178,10 @@
function handleShowAll () { function handleShowAll () {
onLimit(path, Infinity) onLimit(path, Infinity)
} }
function handleShowMore () {
onLimit(path, (Math.round(limit / DEFAULT_LIMIT) + 1) * DEFAULT_LIMIT)
}
</script> </script>
<div class='json-node'> <div class='json-node'>
@ -229,8 +233,8 @@
/> />
{/each} {/each}
{#if limited} {#if limited}
<div> <div class='limit'>
(showing {limit} of {value.length} items <button on:click={handleShowAll}>show all</button>) (showing {limit} of {value.length} items <button on:click={handleShowMore}>show more</button> <button on:click={handleShowAll}>show all</button>)
</div> </div>
{/if} {/if}
</div> </div>

View File

@ -7,6 +7,7 @@ $font-size-icon: 16px;
$white: #fff; $white: #fff;
$black: #1A1A1A; $black: #1A1A1A;
$red: #ee422e;
$contentsMinHeight: 150px; $contentsMinHeight: 150px;
$theme-color: #3883fa; $theme-color: #3883fa;
$theme-color-light: lighten($theme-color, 5%); $theme-color-light: lighten($theme-color, 5%);