Update JSON, boolean and date cells to respect row height
This commit is contained in:
parent
d38cf2d7f0
commit
0cede10867
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.boolean-cell {
|
.boolean-cell {
|
||||||
padding: 0 var(--cell-padding);
|
padding: 2px var(--cell-padding);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.boolean-cell.editable {
|
.boolean-cell.editable {
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.container {
|
.container {
|
||||||
padding: 0 var(--cell-padding);
|
padding: var(--cell-padding);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
.picker {
|
.picker {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
-webkit-line-clamp: var(--content-lines);
|
-webkit-line-clamp: var(--content-lines);
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
line-height: 19px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
textarea {
|
textarea {
|
||||||
padding: var(--cell-padding);
|
padding: var(--cell-padding);
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
resize: none;
|
resize: none;
|
||||||
line-height: 19px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
textarea.invertX {
|
textarea.invertX {
|
||||||
left: auto;
|
left: auto;
|
||||||
|
|
|
@ -83,7 +83,9 @@
|
||||||
{@const color = getOptionColor(val)}
|
{@const color = getOptionColor(val)}
|
||||||
{#if color}
|
{#if color}
|
||||||
<div class="badge text" style="--color: {color}">
|
<div class="badge text" style="--color: {color}">
|
||||||
|
<span>
|
||||||
{val}
|
{val}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="text">
|
<div class="text">
|
||||||
|
@ -131,9 +133,10 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: stretch;
|
align-items: flex-start;
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.container.editable:hover {
|
.container.editable:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -142,12 +145,13 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
width: 0;
|
grid-column-gap: var(--cell-spacing);
|
||||||
gap: var(--cell-spacing);
|
grid-row-gap: var(--cell-padding);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0 var(--cell-padding);
|
padding: var(--cell-padding);
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.text {
|
.text {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -158,10 +162,20 @@
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
.badge {
|
.badge {
|
||||||
padding: 2px var(--cell-padding);
|
padding: 0 var(--cell-padding);
|
||||||
background: var(--color);
|
background: var(--color);
|
||||||
border-radius: var(--cell-padding);
|
border-radius: var(--cell-padding);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--cell-spacing);
|
||||||
|
height: 20px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.badge span {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.arrow {
|
.arrow {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -210,9 +224,6 @@
|
||||||
gap: var(--cell-spacing);
|
gap: var(--cell-spacing);
|
||||||
background-color: var(--cell-background-hover);
|
background-color: var(--cell-background-hover);
|
||||||
}
|
}
|
||||||
.option:first-child {
|
|
||||||
flex: 0 0 calc(var(--row-height) - 1px);
|
|
||||||
}
|
|
||||||
.option:hover,
|
.option:hover,
|
||||||
.option.focused {
|
.option.focused {
|
||||||
background-color: var(--spectrum-global-color-gray-200);
|
background-color: var(--spectrum-global-color-gray-200);
|
||||||
|
|
|
@ -249,7 +249,7 @@
|
||||||
placeholder={primaryDisplay ? `Search by ${primaryDisplay}` : null}
|
placeholder={primaryDisplay ? `Search by ${primaryDisplay}` : null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if searchResults}
|
{#if searchString && searchResults}
|
||||||
<div class="info">
|
<div class="info">
|
||||||
{searchResults.length} row{searchResults.length === 1 ? "" : "s"} found
|
{searchResults.length} row{searchResults.length === 1 ? "" : "s"} found
|
||||||
</div>
|
</div>
|
||||||
|
@ -265,7 +265,9 @@
|
||||||
on:mouseenter={() => (candidateIndex = idx)}
|
on:mouseenter={() => (candidateIndex = idx)}
|
||||||
>
|
>
|
||||||
<div class="badge">
|
<div class="badge">
|
||||||
|
<span>
|
||||||
{row.primaryDisplay}
|
{row.primaryDisplay}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{#if isRowSelected(row)}
|
{#if isRowSelected(row)}
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -342,13 +344,16 @@
|
||||||
background: var(--color);
|
background: var(--color);
|
||||||
border-radius: var(--cell-padding);
|
border-radius: var(--cell-padding);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--cell-spacing);
|
gap: var(--cell-spacing);
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.badge span {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.focused .badge span:hover {
|
.focused .badge span:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
-webkit-line-clamp: var(--content-lines);
|
-webkit-line-clamp: var(--content-lines);
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
line-height: 19px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
.number .value {
|
.number .value {
|
||||||
-webkit-line-clamp: 1;
|
-webkit-line-clamp: 1;
|
||||||
|
@ -91,6 +91,7 @@
|
||||||
font-size: var(--cell-font-size);
|
font-size: var(--cell-font-size);
|
||||||
font-family: var(--font-sans);
|
font-family: var(--font-sans);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
input:focus {
|
input:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
|
|
|
@ -4,7 +4,6 @@ export const MaxCellRenderWidthOverflow = 200
|
||||||
export const ScrollBarSize = 8
|
export const ScrollBarSize = 8
|
||||||
export const GutterWidth = 72
|
export const GutterWidth = 72
|
||||||
export const DefaultColumnWidth = 200
|
export const DefaultColumnWidth = 200
|
||||||
export const DefaultRelationshipColumnWidth = 360
|
|
||||||
export const MinColumnWidth = 100
|
export const MinColumnWidth = 100
|
||||||
export const SmallRowHeight = 36
|
export const SmallRowHeight = 36
|
||||||
export const MediumRowHeight = 64
|
export const MediumRowHeight = 64
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
import { derived, get, writable } from "svelte/store"
|
import { derived, get, writable } from "svelte/store"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import {
|
import { GutterWidth, DefaultColumnWidth } from "../lib/constants"
|
||||||
GutterWidth,
|
|
||||||
DefaultColumnWidth,
|
|
||||||
DefaultRelationshipColumnWidth,
|
|
||||||
} from "../lib/constants"
|
|
||||||
|
|
||||||
export const getDefaultColumnWidth = column => {
|
|
||||||
return column?.schema?.type === "link"
|
|
||||||
? DefaultRelationshipColumnWidth
|
|
||||||
: DefaultColumnWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createStores = () => {
|
export const createStores = () => {
|
||||||
const columns = writable([])
|
const columns = writable([])
|
||||||
|
@ -86,12 +76,10 @@ export const deriveStores = context => {
|
||||||
// Copy over metadata
|
// Copy over metadata
|
||||||
if (column === $stickyColumn?.name) {
|
if (column === $stickyColumn?.name) {
|
||||||
newSchema[column].visible = true
|
newSchema[column].visible = true
|
||||||
newSchema[column].width =
|
newSchema[column].width = $stickyColumn.width || DefaultColumnWidth
|
||||||
$stickyColumn.width || getDefaultColumnWidth($stickyColumn)
|
|
||||||
} else {
|
} else {
|
||||||
newSchema[column].visible = $columns[index]?.visible ?? true
|
newSchema[column].visible = $columns[index]?.visible ?? true
|
||||||
newSchema[column].width =
|
newSchema[column].width = $columns[index]?.width || DefaultColumnWidth
|
||||||
$columns[index]?.width || getDefaultColumnWidth($columns[index])
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -155,9 +143,7 @@ export const initialise = context => {
|
||||||
.map(field => ({
|
.map(field => ({
|
||||||
name: field,
|
name: field,
|
||||||
schema: schema[field],
|
schema: schema[field],
|
||||||
width:
|
width: schema[field].width || DefaultColumnWidth,
|
||||||
schema[field].width ||
|
|
||||||
getDefaultColumnWidth({ schema: schema[field].type }),
|
|
||||||
visible: schema[field].visible ?? true,
|
visible: schema[field].visible ?? true,
|
||||||
order: schema[field].order,
|
order: schema[field].order,
|
||||||
}))
|
}))
|
||||||
|
@ -195,12 +181,9 @@ export const initialise = context => {
|
||||||
if (!existing && currentStickyColumn?.name === primaryDisplay) {
|
if (!existing && currentStickyColumn?.name === primaryDisplay) {
|
||||||
existing = currentStickyColumn
|
existing = currentStickyColumn
|
||||||
}
|
}
|
||||||
const defaultWidth = getDefaultColumnWidth({
|
|
||||||
schema: schema[primaryDisplay],
|
|
||||||
})
|
|
||||||
stickyColumn.set({
|
stickyColumn.set({
|
||||||
name: primaryDisplay,
|
name: primaryDisplay,
|
||||||
width: schema[primaryDisplay].width || defaultWidth,
|
width: schema[primaryDisplay].width || DefaultColumnWidth,
|
||||||
left: GutterWidth,
|
left: GutterWidth,
|
||||||
schema: schema[primaryDisplay],
|
schema: schema[primaryDisplay],
|
||||||
idx: "sticky",
|
idx: "sticky",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { writable, get, derived } from "svelte/store"
|
import { writable, get, derived } from "svelte/store"
|
||||||
import { getDefaultColumnWidth } from "./columns"
|
import { MinColumnWidth, DefaultColumnWidth } from "../lib/constants"
|
||||||
import { MinColumnWidth } from "../lib/constants"
|
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
initialMouseX: null,
|
initialMouseX: null,
|
||||||
|
@ -98,16 +97,15 @@ export const deriveStores = context => {
|
||||||
// Resets a column size back to default
|
// Resets a column size back to default
|
||||||
const resetSize = async column => {
|
const resetSize = async column => {
|
||||||
const $stickyColumn = get(stickyColumn)
|
const $stickyColumn = get(stickyColumn)
|
||||||
const width = getDefaultColumnWidth(column)
|
|
||||||
if (column.name === $stickyColumn?.name) {
|
if (column.name === $stickyColumn?.name) {
|
||||||
stickyColumn.update(state => ({
|
stickyColumn.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
width,
|
width: DefaultColumnWidth,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
columns.update(state => {
|
columns.update(state => {
|
||||||
const columnIdx = state.findIndex(x => x.name === column.name)
|
const columnIdx = state.findIndex(x => x.name === column.name)
|
||||||
state[columnIdx].width = width
|
state[columnIdx].width = DefaultColumnWidth
|
||||||
return [...state]
|
return [...state]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ export const deriveStores = context => {
|
||||||
|
|
||||||
const contentLines = derived(rowHeight, $rowHeight => {
|
const contentLines = derived(rowHeight, $rowHeight => {
|
||||||
if ($rowHeight === LargeRowHeight) {
|
if ($rowHeight === LargeRowHeight) {
|
||||||
return 4
|
return 3
|
||||||
} else if ($rowHeight === MediumRowHeight) {
|
} else if ($rowHeight === MediumRowHeight) {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue