Initial RuneStone project

This commit is contained in:
Knotty Wyvern
2026-09-26 01:25:42 -07:00
commit bdc15e952d
190 changed files with 25986 additions and 0 deletions
+140
View File
@@ -0,0 +1,140 @@
<script lang="ts">
import { onDestroy } from "svelte";
import Icon from "./Icon.svelte";
export type IconName =
| "split"
| "more"
| "chevron-down"
| "maximize"
| "minimize"
| "window-maximize"
| "window-restore"
| "restore"
| "text"
| "folder-open"
| "file-plus"
| "folder-plus"
| "save"
| "pen"
| "code"
| "terminal"
| "eye"
| "panel-left"
| "panel-right"
| "spark"
| "list"
| "search"
| "bookmark"
| "files"
| "sort"
| "fold"
| "unfold"
| "book-open"
| "close"
| "trash"
| "plus";
type Props = {
icon: IconName;
label: string;
active?: boolean;
disabled?: boolean;
onclick?: () => void;
side?: "bottom" | "right";
type?: "button" | "submit";
};
let { icon, label, active, disabled = false, onclick, side = "bottom", type = "button" }: Props = $props();
const tooltipId = $props.id();
let button: HTMLButtonElement;
let tooltip: HTMLSpanElement;
let showTip = $state(false);
let timer: ReturnType<typeof setTimeout> | undefined;
function onLeave() {
clearTimeout(timer);
showTip = false;
if (tooltip?.matches(":popover-open")) tooltip.hidePopover();
}
function onEnter() {
clearTimeout(timer);
timer = setTimeout(() => {
if (!button?.isConnected || disabled) return;
const bounds = button.getBoundingClientRect();
tooltip.showPopover();
const tip = tooltip.getBoundingClientRect();
let left = side === "right" ? bounds.right + 8 : bounds.left + (bounds.width - tip.width) / 2;
let top = side === "right" ? bounds.top + (bounds.height - tip.height) / 2 : bounds.bottom + 8;
if (top + tip.height > innerHeight - 8) top = bounds.top - tip.height - 8;
left = Math.max(8, Math.min(left, innerWidth - tip.width - 8));
tooltip.style.left = `${left}px`;
tooltip.style.top = `${Math.max(8, top)}px`;
showTip = true;
}, 300);
}
onDestroy(() => clearTimeout(timer));
</script>
<svelte:window onresize={onLeave} onkeydown={(event) => { if (event.key === "Escape") onLeave(); }} />
<button
bind:this={button}
class="icon-btn"
class:active
{type}
{disabled}
aria-label={label}
aria-pressed={active}
aria-describedby={showTip ? tooltipId : undefined}
onclick={() => { onLeave(); onclick?.(); }}
onmouseenter={onEnter}
onmouseleave={onLeave}
onfocus={onEnter}
onblur={onLeave}
>
<Icon {icon} />
</button>
<span bind:this={tooltip} id={tooltipId} class="tip" popover="manual" role="tooltip">{label}</span>
<style>
.icon-btn {
position: relative;
width: 28px;
flex: 0 0 28px;
border-radius: var(--rs-control-radius);
height: 28px;
padding: 0;
border: 1px solid transparent;
background: transparent;
color: var(--rs-text-dim);
display: inline-flex;
align-items: center;
justify-content: center;
}
.icon-btn:hover,
.icon-btn.active {
background: var(--rs-bg-active);
border-color: var(--rs-border);
color: var(--rs-accent);
}
.tip {
position: fixed;
inset: auto;
margin: 0;
max-width: min(280px, calc(100vw - 16px));
white-space: pre-line;
text-align: left;
background: var(--rs-bg-active);
border: 1px solid var(--rs-border);
border-radius: 6px;
box-shadow: 0 4px 16px #0005;
color: var(--rs-text-strong);
padding: 6px 10px;
font: 12px/1.5 var(--rs-font-ui);
pointer-events: none;
}
</style>