anbeime/skill / skills/hairline/hairline
hairline
Flagged一句话生成跟随鼠标的交互式等轴测线框图(单文件、零依赖、双击即开),或把已有 SVG/Logo 重建为可交互线框。
apps/site/components/copy.tsx
View on GitHub"use client";
import { useCallback, useEffect, useState, type RefObject } from "react";
/**
* Copies text, and says so for a moment. Without clipboard permission, or on
* a page served without a secure context where there is no clipboard at all,
* it selects the text instead, so the keyboard can copy it. Resolves whether
* the text reached the clipboard.
*/
export function useCopy(): [copied: boolean, copy: (text: string, fallback?: Element | null) => Promise<boolean>] {
// counted, not flagged, so a copy made while the last one shows restarts its time
const [copies, setCopies] = useState(0);
useEffect(() => {
if (!copies) return;
const timer = setTimeout(() => setCopies(0), 1600);
return () => clearTimeout(timer);
}, [copies]);
const copy = useCallback(async (text: string, fallback?: Element | null) => {
try {
await navigator.clipboard.writeText(text);
setCopies((n) => n + 1);
return true;
} catch {
if (!fallback) return false;
const range = document.createRange();
range.selectNodeContents(fallback);
const selection = window.getSelection();
selection?.removeAllRanges();
selection?.addRange(range);
return false;
}
}, []);
return [copies > 0, copy];
}
/**
* Copy as an icon: the clipboard gives way to a check through scale, opacity
* and blur, and back. Both icons stay in the DOM so the swap is a transition
* either way, and interrupts cleanly on a second click.
*/
export function CopyIcon({ text, select, label = "Copy", className = "" }: { text: string | (() => string); select?: RefObject<Element | null>; label?: string; className?: string }) {
const [copied, copy] = useCopy();
return (
<button type="button" className={`icopy ${className}`} data-copied={copied || undefined} aria-label={label} title={label} onClick={() => copy(typeof text === "function" ? text() : text, select?.current)}>
<svg className="icopy-a" viewBox="0 0 16 16" width="15" height="15" aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinejoin="round">
<rect x="5.25" y="5.25" width="8.5" height="8.5" rx="2" />
<path d="M10.75 5.25V4.25a2 2 0 0 0-2-2h-4.5a2 2 0 0 0-2 2v4.5a2 2 0 0 0 2 2h1" />
</svg>
<svg className="icopy-b" viewBox="0 0 16 16" width="15" height="15" aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
<path d="M3.5 8.5l3 3 6-7" />
</svg>
<span className="sr-only" aria-live="polite">{copied ? "Copied" : ""}</span>
</button>
);
}
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 |