status bar
This commit is contained in:
@@ -1,77 +1,65 @@
|
||||
<script lang="ts">
|
||||
import Movable from '#lib/modules/Movable.svelte';
|
||||
import type { MWinParams } from '#lib/mwinlib/mwin_util.ts';
|
||||
import { createRawSnippet, mount, unmount } from 'svelte';
|
||||
import Input from '#lib/modules/Input.svelte';
|
||||
import StatusBar from '#lib/modules/StatusBar.svelte';
|
||||
|
||||
const mwinoptions: Partial<MWinParams> = {
|
||||
resizable: { threshold: 10, minWidth: 300, minHeight: 200 }
|
||||
};
|
||||
let value = $state('');
|
||||
let input: Input | undefined = $state();
|
||||
|
||||
let wrapper: HTMLElement;
|
||||
let count: number = $state(-1);
|
||||
const movables = new Map<number, ReturnType<typeof mount>>();
|
||||
let date = $state(new Date());
|
||||
|
||||
createRawSnippet(() => {
|
||||
return {
|
||||
render: () =>
|
||||
`<div class="size-full bg-[${Math.floor(Math.random() * 16777215).toString(16)}]"></div>`
|
||||
};
|
||||
$effect(() => {
|
||||
setInterval(() => {
|
||||
date = new Date();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
function remove(id: number) {
|
||||
const m = movables.get(id);
|
||||
if (!m) return;
|
||||
unmount(m);
|
||||
movables.delete(id);
|
||||
}
|
||||
|
||||
function add() {
|
||||
count++;
|
||||
const id = count;
|
||||
const child = createRawSnippet(() => {
|
||||
return {
|
||||
render: () =>
|
||||
`<div class="size-full" style="background-color: #${Math.floor(Math.random() * 16777215).toString(16)}">
|
||||
<button class="bg-emerald-700" type="button" data-remove-btn>Bye</button>
|
||||
</div>`
|
||||
};
|
||||
});
|
||||
|
||||
const movable = mount(Movable, {
|
||||
target: wrapper,
|
||||
props: {
|
||||
class: 'size-100',
|
||||
id: 'movable-' + id.toString(),
|
||||
'data-movable-id': String(id),
|
||||
wrapper,
|
||||
mwinoptions: { ...mwinoptions, handle: '#movable-' + id.toString() },
|
||||
children: child
|
||||
}
|
||||
});
|
||||
|
||||
movables.set(id, movable);
|
||||
|
||||
const btn = wrapper.querySelector<HTMLButtonElement>(`#movable-${id} [data-remove-btn]`);
|
||||
|
||||
if (btn) {
|
||||
// Prevent the drag from starting when clicking the button.
|
||||
btn.addEventListener('mousedown', (e) => e.stopPropagation());
|
||||
btn.addEventListener('pointerdown', (e) => e.stopPropagation());
|
||||
// Direct call — no bubbling required.
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
remove(id);
|
||||
});
|
||||
} else {
|
||||
console.warn('remove button not found for movable', id);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={() => add()} class="bg-[#c08f58]">Add component</button>
|
||||
<div class="h-dvh w-full p-4">
|
||||
<div class=" bg-pattern flex h-full flex-col rounded-md">
|
||||
<div class="relative flex flex-1"></div>
|
||||
<div class="bg-bg-soft border-bg3 w-full rounded-b-md border-t text-xs">
|
||||
<StatusBar
|
||||
username="gornodox"
|
||||
theme="gruvbox"
|
||||
windowCount="no"
|
||||
version="v0.0.1_alpha"
|
||||
hash="a3d5b1c"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
bind:this={wrapper}
|
||||
id="mwin-wrapper"
|
||||
class=" relative flex h-screen w-full flex-col items-center justify-center"
|
||||
></div>
|
||||
<!-- <div class="h-dvh w-full p-4">
|
||||
<div class="bg-bg-soft border-border text-glow size-full rounded-xl font-mono tracking-widest">
|
||||
<div class=" border-border grid grid-cols-[1fr_auto_1fr] rounded-t-xl border-b px-2 py-1.5">
|
||||
<div></div>
|
||||
<div class="text-fg text-[10px] uppercase">
|
||||
<span class="">gornodox@termos</span>
|
||||
<span class=" normal-case"> — ~/Downloads</span>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div
|
||||
class=" bg-bg border-border fixed bottom-full grid grid-cols-[1fr_auto_1fr] rounded-b-xl border-b px-2 py-1.5"
|
||||
>
|
||||
<div></div>
|
||||
<div class="text-fg text-[10px] uppercase">
|
||||
<span class="">gornodox@termos</span>
|
||||
<span class=" normal-case"> — ~/Downloads</span>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div
|
||||
onclick={() => input?.focusInput()}
|
||||
onkeydown={() => input?.focusInput()}
|
||||
role="textbox"
|
||||
tabindex="-1"
|
||||
class=" bg-bg-base scroll-hidden text-glow relative h-screen w-full overflow-y-auto p-4 text-sm"
|
||||
>
|
||||
<Input bind:value blinkDelay={500} bind:this={input} />
|
||||
</div>
|
||||
<div class="bg-bg fixed bottom-0 flex w-full flex-row px-3">
|
||||
<p class="text-md">Uptime: 09:10:01</p>
|
||||
</div> -->
|
||||
|
||||
Reference in New Issue
Block a user