From b459ee250c4ef20a203c09d470e7373408d4412d Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 12 Feb 2022 11:53:28 +0100 Subject: [PATCH] tab toolbar POC --- packages/web/public/dimensions.css | 2 +- packages/web/src/datagrid/DataGridCore.svelte | 2 + packages/web/src/tabs/TableDataTab.svelte | 32 ++++++--- .../web/src/widgets/RoundToolbarButton.svelte | 69 +++++++++++++++++++ .../src/widgets/TabToolbarContainer.svelte | 27 ++++++++ packages/web/src/widgets/ToolbarButton.svelte | 5 +- .../src/widgets/ToolbarCommandButton.svelte | 29 ++++++++ 7 files changed, 152 insertions(+), 14 deletions(-) create mode 100644 packages/web/src/widgets/RoundToolbarButton.svelte create mode 100644 packages/web/src/widgets/TabToolbarContainer.svelte create mode 100644 packages/web/src/widgets/ToolbarCommandButton.svelte diff --git a/packages/web/public/dimensions.css b/packages/web/public/dimensions.css index 48069830..44e83f84 100644 --- a/packages/web/public/dimensions.css +++ b/packages/web/public/dimensions.css @@ -15,7 +15,7 @@ --dim-visible-toolbar: 0; /* set from JS */ --dim-visible-titlebar: 0; /* set from JS */ - --dim-toolbar-height: 30px; + --dim-toolbar-height: 25px; --dim-titlebar-height: 30px; --dim-toolbar-top: calc(var(--dim-titlebar-height) * var(--dim-visible-titlebar)); --dim-header-top: calc( diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index 79fb627b..9882fd7a 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -43,6 +43,8 @@ id: 'dataGrid.insertNewRow', category: 'Data grid', name: 'Insert new row', + toolbarName: 'New row', + icon: 'icon add', keyText: 'Insert', testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable, onClick: () => getCurrentDataGrid().insertNewRow(), diff --git a/packages/web/src/tabs/TableDataTab.svelte b/packages/web/src/tabs/TableDataTab.svelte index 0e9a56f8..9d91a4b9 100644 --- a/packages/web/src/tabs/TableDataTab.svelte +++ b/packages/web/src/tabs/TableDataTab.svelte @@ -54,6 +54,8 @@ import { setContext } from 'svelte'; import { apiCall } from '../utility/api'; import { getLocalStorage, setLocalStorage, setLocalStorage } from '../utility/storageCache'; + import TabToolbarContainer from '../widgets/TabToolbarContainer.svelte'; + import ToolbarCommandButton from '../widgets/ToolbarCommandButton.svelte'; export let tabid; export let conid; @@ -116,17 +118,25 @@ $: setLocalStorage('dataGrid_collapsedLeftColumn', $collapsedLeftColumnStore); - + + + + + + + + + + import { createEventDispatcher } from 'svelte'; + import FontIcon from '../icons/FontIcon.svelte'; + + export let disabled = false; + export let icon = null; + export let title = null; + export let externalImage = null; + + const dispatch = createEventDispatcher(); + + function handleClick(e) { + if (disabled) return; + dispatch('click'); + } + + +
+
+ {#if externalImage} + + {:else} + + + {/if} +
+
+ + diff --git a/packages/web/src/widgets/TabToolbarContainer.svelte b/packages/web/src/widgets/TabToolbarContainer.svelte new file mode 100644 index 00000000..9e4ca352 --- /dev/null +++ b/packages/web/src/widgets/TabToolbarContainer.svelte @@ -0,0 +1,27 @@ +
+ +
+ +
+ +
+ + diff --git a/packages/web/src/widgets/ToolbarButton.svelte b/packages/web/src/widgets/ToolbarButton.svelte index 4c9cbd85..51f8e1c1 100644 --- a/packages/web/src/widgets/ToolbarButton.svelte +++ b/packages/web/src/widgets/ToolbarButton.svelte @@ -36,14 +36,15 @@ border-right: 1px solid var(--theme-border); align-self: stretch; display: flex; + user-select: none; } .button.disabled { color: var(--theme-font-3); } - .button:hover { + .button:hover:not(.disabled) { background: var(--theme-bg-2); } - .button:active:hover { + .button:active:hover:not(.disabled) { background: var(--theme-bg-3); } .icon { diff --git a/packages/web/src/widgets/ToolbarCommandButton.svelte b/packages/web/src/widgets/ToolbarCommandButton.svelte new file mode 100644 index 00000000..7c728929 --- /dev/null +++ b/packages/web/src/widgets/ToolbarCommandButton.svelte @@ -0,0 +1,29 @@ + + + + +{#if cmd} + + {cmd.toolbarName || cmd.name} + +{/if}