SPB Git forge

spb/websensor

Public
33commits 1branches 0releases
3.4 MBsize
maindefault branch
10 days agolast push
TypeScript 55.4% Python 43.2% SQL 1.2%
945 B · 28 lines tsx
Raw Blame History
1"use client";23import { Check, Copy } from "lucide-react";4import { useState } from "react";56export function Code({ children, lang = "bash" }: { children: string; lang?: string }) {7  const [done, setDone] = useState(false);8  return (9    <div className="relative">10      <pre className="overflow-x-auto rounded-md border border-line bg-panel-2 p-3 pr-10 font-mono text-[12px] leading-5" data-lang={lang}>11        {children}12      </pre>13      <button14        type="button"15        aria-label="Copy"16        onClick={async () => {17          await navigator.clipboard.writeText(children).catch(() => undefined);18          setDone(true);19          setTimeout(() => setDone(false), 1200);20        }}21        className="absolute right-2 top-2 rounded border border-line bg-panel p-1 text-fg-subtle hover:text-fg"22      >23        {done ? <Check className="size-3.5 text-signal" /> : <Copy className="size-3.5" />}24      </button>25    </div>26  );27}28