From 638b537792ac571fb38bb8debab9c308d2aef40f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 5 Jul 2023 14:37:43 +0100 Subject: [PATCH 01/15] Prevent adding rows when no non-autocolumn columns exist --- .../grid/controls/AddColumnButton.svelte | 16 -------------- .../grid/controls/AddRowButton.svelte | 18 ---------------- .../src/components/grid/layout/Grid.svelte | 3 ++- .../components/grid/layout/GridBody.svelte | 4 ++-- .../src/components/grid/layout/NewRow.svelte | 3 +-- .../grid/layout/StickyColumn.svelte | 5 ++--- .../grid/overlays/KeyboardManager.svelte | 5 +++-- .../grid/overlays/MenuOverlay.svelte | 3 ++- .../src/components/grid/stores/ui.js | 21 +++++++++++++++++++ 9 files changed, 33 insertions(+), 45 deletions(-) delete mode 100644 packages/frontend-core/src/components/grid/controls/AddColumnButton.svelte delete mode 100644 packages/frontend-core/src/components/grid/controls/AddRowButton.svelte diff --git a/packages/frontend-core/src/components/grid/controls/AddColumnButton.svelte b/packages/frontend-core/src/components/grid/controls/AddColumnButton.svelte deleted file mode 100644 index 20125bc49c..0000000000 --- a/packages/frontend-core/src/components/grid/controls/AddColumnButton.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - dispatch("add-column")} - disabled={!$config.allowSchemaChanges} -> - Add column - diff --git a/packages/frontend-core/src/components/grid/controls/AddRowButton.svelte b/packages/frontend-core/src/components/grid/controls/AddRowButton.svelte deleted file mode 100644 index 71062d6a1a..0000000000 --- a/packages/frontend-core/src/components/grid/controls/AddRowButton.svelte +++ /dev/null @@ -1,18 +0,0 @@ - - - dispatch("add-row-inline")} - disabled={!loaded || - !$config.allowAddRows || - (!$columns.length && !$stickyColumn)} -> - Add row - diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index 5b9bff8865..cc74c726c1 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -71,6 +71,7 @@ contentLines, gridFocused, error, + canAddRows, } = context // Keep config store up to date with props @@ -143,7 +144,7 @@ - {#if allowAddRows} + {#if $canAddRows} {/if}
diff --git a/packages/frontend-core/src/components/grid/layout/GridBody.svelte b/packages/frontend-core/src/components/grid/layout/GridBody.svelte index b5f6c38287..e8a721b2a7 100644 --- a/packages/frontend-core/src/components/grid/layout/GridBody.svelte +++ b/packages/frontend-core/src/components/grid/layout/GridBody.svelte @@ -9,7 +9,7 @@ renderedRows, renderedColumns, rowVerticalInversionIndex, - config, + canAddRows, hoveredRowId, dispatch, isDragging, @@ -43,7 +43,7 @@ invertY={idx >= $rowVerticalInversionIndex} /> {/each} - {#if $config.allowAddRows && $renderedColumns.length} + {#if $canAddRows}
-{#if !visible && !selectedRowCount && $config.allowAddRows && firstColumn} +{#if !visible && !selectedRowCount}
dispatch("add-row-inline")} diff --git a/packages/frontend-core/src/components/grid/layout/StickyColumn.svelte b/packages/frontend-core/src/components/grid/layout/StickyColumn.svelte index 97b40e3e23..1fc55e612c 100644 --- a/packages/frontend-core/src/components/grid/layout/StickyColumn.svelte +++ b/packages/frontend-core/src/components/grid/layout/StickyColumn.svelte @@ -13,11 +13,10 @@ rows, selectedRows, stickyColumn, - renderedColumns, renderedRows, focusedCellId, hoveredRowId, - config, + canAddRows, selectedCellMap, focusedRow, scrollLeft, @@ -93,7 +92,7 @@ {/if}
{/each} - {#if $config.allowAddRows && ($renderedColumns.length || $stickyColumn)} + {#if $canAddRows}
Duplicate row diff --git a/packages/frontend-core/src/components/grid/stores/ui.js b/packages/frontend-core/src/components/grid/stores/ui.js index c88ad9499d..671addc087 100644 --- a/packages/frontend-core/src/components/grid/stores/ui.js +++ b/packages/frontend-core/src/components/grid/stores/ui.js @@ -70,6 +70,9 @@ export const deriveStores = context => { rowHeight, stickyColumn, width, + columns, + stickyColumns, + config, } = context // Derive the row that contains the selected cell @@ -112,7 +115,25 @@ export const deriveStores = context => { return ($stickyColumn?.width || 0) + $width + GutterWidth < 1100 }) + // Derive if we're able to add rows + const canAddRows = derived( + [config, columns, stickyColumn], + ([$config, $columns, $stickyColumn]) => { + // Check if we have a normal column + let allCols = $columns || [] + if ($stickyColumn) { + allCols = [...allCols, $stickyColumn] + } + const normalCols = allCols.filter(column => { + return column.visible && !column.schema?.autocolumn + }) + // Check if we're allowed to add rows + return $config.allowAddRows && normalCols.length > 0 + } + ) + return { + canAddRows, focusedRow, contentLines, compact, From 75c4b927662bc1b274ced14a600f717affdd67b5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 5 Jul 2023 15:46:07 +0100 Subject: [PATCH 02/15] Add new tooltip which is far better --- packages/bbui/src/Tooltip/AbsTooltip.svelte | 120 ++++++++++++++++++ packages/bbui/src/index.js | 5 + .../components/grid/layout/HeaderRow.svelte | 25 +++- 3 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 packages/bbui/src/Tooltip/AbsTooltip.svelte diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte new file mode 100644 index 0000000000..a407c34de3 --- /dev/null +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -0,0 +1,120 @@ + + + + +
+ +
+{#if visible} + + + {text} + + + +{/if} + + diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index d26b938dd5..cbe9ddbff5 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -36,6 +36,11 @@ export { default as Layout } from "./Layout/Layout.svelte" export { default as Page } from "./Layout/Page.svelte" export { default as Link } from "./Link/Link.svelte" export { default as Tooltip } from "./Tooltip/Tooltip.svelte" +export { + default as AbsTooltip, + TooltipDirection, + TooltipType, +} from "./Tooltip/AbsTooltip.svelte" export { default as TooltipWrapper } from "./Tooltip/TooltipWrapper.svelte" export { default as Menu } from "./Menu/Menu.svelte" export { default as MenuSection } from "./Menu/Section.svelte" diff --git a/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte b/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte index f31cc198fb..de73281bd5 100644 --- a/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte +++ b/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte @@ -2,7 +2,12 @@ import { getContext } from "svelte" import GridScrollWrapper from "./GridScrollWrapper.svelte" import HeaderCell from "../cells/HeaderCell.svelte" - import { Icon } from "@budibase/bbui" + import { + Icon, + AbsTooltip, + TooltipType, + TooltipDirection, + } from "@budibase/bbui" const { renderedColumns, @@ -30,13 +35,19 @@
{#if $config.allowSchemaChanges} -
dispatch("add-column")} + - -
+
dispatch("add-column")} + > + +
+ {/if}
From 35150af784eee218455f1ce36993932b6348bb78 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Jul 2023 12:09:23 +0100 Subject: [PATCH 03/15] Update multiple usages of tooltips to use new tooltip --- packages/bbui/src/Button/Button.svelte | 99 +++++++++---------- packages/bbui/src/Popover/Popover.svelte | 2 +- packages/bbui/src/Tooltip/AbsTooltip.svelte | 56 ++++++----- packages/bbui/src/index.js | 2 +- .../src/components/deploy/AppActions.svelte | 22 +++-- .../components/portal/page/SideNavItem.svelte | 21 ---- .../app/[application]/settings/_layout.svelte | 22 +++-- .../_components/ActionsRenderer.svelte | 22 +++-- .../components/grid/layout/HeaderRow.svelte | 4 +- 9 files changed, 118 insertions(+), 132 deletions(-) diff --git a/packages/bbui/src/Button/Button.svelte b/packages/bbui/src/Button/Button.svelte index 91affdb6c7..9e49d84d44 100644 --- a/packages/bbui/src/Button/Button.svelte +++ b/packages/bbui/src/Button/Button.svelte @@ -1,6 +1,7 @@ - + + + diff --git a/packages/bbui/src/Popover/Popover.svelte b/packages/bbui/src/Popover/Popover.svelte index 20207a85da..9f951a6a7e 100644 --- a/packages/bbui/src/Popover/Popover.svelte +++ b/packages/bbui/src/Popover/Popover.svelte @@ -90,6 +90,6 @@ .spectrum-Popover { min-width: var(--spectrum-global-dimension-size-2000); border-color: var(--spectrum-global-color-gray-300); - overflow: visible; + overflow: auto; } diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte index a407c34de3..78a4d5f609 100644 --- a/packages/bbui/src/Tooltip/AbsTooltip.svelte +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -1,5 +1,5 @@ -
+{#if text} +
+ +
+ {#if visible} + + + {text} + + + + {/if} +{:else} -
-{#if visible} - - - {text} - - - {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte index de65333f6f..7020e8fc11 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte @@ -1,6 +1,6 @@ From 99ef4f2992d6065bf6a72f252fa7c11b790cf9dd Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Jul 2023 14:46:41 +0100 Subject: [PATCH 05/15] Add new temporary tooltip component. Improve tooltips and user avatars --- packages/bbui/src/Tooltip/AbsTooltip.svelte | 67 ++++++++++------ packages/bbui/src/Tooltip/TempTooltip.svelte | 39 +++++++++ packages/bbui/src/index.js | 1 + .../src/components/common/NavItem.svelte | 80 +++++++++++-------- .../_components/UserAvatars.svelte | 14 +++- .../app/[application]/settings/_layout.svelte | 2 +- .../src/components/UserAvatar.svelte | 53 ++---------- .../components/grid/layout/HeaderRow.svelte | 33 ++++---- .../src/components/grid/stores/columns.js | 16 ++++ .../src/components/grid/stores/ui.js | 18 +---- 10 files changed, 186 insertions(+), 137 deletions(-) create mode 100644 packages/bbui/src/Tooltip/TempTooltip.svelte diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte index 3e8caa389e..c6963d0870 100644 --- a/packages/bbui/src/Tooltip/AbsTooltip.svelte +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -5,7 +5,6 @@ Bottom: "bottom", Left: "left", } - export const TooltipType = { Default: "default", Info: "info", @@ -23,14 +22,27 @@ export let type = TooltipType.Default export let text = "" export let fixed = false + export let color = null let wrapper let hovered = false let left = 0 let top = 0 + let visible = false + let timeout - $: visible = hovered || fixed + $: { + if (hovered || fixed) { + timeout = setTimeout(show, 200) + } else { + clearTimeout(timeout) + hide() + } + } + $: tooltipStyle = color ? `background:${color};` : null + $: tipStyle = color ? `border-top-color:${color};` : null + // Computes the position of the tooltip then shows it const show = () => { const node = wrapper?.children?.[0] if (!node) { @@ -38,6 +50,7 @@ } const bounds = node.getBoundingClientRect() + // Determine where to render tooltip based on position prop if (position === TooltipPosition.Top) { left = bounds.left + bounds.width / 2 top = bounds.top @@ -54,36 +67,36 @@ return } - hovered = true + visible = true } + + // Hides the tooltip const hide = () => { - hovered = false + visible = false } -{#if text} -
- -
- {#if visible} - - - {text} - - - - {/if} -{:else} +
(hovered = true)} + on:mouseleave={() => (hovered = false)} +> +
+ +{#if visible && text} + + + {text} + + + {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte index 7020e8fc11..7063a271be 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte @@ -46,7 +46,7 @@ />
- import { Avatar, Tooltip } from "@budibase/bbui" + import { Avatar, AbsTooltip, TooltipPosition } from "@budibase/bbui" import { helpers } from "@budibase/shared-core" export let user export let size - export let tooltipDirection = "top" + export let tooltipPosition = TooltipPosition.Top export let showTooltip = true - - $: tooltipStyle = getTooltipStyle(tooltipDirection) - - const getTooltipStyle = direction => { - if (!direction) { - return "" - } - if (direction === "top") { - return "transform: translateX(-50%) translateY(-100%);" - } else if (direction === "bottom") { - return "transform: translateX(-50%) translateY(100%);" - } - } {#if user} -
+ - {#if showTooltip} -
- -
- {/if} -
+
{/if} - - diff --git a/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte b/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte index f5e6365b88..71bde9d3d8 100644 --- a/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte +++ b/packages/frontend-core/src/components/grid/layout/HeaderRow.svelte @@ -4,7 +4,7 @@ import HeaderCell from "../cells/HeaderCell.svelte" import { Icon, - AbsTooltip, + TempTooltip, TooltipType, TooltipPosition, } from "@budibase/bbui" @@ -16,10 +16,11 @@ hiddenColumnsWidth, width, config, + hasNonAutoColumn, } = getContext("grid") $: columnsWidth = $renderedColumns.reduce( - (total, col) => (total += col.width), + (total, col) => total + col.width, 0 ) $: end = $hiddenColumnsWidth + columnsWidth - 1 - $scroll.left @@ -35,19 +36,23 @@
{#if $config.allowSchemaChanges} - -
dispatch("add-column")} + {#key left} + - -
-
+
dispatch("add-column")} + > + +
+ + {/key} {/if}
diff --git a/packages/frontend-core/src/components/grid/stores/columns.js b/packages/frontend-core/src/components/grid/stores/columns.js index 21458eaefb..6ca8704c1c 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.js +++ b/packages/frontend-core/src/components/grid/stores/columns.js @@ -83,6 +83,21 @@ export const deriveStores = context => { await saveChanges() } + // Derive if we have any normal columns + const hasNonAutoColumn = derived( + [columns, stickyColumn], + ([$columns, $stickyColumn]) => { + let allCols = $columns || [] + if ($stickyColumn) { + allCols = [...allCols, $stickyColumn] + } + const normalCols = allCols.filter(column => { + return !column.schema?.autocolumn + }) + return normalCols.length > 0 + } + ) + // Persists column changes by saving metadata against table schema const saveChanges = async () => { const $columns = get(columns) @@ -128,6 +143,7 @@ export const deriveStores = context => { } return { + hasNonAutoColumn, columns: { ...columns, actions: { diff --git a/packages/frontend-core/src/components/grid/stores/ui.js b/packages/frontend-core/src/components/grid/stores/ui.js index 671addc087..2f16265273 100644 --- a/packages/frontend-core/src/components/grid/stores/ui.js +++ b/packages/frontend-core/src/components/grid/stores/ui.js @@ -70,8 +70,7 @@ export const deriveStores = context => { rowHeight, stickyColumn, width, - columns, - stickyColumns, + hasNonAutoColumn, config, } = context @@ -117,18 +116,9 @@ export const deriveStores = context => { // Derive if we're able to add rows const canAddRows = derived( - [config, columns, stickyColumn], - ([$config, $columns, $stickyColumn]) => { - // Check if we have a normal column - let allCols = $columns || [] - if ($stickyColumn) { - allCols = [...allCols, $stickyColumn] - } - const normalCols = allCols.filter(column => { - return column.visible && !column.schema?.autocolumn - }) - // Check if we're allowed to add rows - return $config.allowAddRows && normalCols.length > 0 + [config, hasNonAutoColumn], + ([$config, $hasNonAutoColumn]) => { + return $config.allowAddRows && $hasNonAutoColumn } ) From 62e452dfe70981748d9cd59b376d356b347ba970 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Jul 2023 15:45:18 +0100 Subject: [PATCH 06/15] Update user avatars and selection state for collaboration --- packages/builder/src/builderStore/index.js | 8 +++- .../src/components/common/NavItem.svelte | 6 ++- .../_components/UserAvatars.svelte | 48 +++++++++++++++---- .../builder/app/[application]/_layout.svelte | 2 +- .../src/components/UserAvatar.svelte | 2 +- 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index 16a87810ad..2ca8057b48 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -127,8 +127,12 @@ export const selectedAutomation = derived(automationStore, $automationStore => { export const userSelectedResourceMap = derived(userStore, $userStore => { let map = {} $userStore.forEach(user => { - if (user.builderMetadata?.selectedResourceId) { - map[user.builderMetadata?.selectedResourceId] = user + const resource = user.builderMetadata?.selectedResourceId + if (resource) { + if (!map[resource]) { + map[resource] = [] + } + map[resource].push(user) } }) return map diff --git a/packages/builder/src/components/common/NavItem.svelte b/packages/builder/src/components/common/NavItem.svelte index 5309bc0d7d..468f60b9f7 100644 --- a/packages/builder/src/components/common/NavItem.svelte +++ b/packages/builder/src/components/common/NavItem.svelte @@ -3,6 +3,7 @@ import { createEventDispatcher, getContext } from "svelte" import { helpers } from "@budibase/shared-core" import { UserAvatar } from "@budibase/frontend-core" + import UserAvatars from "../../pages/builder/app/[application]/_components/UserAvatars.svelte" export let icon export let withArrow = false @@ -102,7 +103,7 @@
{text} {#if selectedBy} - + {/if}
@@ -145,13 +146,16 @@ } .nav-item.highlighted { background-color: var(--spectrum-global-color-gray-200); + --avatars-background: var(--spectrum-global-color-gray-200); } .nav-item.selected { background-color: var(--spectrum-global-color-gray-300); + --avatars-background: var(--spectrum-global-color-gray-300); color: var(--ink); } .nav-item:hover { background-color: var(--spectrum-global-color-gray-300); + --avatars-background: var(--spectrum-global-color-gray-300); } .nav-item:hover .actions { visibility: visible; diff --git a/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte b/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte index dc4938b9bd..9e62951d53 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte @@ -1,24 +1,54 @@
- {#each uniqueUsers as user, idx} - - + {#each avatars as user} + + {#if user._id === "overflow"} + + {:else} + + {/if} {/each}
@@ -27,10 +57,10 @@ .avatars { display: flex; } - .avatars :global(> *:not(:first-child)) { - margin-left: -12px; + span:not(:first-of-type) { + margin-left: -6px; } .avatars :global(.spectrum-Avatar) { - border: 2px solid var(--background); + border: 2px solid var(--avatars-background, var(--background)); } diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index e6c79335a9..8586a300fc 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -172,7 +172,7 @@
- +
diff --git a/packages/frontend-core/src/components/UserAvatar.svelte b/packages/frontend-core/src/components/UserAvatar.svelte index 97a06aa569..bc630ed473 100644 --- a/packages/frontend-core/src/components/UserAvatar.svelte +++ b/packages/frontend-core/src/components/UserAvatar.svelte @@ -3,7 +3,7 @@ import { helpers } from "@budibase/shared-core" export let user - export let size + export let size = "S" export let tooltipPosition = TooltipPosition.Top export let showTooltip = true From 06876b0ea2a79a3660e99bce83df4d10abddde06 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Jul 2023 16:03:25 +0100 Subject: [PATCH 07/15] Improve tooltips more by ensuring they follow the target smoothly --- packages/bbui/src/Tooltip/AbsTooltip.svelte | 25 ++++++++++++++----- .../components/grid/layout/HeaderRow.svelte | 17 +++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte index c6963d0870..3a2c035615 100644 --- a/packages/bbui/src/Tooltip/AbsTooltip.svelte +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -17,6 +17,7 @@ import Portal from "svelte-portal" import { fade } from "svelte/transition" import "@spectrum-css/tooltip/dist/index-vars.css" + import { onDestroy } from "svelte" export let position = TooltipPosition.Top export let type = TooltipType.Default @@ -30,20 +31,21 @@ let top = 0 let visible = false let timeout + let interval $: { if (hovered || fixed) { + // Debounce showing by 200ms to avoid flashing tooltip timeout = setTimeout(show, 200) } else { - clearTimeout(timeout) hide() } } $: tooltipStyle = color ? `background:${color};` : null $: tipStyle = color ? `border-top-color:${color};` : null - // Computes the position of the tooltip then shows it - const show = () => { + // Computes the position of the tooltip + const updateTooltipPosition = () => { const node = wrapper?.children?.[0] if (!node) { return @@ -63,17 +65,27 @@ } else if (position === TooltipPosition.Left) { left = bounds.left top = bounds.top + bounds.height / 2 - } else { - return } + } + // Computes the position of the tooltip then shows it. + // We set up a poll to frequently update the position of the tooltip in case + // the target moves. + const show = () => { + updateTooltipPosition() + interval = setInterval(updateTooltipPosition, 100) visible = true } // Hides the tooltip const hide = () => { + clearTimeout(timeout) + clearInterval(interval) visible = false } + + // Ensure we clean up interval and timeout + onDestroy(hide)
{#if $config.allowSchemaChanges} - {#key left} + {#key $tableId}
dispatch("add-column")} > From ce90f9cd257e4534744e18dcffec60b331121e42 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Jul 2023 16:05:23 +0100 Subject: [PATCH 08/15] Improve position of user avatar tooltips --- .../app/[application]/_components/UserAvatars.svelte | 3 ++- .../src/pages/builder/app/[application]/_layout.svelte | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte b/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte index 9e62951d53..7e9682dacc 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/UserAvatars.svelte @@ -5,6 +5,7 @@ export let users = [] export let order = "ltr" export let size = "S" + export let tooltipPosition = TooltipPosition.Top $: uniqueUsers = unique(users, order) $: avatars = getAvatars(uniqueUsers, order) @@ -47,7 +48,7 @@ color="var(--spectrum-global-color-gray-500)" /> {:else} - + {/if} {/each} diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index 8586a300fc..8e637d6fa2 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -15,6 +15,7 @@ Heading, Modal, notifications, + TooltipPosition, } from "@budibase/bbui" import AppActions from "components/deploy/AppActions.svelte" import { API } from "api" @@ -172,7 +173,11 @@
- +
From fb35d52ac98ee880a41e79f6e5c929ff5c898a49 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 10 Jul 2023 11:23:29 +0100 Subject: [PATCH 09/15] Add temporary tooltip to help creating the first row in grids --- packages/bbui/src/Tooltip/AbsTooltip.svelte | 8 +++-- .../src/components/grid/layout/NewRow.svelte | 31 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte index 3a2c035615..9be7251445 100644 --- a/packages/bbui/src/Tooltip/AbsTooltip.svelte +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -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 @@
-{#if visible && text} +{#if visible && text && left != null && top != null} 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 @@ -{#if !visible && !selectedRowCount} -
dispatch("add-row-inline")} - transition:fade|local={{ duration: 130 }} - class:offset={!$stickyColumn} - > - -
-{/if} + + {#if !visible && !selectedRowCount && $canAddRows} +
dispatch("add-row-inline")} + transition:fade|local={{ duration: 130 }} + class:offset={!$stickyColumn} + > + +
+ {/if} +
{#if visible} From ca375b7c39efe3d5a987ccbfbfd2b4e118bb1130 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 10 Jul 2023 11:51:07 +0100 Subject: [PATCH 10/15] Lint --- .../src/components/common/NavItem.svelte | 36 ------------------- .../src/components/grid/layout/NewRow.svelte | 4 +-- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/packages/builder/src/components/common/NavItem.svelte b/packages/builder/src/components/common/NavItem.svelte index 468f60b9f7..6f87c8c362 100644 --- a/packages/builder/src/components/common/NavItem.svelte +++ b/packages/builder/src/components/common/NavItem.svelte @@ -2,7 +2,6 @@ import { Icon } from "@budibase/bbui" import { createEventDispatcher, getContext } from "svelte" import { helpers } from "@budibase/shared-core" - import { UserAvatar } from "@budibase/frontend-core" import UserAvatars from "../../pages/builder/app/[application]/_components/UserAvatars.svelte" export let icon @@ -119,10 +118,6 @@ {/if} - - - -