mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 20:53:57 +00:00
left panel logic
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import WidgetContainer from './widgets/WidgetContainer.svelte';
|
||||||
import WidgetIconPanel from './widgets/WidgetIconPanel.svelte';
|
import WidgetIconPanel from './widgets/WidgetIconPanel.svelte';
|
||||||
|
import { leftPanelWidth, selectedWidget } from './stores';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="theme-dark">
|
<div class="theme-dark">
|
||||||
@@ -7,6 +9,11 @@
|
|||||||
<WidgetIconPanel />
|
<WidgetIconPanel />
|
||||||
</div>
|
</div>
|
||||||
<div class="statusbar" />
|
<div class="statusbar" />
|
||||||
|
{#if $selectedWidget}
|
||||||
|
<div class="leftpanel" style="width: {$leftPanelWidth}px">
|
||||||
|
<WidgetContainer />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -30,4 +37,12 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
.leftpanel {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: var(--widget-icon-size);
|
||||||
|
bottom: var(--statusbar-height);
|
||||||
|
background-color: var(--theme-left_background);
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
4
packages/web-svelte/src/stores.ts
Normal file
4
packages/web-svelte/src/stores.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
export const selectedWidget = writable('database');
|
||||||
|
export const leftPanelWidth = writable(300);
|
||||||
1
packages/web-svelte/src/widgets/DatabaseWidget.svelte
Normal file
1
packages/web-svelte/src/widgets/DatabaseWidget.svelte
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<div></div>
|
||||||
10
packages/web-svelte/src/widgets/WidgetContainer.svelte
Normal file
10
packages/web-svelte/src/widgets/WidgetContainer.svelte
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
import { selectedWidget } from '../stores';
|
||||||
|
import DatabaseWidget from './DatabaseWidget.svelte';
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if $selectedWidget == 'database'}
|
||||||
|
<DatabaseWidget />
|
||||||
|
{/if}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
import { selectedWidget } from '../stores';
|
||||||
let selectedWidget = 'database';
|
|
||||||
|
|
||||||
const widgets = [
|
const widgets = [
|
||||||
{
|
{
|
||||||
@@ -42,10 +41,15 @@
|
|||||||
// name: 'settings',
|
// name: 'settings',
|
||||||
// },
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function handleChangeWidget(name) {
|
||||||
|
selectedWidget.set(name == $selectedWidget ? null : name);
|
||||||
|
}
|
||||||
|
//const handleChangeWidget= e => (selectedWidget.set(item.name))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each widgets as item}
|
{#each widgets as item}
|
||||||
<div class="wrapper" class:selected={item.name == selectedWidget} on:click={e => (selectedWidget = item.name)}>
|
<div class="wrapper" class:selected={item.name == $selectedWidget} on:click={() => handleChangeWidget(item.name)}>
|
||||||
<FontIcon icon={item.icon} />
|
<FontIcon icon={item.icon} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user