mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 23:26:00 +00:00
#810 hide non active tool strip containers
This commit is contained in:
@@ -1,11 +1,24 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { get_current_component } from 'svelte/internal';
|
||||||
|
import createActivator, { isComponentActiveStore } from '../utility/createActivator';
|
||||||
|
|
||||||
|
const thisInstance = get_current_component();
|
||||||
|
|
||||||
|
export const activator = createActivator('ToolStripContainer', false);
|
||||||
|
|
||||||
|
$: isComponentActive = $isComponentActiveStore('ToolStripContainer', thisInstance);
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if isComponentActive}
|
||||||
<div class="toolstrip">
|
<div class="toolstrip">
|
||||||
<slot name="toolstrip" />
|
<slot name="toolstrip" />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { get_current_component, onMount, setContext } from 'svelte/internal';
|
import { get_current_component, onMount, setContext } from 'svelte/internal';
|
||||||
import invalidateCommands from '../commands/invalidateCommands';
|
import invalidateCommands from '../commands/invalidateCommands';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
const lastActiveDictionary = {};
|
const lastActiveDictionary = {};
|
||||||
|
|
||||||
|
export const isComponentActiveStore = writable((key: string, component) => false as boolean);
|
||||||
|
|
||||||
function isParent(parent, child) {
|
function isParent(parent, child) {
|
||||||
while (child && child.activator) {
|
while (child && child.activator) {
|
||||||
if (parent == child) return true;
|
if (parent == child) return true;
|
||||||
@@ -63,6 +66,10 @@ export default function createActivator(
|
|||||||
parentActivatorInstance.activator.activate();
|
parentActivatorInstance.activator.activate();
|
||||||
}
|
}
|
||||||
// console.log('Active components', lastActiveDictionary);
|
// console.log('Active components', lastActiveDictionary);
|
||||||
|
|
||||||
|
isComponentActiveStore.set((key, component) => {
|
||||||
|
return lastActiveDictionary[key] == component;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTabVisible = () => tabVisibleValue;
|
const getTabVisible = () => tabVisibleValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user