Add smart trunctation to all table cell types

This commit is contained in:
Andrew Kingston 2021-03-25 09:45:23 +00:00
parent 950b022798
commit 3c7aa63f51
4 changed files with 27 additions and 18 deletions

View File

@ -1,15 +1,20 @@
<script> <script>
export let value export let value
const displayLimit = 5
$: attachments = value?.slice(0, displayLimit) ?? []
$: leftover = (value?.length ?? 0) - attachments.length
</script> </script>
{#if value && value.length} {#each attachments as attachment}
{#each value as attachment} {#if attachment.type.startsWith('image')}
{#if attachment.type.startsWith('image')} <img src={attachment.url} alt={attachment.extension} />
<img src={attachment.url} alt={attachment.extension} /> {:else}
{:else} <div class="file">{attachment.extension}</div>
<div class="file">{attachment.extension}</div> {/if}
{/if} {/each}
{/each} {#if leftover}
<div>+{leftover} others</div>
{/if} {/if}
<style> <style>

View File

@ -2,14 +2,19 @@
import "@spectrum-css/label/dist/index-vars.css" import "@spectrum-css/label/dist/index-vars.css"
export let value export let value
const displayLimit = 5
$: relationships = value?.slice(0, displayLimit) ?? []
$: leftover = (value?.length ?? 0) - relationships.length
</script> </script>
{#if value && value.length} {#each relationships as relationship}
{#each value as item} {#if relationship?.primaryDisplay}
{#if item && item.primaryDisplay} <span class="spectrum-Label spectrum-Label--grey">
<span class="spectrum-Label spectrum-Label--grey"> {relationship.primaryDisplay}
{item.primaryDisplay} </span>
</span> {/if}
{/if} {/each}
{/each} {#if leftover}
<div>+{leftover} others</div>
{/if} {/if}

View File

@ -8,5 +8,6 @@
div { div {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
max-width: 320px;
} }
</style> </style>

View File

@ -192,8 +192,6 @@
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
max-width: 320px;
overflow: hidden;
} }
.spectrum-Table-sortedIcon { .spectrum-Table-sortedIcon {
opacity: 0; opacity: 0;