anbeime/skill / skills/hairline/hairline
hairline
Flagged一句话生成跟随鼠标的交互式等轴测线框图(单文件、零依赖、双击即开),或把已有 SVG/Logo 重建为可交互线框。
apps/site/components/example-frame.tsx
View on GitHub"use client";
import { useEffect, useRef } from "react";
/** The bench's `body` padding, 24px above and 24px below the page's one column: every page the skill writes has it. */
const PAD = 48;
/** Set inside the frame: the plate's two corner tags (the figure's name and its read-out) and the rules line under it. */
const QUIET = "hl-site-quiet";
const HIDDEN = "#name, #read, #rules { display: none !important; }";
/**
* Hands an Escape pressed inside a frame's document on to the frame element,
* where it bubbles to the site's document: a key pressed in the frame never
* reaches it otherwise, so the drawer would not close. Returns its remover.
*/
export function forwardEscape(el: HTMLIFrameElement, doc: Document): () => void {
const onKey = (event: KeyboardEvent) => {
if (event.key === "Escape") el.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
};
doc.addEventListener("keydown", onKey);
return () => doc.removeEventListener("keydown", onKey);
}
/**
* A page the skill wrote, in a frame as tall as that page: the frame never
* scrolls inside. Its height is reserved in CSS before it loads, then fitted
* to the page's column and kept fitted as the column's text wraps. The pages
* are served from the site's own origin; were they not, `contentDocument`
* would be null and the frame would keep its CSS height.
*
* Here an example shows only the figure, its controls and what it means: the
* name tag, the read-out and the rules line are hidden from the site's side,
* by one style added to the frame's document before it is measured, because
* the page itself stays exactly as the skill wrote it. Its error line is left
* alone, so a figure that throws still says so.
*/
export function ExampleFrame({ src, title }: { src: string; title: string }) {
const frame = useRef<HTMLIFrameElement>(null);
useEffect(() => {
const el = frame.current;
if (!el) return;
let watch: ResizeObserver | undefined;
let unkey: (() => void) | undefined;
const fit = () => {
const view = el.contentWindow as (Window & typeof globalThis) | null;
const doc = el.contentDocument;
const main = doc?.querySelector("main");
if (!view || !doc || !main) return;
// once a document: the style and the Escape go in together
if (!doc.getElementById(QUIET)) {
const style = doc.createElement("style");
style.id = QUIET;
style.textContent = HIDDEN;
doc.head.append(style);
unkey?.();
unkey = forwardEscape(el, doc);
}
const size = () => { el.style.height = `${Math.ceil(main.getBoundingClientRect().height) + PAD}px`; };
size();
watch?.disconnect();
// the frame's own observer: its column is in the frame's document
watch = new view.ResizeObserver(size);
watch.observe(main);
};
fit();
el.addEventListener("load", fit);
return () => {
el.removeEventListener("load", fit);
watch?.disconnect();
unkey?.();
};
}, []);
return <iframe ref={frame} className="example-frame" src={src} title={title} loading="lazy" />;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |