~james/core

core/web/src/lib/components/repo/FilePathChip.svelte -rw-r--r-- 742 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<script lang="ts">
	import type { Snippet } from "svelte";

	let { children }: { children: Snippet } = $props();

	// a path too long to fit scrolls to its end, where the current entry is. the
	// width settles only once fonts load and the header finishes wrapping
	const showEnd = (el: HTMLElement) => {
		const end = () => {
			el.scrollLeft = el.scrollWidth;
		};
		void document.fonts.ready.then(end);
		const observer = new ResizeObserver(end);
		observer.observe(el);
		return () => observer.disconnect();
	};
</script>

<div
	class="flex w-fit min-w-0 items-center gap-2xs overflow-x-auto rounded-md border border-background-canvas bg-background-canvas px-sm py-2xs whitespace-nowrap"
	{@attach showEnd}
>
	{@render children()}
</div>