Use nicer checkboxes and fix some hover styles
This commit is contained in:
parent
a28148d9f8
commit
26ca96eaa9
|
@ -2,6 +2,7 @@
|
||||||
import SheetCell from "./SheetCell.svelte"
|
import SheetCell from "./SheetCell.svelte"
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { Icon } from "@budibase/bbui"
|
import { Icon } from "@budibase/bbui"
|
||||||
|
import { Checkbox } from "@budibase/bbui"
|
||||||
|
|
||||||
const { visibleColumns, reorder, selectedRows, rows } =
|
const { visibleColumns, reorder, selectedRows, rows } =
|
||||||
getContext("spreadsheet")
|
getContext("spreadsheet")
|
||||||
|
@ -36,10 +37,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Field headers -->
|
<!-- Field headers -->
|
||||||
<SheetCell header label on:click={selectAll} width="40" left="0">
|
<SheetCell header label on:click={selectAll} width="40" left="0">
|
||||||
<input
|
<Checkbox value={rowCount && selectedRowCount === rowCount} />
|
||||||
type="checkbox"
|
|
||||||
checked={rowCount && selectedRowCount === rowCount}
|
|
||||||
/>
|
|
||||||
</SheetCell>
|
</SheetCell>
|
||||||
{#each $visibleColumns as column}
|
{#each $visibleColumns as column}
|
||||||
<SheetCell
|
<SheetCell
|
||||||
|
@ -73,14 +71,7 @@
|
||||||
width: inherit;
|
width: inherit;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.row.new {
|
|
||||||
position: absolute;
|
|
||||||
transform: translateY(var(--top));
|
|
||||||
}
|
|
||||||
.row :global(> :last-child) {
|
.row :global(> :last-child) {
|
||||||
border-right-width: 1px;
|
border-right-width: 1px;
|
||||||
}
|
}
|
||||||
input[type="checkbox"] {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
width: inherit;
|
width: inherit;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
.row:hover :global(.cell) {
|
:global(.sheet:not(.is-resizing):not(.is-reordering) .row:hover .cell) {
|
||||||
background: var(--cell-background-hover);
|
background: var(--cell-background-hover);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
gap: calc(2 * var(--cell-spacing));
|
gap: calc(2 * var(--cell-spacing));
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.cell.header :global(span) {
|
.cell.header :global(> span) {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
width: 0;
|
width: 0;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@ -127,5 +127,9 @@
|
||||||
position: sticky;
|
position: sticky;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import NumberCell from "./cells/NumberCell.svelte"
|
import NumberCell from "./cells/NumberCell.svelte"
|
||||||
import RelationshipCell from "./cells/RelationshipCell.svelte"
|
import RelationshipCell from "./cells/RelationshipCell.svelte"
|
||||||
import TextCell from "./cells/TextCell.svelte"
|
import TextCell from "./cells/TextCell.svelte"
|
||||||
|
import { Checkbox } from "@budibase/bbui"
|
||||||
|
|
||||||
export let row
|
export let row
|
||||||
|
|
||||||
|
@ -20,25 +21,16 @@
|
||||||
visibleColumns,
|
visibleColumns,
|
||||||
cellHeight,
|
cellHeight,
|
||||||
} = getContext("spreadsheet")
|
} = getContext("spreadsheet")
|
||||||
|
const TypeComponentMap = {
|
||||||
|
options: OptionsCell,
|
||||||
|
datetime: DateCell,
|
||||||
|
array: MultiSelectCell,
|
||||||
|
number: NumberCell,
|
||||||
|
link: RelationshipCell,
|
||||||
|
}
|
||||||
|
|
||||||
$: rowSelected = !!$selectedRows[row._id]
|
$: rowSelected = !!$selectedRows[row._id]
|
||||||
|
|
||||||
const getCellForField = field => {
|
|
||||||
const type = field.schema.type
|
|
||||||
if (type === "options") {
|
|
||||||
return OptionsCell
|
|
||||||
} else if (type === "datetime") {
|
|
||||||
return DateCell
|
|
||||||
} else if (type === "array") {
|
|
||||||
return MultiSelectCell
|
|
||||||
} else if (type === "number") {
|
|
||||||
return NumberCell
|
|
||||||
} else if (type === "link") {
|
|
||||||
return RelationshipCell
|
|
||||||
}
|
|
||||||
return TextCell
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectRow = id => {
|
const selectRow = id => {
|
||||||
selectedRows.update(state => ({
|
selectedRows.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
|
@ -50,7 +42,7 @@
|
||||||
<div class="row" style="--top:{(row.__idx + 1) * cellHeight}px;">
|
<div class="row" style="--top:{(row.__idx + 1) * cellHeight}px;">
|
||||||
<SpreadsheetCell label {rowSelected} on:click={() => selectRow(row._id)}>
|
<SpreadsheetCell label {rowSelected} on:click={() => selectRow(row._id)}>
|
||||||
<div class="checkbox" class:visible={rowSelected}>
|
<div class="checkbox" class:visible={rowSelected}>
|
||||||
<input type="checkbox" checked={rowSelected} />
|
<Checkbox value={rowSelected} />
|
||||||
</div>
|
</div>
|
||||||
<div class="number" class:visible={!rowSelected}>
|
<div class="number" class:visible={!rowSelected}>
|
||||||
{row.__idx + 1}
|
{row.__idx + 1}
|
||||||
|
@ -70,7 +62,7 @@
|
||||||
column={column.idx}
|
column={column.idx}
|
||||||
>
|
>
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={getCellForField(column)}
|
this={TypeComponentMap[column.schema.type] || TextCell}
|
||||||
value={row[column.name]}
|
value={row[column.name]}
|
||||||
schema={column.schema}
|
schema={column.schema}
|
||||||
selected={$selectedCellId === cellIdx}
|
selected={$selectedCellId === cellIdx}
|
||||||
|
@ -88,7 +80,7 @@
|
||||||
top: var(--top);
|
top: var(--top);
|
||||||
width: inherit;
|
width: inherit;
|
||||||
}
|
}
|
||||||
.row:hover :global(.cell) {
|
:global(.sheet:not(.is-resizing):not(.is-reordering) .row:hover .cell) {
|
||||||
background: var(--cell-background-hover);
|
background: var(--cell-background-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,13 +88,8 @@
|
||||||
.checkbox {
|
.checkbox {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
input[type="checkbox"] {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.number {
|
.number {
|
||||||
display: none;
|
display: none;
|
||||||
min-width: 14px;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--spectrum-global-color-gray-500);
|
color: var(--spectrum-global-color-gray-500);
|
||||||
}
|
}
|
||||||
.row:hover .checkbox,
|
.row:hover .checkbox,
|
||||||
|
|
Loading…
Reference in New Issue