From fae897f4685947872d3cc8d2ad2d77842bea6e32 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Sep 2024 09:31:19 +0100 Subject: [PATCH] Allow button groups to be collapsed --- .../bbui/src/Actions/position_dropdown.js | 2 +- packages/bbui/src/Button/Button.svelte | 2 + .../data/table/[tableId]/index.svelte | 2 +- packages/client/manifest.json | 48 +++++++- .../src/components/app/ButtonGroup.svelte | 108 ++++++++++++------ .../src/components/grid/cells/GridCell.svelte | 7 +- .../grid/layout/ButtonColumn.svelte | 4 +- 7 files changed, 129 insertions(+), 44 deletions(-) diff --git a/packages/bbui/src/Actions/position_dropdown.js b/packages/bbui/src/Actions/position_dropdown.js index 7a852f1b46..e95c7dd1b6 100644 --- a/packages/bbui/src/Actions/position_dropdown.js +++ b/packages/bbui/src/Actions/position_dropdown.js @@ -246,7 +246,7 @@ export default function positionDropdown(element, opts) { } // Apply initial styles which don't need to change - element.style.position = "absolute" + element.style.position = "fixed" element.style.zIndex = "9999" // Set up a scroll listener diff --git a/packages/bbui/src/Button/Button.svelte b/packages/bbui/src/Button/Button.svelte index 9e49d84d44..7971c0ea8d 100644 --- a/packages/bbui/src/Button/Button.svelte +++ b/packages/bbui/src/Button/Button.svelte @@ -17,6 +17,7 @@ export let tooltip = undefined export let newStyles = true export let id + export let ref const dispatch = createEventDispatcher() @@ -25,6 +26,7 @@ + + + + {#each buttons as button} + handleCollapsedClick(button)} + disabled={button.disabled} + > + {button.text || "Button"} + + {/each} + + +{:else} + + + {#each buttons as { text, type, quiet, disabled, onClick, size, icon, gap }} + + {/each} + + +{/if} diff --git a/packages/frontend-core/src/components/grid/cells/GridCell.svelte b/packages/frontend-core/src/components/grid/cells/GridCell.svelte index 7b5deccb35..68f98648b4 100644 --- a/packages/frontend-core/src/components/grid/cells/GridCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/GridCell.svelte @@ -16,7 +16,12 @@ $: style = getStyle(width, selectedUser, metadata) const getStyle = (width, selectedUser, metadata) => { - let style = width === "auto" ? "width: auto;" : `flex: 0 0 ${width}px;` + let style + if (width === "auto" || width === "100%") { + style = `width: ${width};` + } else { + style = `flex: 0 0 ${width}px;` + } if (selectedUser) { style += `--user-color :${selectedUser.color};` } diff --git a/packages/frontend-core/src/components/grid/layout/ButtonColumn.svelte b/packages/frontend-core/src/components/grid/layout/ButtonColumn.svelte index bb8dd30b93..22a7e0d688 100644 --- a/packages/frontend-core/src/components/grid/layout/ButtonColumn.svelte +++ b/packages/frontend-core/src/components/grid/layout/ButtonColumn.svelte @@ -45,7 +45,7 @@ onMount(() => { const observer = new ResizeObserver(entries => { const width = entries?.[0]?.contentRect?.width ?? 0 - buttonColumnWidth.set(Math.floor(width) - 1) + buttonColumnWidth.set(width) }) observer.observe(container) }) @@ -113,7 +113,7 @@ on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)} > dispatch("add-row-inline")} />