This commit is contained in:
Gerard Burns 2024-04-16 11:00:23 +01:00
parent 4b52508625
commit 7b52811f10
6 changed files with 41 additions and 24 deletions

View File

@ -157,8 +157,6 @@
border-radius: 5px; border-radius: 5px;
box-sizing: border-box; box-sizing: border-box;
opacity: 0;
overflow: hidden;
border: 1px solid var(--grey-4); border: 1px solid var(--grey-4);
transition: width 300ms ease-in, height 300ms ease-in, top 300ms ease-in, left 300ms ease-in; transition: width 300ms ease-in, height 300ms ease-in, top 300ms ease-in, left 300ms ease-in;

View File

@ -16,7 +16,7 @@
} }
if (["string", "number", "boolean"].includes(schema.type)) { if (["string", "number", "boolean"].includes(schema.type)) {
newScalarDescendants.push(path.join(".")) newScalarDescendants.push({ name: path.join("."), type: schema.type })
} else if (schema.type === "json") { } else if (schema.type === "json") {
Object.entries(schema.schema ?? {}).forEach(([childName, childSchema]) => Object.entries(schema.schema ?? {}).forEach(([childName, childSchema]) =>
getScalarDescendantFromSchema([...path, childName], childSchema)) getScalarDescendantFromSchema([...path, childName], childSchema))
@ -39,24 +39,26 @@
{#if scalarDescendants.length > 0} {#if scalarDescendants.length > 0}
<Section> <Section>
Examples of scalar descendants of this object are: Examples scalar descendants of this object:
{#if scalarDescendants[0]} <br />
<Block>{scalarDescendants[0]}</Block>
{/if} {#each scalarDescendants as descendant}
{#if scalarDescendants.length === 2} <div class="example">
{" and "} <Block truncate>{descendant.name}</Block><span class="separator">-</span><Block truncate noShrink>{descendant.type}</Block>
{:else if scalarDescendants.length === 3} </div>
{", "} {/each}
{/if}
{#if scalarDescendants[1]}
<Block>{scalarDescendants[1]}</Block>
{/if}
{#if scalarDescendants.length === 3}
{" and "}
{/if}
{#if scalarDescendants[2]}
<Block>{scalarDescendants[2]}</Block>
{/if}
</Section> </Section>
{/if} {/if}
</Subject> </Subject>
<style>
.example {
display: flex;
margin-bottom: 2px;
}
.separator {
margin: 0 4px;
flex-shrink: 0;
}
</style>

View File

@ -1,4 +1,8 @@
<span class="block"> <script>
export let truncate = false
export let noShrink = false
</script>
<span class:truncate class:noShrink class="block">
<slot /> <slot />
</span> </span>
@ -11,4 +15,14 @@
color: var(--ink); color: var(--ink);
word-break: break-word; word-break: break-word;
} }
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.noShrink {
flex-shrink: 0;
}
</style> </style>

View File

@ -8,4 +8,8 @@
margin-bottom: 13px; margin-bottom: 13px;
overflow: hidden; overflow: hidden;
} }
.section :global(ul) {
padding-left: 24px;
}
</style> </style>

View File

@ -9,7 +9,6 @@
<Line> <Line>
<InfoWord <InfoWord
on:mouseenter={() => setExplanationSubject(subjects.scalarJsonOnly)} on:mouseenter={() => setExplanationSubject(subjects.scalarJsonOnly)}
on:mouseleave={() => setExplanationSubject(subjects.none)}
>Scalar JSON values</InfoWord> >Scalar JSON values</InfoWord>
<Text <Text
value=" can be used with this component if their individual types are supported" value=" can be used with this component if their individual types are supported"

View File

@ -31,7 +31,7 @@
align-items: center; align-items: center;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
row-gap: 4px; row-gap: 3px;
} }
.noWrap { .noWrap {