Add temporary tooltip to help creating the first row in grids

This commit is contained in:
Andrew Kingston 2023-07-10 11:23:29 +01:00
parent ce90f9cd25
commit fb35d52ac9
2 changed files with 25 additions and 14 deletions

View File

@ -27,8 +27,8 @@
let wrapper
let hovered = false
let left = 0
let top = 0
let left
let top
let visible = false
let timeout
let interval
@ -48,6 +48,8 @@
const updateTooltipPosition = () => {
const node = wrapper?.children?.[0]
if (!node) {
left = null
top = null
return
}
const bounds = node.getBoundingClientRect()
@ -98,7 +100,7 @@
<slot />
</div>
{#if visible && text}
{#if visible && text && left != null && top != null}
<Portal target=".spectrum">
<span
class="spectrum-Tooltip spectrum-Tooltip--{type} spectrum-Tooltip--{position} is-open"

View File

@ -1,6 +1,6 @@
<script>
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 DataCell from "../cells/DataCell.svelte"
import { fade } from "svelte/transition"
@ -27,6 +27,8 @@
rowVerticalInversionIndex,
columnHorizontalInversionIndex,
selectedRows,
config,
canAddRows,
} = getContext("grid")
let visible = false
@ -39,6 +41,7 @@
$: $tableId, (visible = false)
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
$: selectedRowCount = Object.values($selectedRows).length
$: hasNoRows = !$rows.length
const shouldInvertY = (offset, inversionIndex, rows) => {
if (offset === 0) {
@ -146,16 +149,22 @@
</script>
<!-- New row FAB -->
{#if !visible && !selectedRowCount}
<div
class="new-row-fab"
on:click={() => dispatch("add-row-inline")}
transition:fade|local={{ duration: 130 }}
class:offset={!$stickyColumn}
>
<Icon name="Add" size="S" />
</div>
{/if}
<TempTooltip
text="Click here to create your first row"
condition={hasNoRows}
type={TooltipType.Info}
>
{#if !visible && !selectedRowCount && $canAddRows}
<div
class="new-row-fab"
on:click={() => dispatch("add-row-inline")}
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 -->
{#if visible}