tab toolbar POC

This commit is contained in:
Jan Prochazka 2022-02-12 11:53:28 +01:00
parent 50984cae89
commit b459ee250c
7 changed files with 152 additions and 14 deletions

View File

@ -15,7 +15,7 @@
--dim-visible-toolbar: 0; /* set from JS */ --dim-visible-toolbar: 0; /* set from JS */
--dim-visible-titlebar: 0; /* set from JS */ --dim-visible-titlebar: 0; /* set from JS */
--dim-toolbar-height: 30px; --dim-toolbar-height: 25px;
--dim-titlebar-height: 30px; --dim-titlebar-height: 30px;
--dim-toolbar-top: calc(var(--dim-titlebar-height) * var(--dim-visible-titlebar)); --dim-toolbar-top: calc(var(--dim-titlebar-height) * var(--dim-visible-titlebar));
--dim-header-top: calc( --dim-header-top: calc(

View File

@ -43,6 +43,8 @@
id: 'dataGrid.insertNewRow', id: 'dataGrid.insertNewRow',
category: 'Data grid', category: 'Data grid',
name: 'Insert new row', name: 'Insert new row',
toolbarName: 'New row',
icon: 'icon add',
keyText: 'Insert', keyText: 'Insert',
testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable, testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable,
onClick: () => getCurrentDataGrid().insertNewRow(), onClick: () => getCurrentDataGrid().insertNewRow(),

View File

@ -54,6 +54,8 @@
import { setContext } from 'svelte'; import { setContext } from 'svelte';
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
import { getLocalStorage, setLocalStorage, setLocalStorage } from '../utility/storageCache'; import { getLocalStorage, setLocalStorage, setLocalStorage } from '../utility/storageCache';
import TabToolbarContainer from '../widgets/TabToolbarContainer.svelte';
import ToolbarCommandButton from '../widgets/ToolbarCommandButton.svelte';
export let tabid; export let tabid;
export let conid; export let conid;
@ -116,7 +118,8 @@
$: setLocalStorage('dataGrid_collapsedLeftColumn', $collapsedLeftColumnStore); $: setLocalStorage('dataGrid_collapsedLeftColumn', $collapsedLeftColumnStore);
</script> </script>
<TableDataGrid <TabToolbarContainer>
<TableDataGrid
{...$$props} {...$$props}
config={$config} config={$config}
setConfig={config.update} setConfig={config.update}
@ -126,7 +129,14 @@
focusOnVisible focusOnVisible
{changeSetStore} {changeSetStore}
{dispatchChangeSet} {dispatchChangeSet}
/> />
<svelte:fragment slot="toolbar">
<ToolbarCommandButton command="dataGrid.refresh" />
<ToolbarCommandButton command="tableData.save" />
<ToolbarCommandButton command="dataGrid.insertNewRow" />
</svelte:fragment>
</TabToolbarContainer>
<StatusBarTabItem <StatusBarTabItem
text="Open structure" text="Open structure"

View File

@ -0,0 +1,69 @@
<script lang="ts">
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');
}
</script>
<div class="button" on:click={handleClick} class:disabled {title}>
<div class="inner" class:disabled>
{#if externalImage}
<img src={externalImage} />
{:else}
<span class="icon" class:disabled><FontIcon {icon} /></span>
<slot />
{/if}
</div>
</div>
<style>
.button {
/* padding: 5px 15px; */
padding-left: 5px;
padding-right: 5px;
color: var(--theme-font-1);
border: 0;
align-self: stretch;
display: flex;
user-select: none;
}
.button.disabled {
color: var(--theme-font-3);
}
.inner:hover:not(.disabled) {
background: var(--theme-bg-3);
}
.inner:active:hover:not(.disabled) {
background: var(--theme-bg-4);
}
.icon {
margin-right: 5px;
color: var(--theme-font-link);
}
.icon.disabled {
color: var(--theme-font-3);
}
.inner {
/* position: relative;
top: 2px; */
white-space: nowrap;
align-self: center;
background: var(--theme-bg-2);
padding: 2px 8px;
border-radius: 4px;
}
img {
width: 20px;
height: 20px;
}
</style>

View File

@ -0,0 +1,27 @@
<div class="toolbar">
<slot name="toolbar" />
</div>
<div class="content">
<slot />
</div>
<style>
.content {
position: absolute;
left: 0;
top: var(--dim-toolbar-height);
right: 0;
bottom: 0;
display: flex;
}
.toolbar {
position: absolute;
left: 0;
height: var(--dim-toolbar-height);
right: 0;
display: flex;
background: var(--theme-bg-0);
}
</style>

View File

@ -36,14 +36,15 @@
border-right: 1px solid var(--theme-border); border-right: 1px solid var(--theme-border);
align-self: stretch; align-self: stretch;
display: flex; display: flex;
user-select: none;
} }
.button.disabled { .button.disabled {
color: var(--theme-font-3); color: var(--theme-font-3);
} }
.button:hover { .button:hover:not(.disabled) {
background: var(--theme-bg-2); background: var(--theme-bg-2);
} }
.button:active:hover { .button:active:hover:not(.disabled) {
background: var(--theme-bg-3); background: var(--theme-bg-3);
} }
.icon { .icon {

View File

@ -0,0 +1,29 @@
<script context="module">
function getCommandTitle(command) {
let res = command.text;
if (command.keyText || command.keyTextFromGroup) res += ` (${command.keyText || command.keyTextFromGroup})`;
return res;
}
</script>
<script lang="ts">
import { commandsCustomized } from '../stores';
import RoundToolbarButton from './RoundToolbarButton.svelte';
export let command;
export let component = RoundToolbarButton;
$: cmd = Object.values($commandsCustomized).find((x: any) => x.id == command) as any;
</script>
{#if cmd}
<svelte:component
this={component}
title={getCommandTitle(cmd)}
icon={cmd.icon}
on:click={cmd.onClick}
disabled={!cmd.enabled}
>
{cmd.toolbarName || cmd.name}
</svelte:component>
{/if}