Moved to a new clean project on pnpm

This commit is contained in:
2026-11-01 10:48:45 +01:00
commit 219b705b96
33 changed files with 5668 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
<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';
const mwinoptions: Partial<MWinParams> = {
resizable: { threshold: 10, minWidth: 300, minHeight: 200 }
};
let wrapper: HTMLElement;
let count: number = $state(-1);
const movables = new Map<number, ReturnType<typeof mount>>();
createRawSnippet(() => {
return {
render: () =>
`<div class="size-full bg-[${Math.floor(Math.random() * 16777215).toString(16)}]"></div>`
};
});
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
bind:this={wrapper}
id="mwin-wrapper"
class=" relative flex h-screen w-full flex-col items-center justify-center"
></div>