Cleaning the codebase a tiny bit

This commit is contained in:
2025-11-13 18:32:33 +01:00
parent 00fa9bff21
commit 7a0d89735a
6 changed files with 0 additions and 373 deletions

View File

@ -1,135 +0,0 @@
<script lang="ts">
import { onMount } from 'svelte';
interface Props {
title?: string;
visible?: boolean;
x?: number;
y?: number;
width?: number;
height?: number;
onClose?: () => void;
}
let {
title = 'Popup',
visible = $bindable(false),
x = 100,
y = 100,
width = 400,
height = 300,
onClose
}: Props = $props();
let isDragging = $state(false);
let dragStartX = $state(0);
let dragStartY = $state(0);
let popupX = $state(x);
let popupY = $state(y);
function handleMouseDown(e: MouseEvent) {
if ((e.target as HTMLElement).classList.contains('popup-header')) {
isDragging = true;
dragStartX = e.clientX - popupX;
dragStartY = e.clientY - popupY;
}
}
function handleMouseMove(e: MouseEvent) {
if (isDragging) {
popupX = e.clientX - dragStartX;
popupY = e.clientY - dragStartY;
}
}
function handleMouseUp() {
isDragging = false;
}
function handleClose() {
visible = false;
if (onClose) {
onClose();
}
}
onMount(() => {
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('mouseup', handleMouseUp);
return () => {
document.removeEventListener('mousemove', handleMouseMove);
document.removeEventListener('mouseup', handleMouseUp);
};
});
</script>
{#if visible}
<div
class="popup"
style="left: {popupX}px; top: {popupY}px; width: {width}px; height: {height}px;"
>
<div class="popup-header" onmousedown={handleMouseDown}>
<span class="popup-title">{title}</span>
<button class="close-button" onclick={handleClose}>×</button>
</div>
<div class="popup-content">
<slot />
</div>
</div>
{/if}
<style>
.popup {
position: fixed;
z-index: 9999;
background-color: var(--bg-color);
border: 1px solid var(--border-color);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
}
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: var(--space-md) var(--space-lg);
background-color: var(--surface-color);
border-bottom: 1px solid var(--border-color);
cursor: move;
user-select: none;
}
.popup-title {
font-weight: 600;
font-size: var(--font-base);
color: var(--text-color);
}
.close-button {
background: none;
border: none;
color: var(--text-secondary);
font-size: 1.5rem;
line-height: 1;
padding: 0;
cursor: pointer;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
transition: color var(--transition-base);
}
.close-button:hover {
color: var(--text-color);
}
.popup-content {
flex: 1;
overflow: auto;
padding: var(--space-lg);
}
</style>