import { createEffect, createSignal, type Accessor } from "solid-js"; export default function FitText(props: { body: Accessor }) { let textRef: SVGTextElement | undefined; const [viewBox, setViewbox] = createSignal() createEffect(async () => { props.body(); await Promise.resolve() const bounds = textRef?.getBBox(); if (bounds === undefined) { return; } setViewbox(`0 0 ${bounds.width} ${bounds.height}`) }); return ( {props.body()} ); }