Add temporary tooltip to help creating the first row in grids
This commit is contained in:
parent
ce90f9cd25
commit
fb35d52ac9
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
let wrapper
|
let wrapper
|
||||||
let hovered = false
|
let hovered = false
|
||||||
let left = 0
|
let left
|
||||||
let top = 0
|
let top
|
||||||
let visible = false
|
let visible = false
|
||||||
let timeout
|
let timeout
|
||||||
let interval
|
let interval
|
||||||
|
@ -48,6 +48,8 @@
|
||||||
const updateTooltipPosition = () => {
|
const updateTooltipPosition = () => {
|
||||||
const node = wrapper?.children?.[0]
|
const node = wrapper?.children?.[0]
|
||||||
if (!node) {
|
if (!node) {
|
||||||
|
left = null
|
||||||
|
top = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const bounds = node.getBoundingClientRect()
|
const bounds = node.getBoundingClientRect()
|
||||||
|
@ -98,7 +100,7 @@
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if visible && text}
|
{#if visible && text && left != null && top != null}
|
||||||
<Portal target=".spectrum">
|
<Portal target=".spectrum">
|
||||||
<span
|
<span
|
||||||
class="spectrum-Tooltip spectrum-Tooltip--{type} spectrum-Tooltip--{position} is-open"
|
class="spectrum-Tooltip spectrum-Tooltip--{type} spectrum-Tooltip--{position} is-open"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext, onDestroy, onMount, tick } from "svelte"
|
import { getContext, onDestroy, onMount, tick } from "svelte"
|
||||||
import { Icon, Button } from "@budibase/bbui"
|
import { Icon, Button, TempTooltip, TooltipType } from "@budibase/bbui"
|
||||||
import GridScrollWrapper from "./GridScrollWrapper.svelte"
|
import GridScrollWrapper from "./GridScrollWrapper.svelte"
|
||||||
import DataCell from "../cells/DataCell.svelte"
|
import DataCell from "../cells/DataCell.svelte"
|
||||||
import { fade } from "svelte/transition"
|
import { fade } from "svelte/transition"
|
||||||
|
@ -27,6 +27,8 @@
|
||||||
rowVerticalInversionIndex,
|
rowVerticalInversionIndex,
|
||||||
columnHorizontalInversionIndex,
|
columnHorizontalInversionIndex,
|
||||||
selectedRows,
|
selectedRows,
|
||||||
|
config,
|
||||||
|
canAddRows,
|
||||||
} = getContext("grid")
|
} = getContext("grid")
|
||||||
|
|
||||||
let visible = false
|
let visible = false
|
||||||
|
@ -39,6 +41,7 @@
|
||||||
$: $tableId, (visible = false)
|
$: $tableId, (visible = false)
|
||||||
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
||||||
$: selectedRowCount = Object.values($selectedRows).length
|
$: selectedRowCount = Object.values($selectedRows).length
|
||||||
|
$: hasNoRows = !$rows.length
|
||||||
|
|
||||||
const shouldInvertY = (offset, inversionIndex, rows) => {
|
const shouldInvertY = (offset, inversionIndex, rows) => {
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
|
@ -146,16 +149,22 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- New row FAB -->
|
<!-- New row FAB -->
|
||||||
{#if !visible && !selectedRowCount}
|
<TempTooltip
|
||||||
<div
|
text="Click here to create your first row"
|
||||||
class="new-row-fab"
|
condition={hasNoRows}
|
||||||
on:click={() => dispatch("add-row-inline")}
|
type={TooltipType.Info}
|
||||||
transition:fade|local={{ duration: 130 }}
|
>
|
||||||
class:offset={!$stickyColumn}
|
{#if !visible && !selectedRowCount && $canAddRows}
|
||||||
>
|
<div
|
||||||
<Icon name="Add" size="S" />
|
class="new-row-fab"
|
||||||
</div>
|
on:click={() => dispatch("add-row-inline")}
|
||||||
{/if}
|
transition:fade|local={{ duration: 130 }}
|
||||||
|
class:offset={!$stickyColumn}
|
||||||
|
>
|
||||||
|
<Icon name="Add" size="S" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</TempTooltip>
|
||||||
|
|
||||||
<!-- Only show new row functionality if we have any columns -->
|
<!-- Only show new row functionality if we have any columns -->
|
||||||
{#if visible}
|
{#if visible}
|
||||||
|
|
Loading…
Reference in New Issue