Improve display of relationship cell and options cell

This commit is contained in:
Andrew Kingston 2023-02-21 11:46:20 +00:00
parent 8f5c5cc758
commit 57cfc9d84c
3 changed files with 63 additions and 5 deletions

View File

@ -73,7 +73,9 @@
{/each} {/each}
</div> </div>
{#if editable} {#if editable}
<div class="arrow">
<Icon name="ChevronDown" /> <Icon name="ChevronDown" />
</div>
{/if} {/if}
{#if open} {#if open}
<div class="options"> <div class="options">
@ -105,11 +107,9 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: stretch;
padding: 0 8px; align-self: stretch;
flex: 1 1 auto; flex: 1 1 auto;
overflow: hidden;
gap: 4px;
} }
.container.editable:hover { .container.editable:hover {
cursor: pointer; cursor: pointer;
@ -123,6 +123,7 @@
width: 0; width: 0;
gap: 4px; gap: 4px;
overflow: hidden; overflow: hidden;
padding: 0 8px;
} }
.text { .text {
overflow: hidden; overflow: hidden;
@ -138,6 +139,20 @@
border-radius: 8px; border-radius: 8px;
user-select: none; user-select: none;
} }
.arrow {
position: absolute;
right: 2px;
top: 2px;
bottom: 2px;
padding: 0 6px 0 16px;
display: grid;
place-items: center;
background: linear-gradient(
to right,
transparent 0%,
var(--background) 40%
);
}
.options { .options {
min-width: 100%; min-width: 100%;
position: absolute; position: absolute;

View File

@ -0,0 +1,40 @@
<script>
export let value
$: console.log(value)
const getColor = idx => {
if (!value || idx === -1) {
return null
}
return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, 0.3)`
}
</script>
<div class="container">
{#each value || [] as relationship, idx}
<div class="badge" style="--color: {getColor(idx)}">
{relationship.primaryDisplay}
</div>
{/each}
</div>
<style>
.container {
display: flex;
flex-direction: row;
align-items: center;
padding: 0 8px;
flex: 1 1 auto;
width: 0;
gap: 4px;
overflow: hidden;
}
.badge {
flex: 0 0 auto;
padding: 2px 8px;
background: var(--color);
border-radius: 8px;
user-select: none;
}
</style>

View File

@ -7,6 +7,7 @@
import DateCell from "./DateCell.svelte" import DateCell from "./DateCell.svelte"
import MultiSelectCell from "./MultiSelectCell.svelte" import MultiSelectCell from "./MultiSelectCell.svelte"
import NumberCell from "./NumberCell.svelte" import NumberCell from "./NumberCell.svelte"
import RelationshipCell from "./RelationshipCell.svelte"
export let table export let table
export let filter export let filter
@ -96,6 +97,8 @@
return MultiSelectCell return MultiSelectCell
} else if (type === "number") { } else if (type === "number") {
return NumberCell return NumberCell
} else if (type === "link") {
return RelationshipCell
} }
return TextCell return TextCell
} }