mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
- Replace root `eslint-plugin-lingui` jsPlugin with `@e18e/eslint-plugin`; move lingui rules into per-app `.oxlintrc.json` overrides for native and web
- Add `jsx-a11y`, `react-hooks-js` (native), and expanded lingui rule sets to per-app configs
- Add `oxc/no-barrel-file` warning at threshold 0 to root config
- Fix `e18e/prefer-url-canparse`: replace `try { new URL() } catch` with `URL.canParse()` in server-url screen and server lib
- Fix `e18e/prefer-timer-args`: pass callback args directly to `setTimeout` instead of wrapping in arrow functions (use-debounce, integration-card)
- Fix `e18e/prefer-static-regex`: hoist `/\/+$/` to module-level constant in server-url screen
- Fix `react-hooks-js/refs` and `react-hooks-js/set-state-in-effect`: convert `useRef` tracking patterns to `useState` + render-time derived updates in `use-server-connection`, `expandable-text`, and settings screen
- Fix `react-hooks-js/immutability`: extract stable palette sub-values before `useMemo` deps in title detail screen
- Apply `e18e` and other rule fixes across core, tmdb, web components, and i18n packages
37 lines
879 B
TypeScript
37 lines
879 B
TypeScript
import { Trans } from "@lingui/react/macro";
|
|
import { IconCheck, IconCopy } from "@tabler/icons-react";
|
|
import { useState } from "react";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
export function CopyButton({ code }: { code: string }) {
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
function handleCopy() {
|
|
navigator.clipboard.writeText(code);
|
|
setCopied(true);
|
|
setTimeout(setCopied, 2000, false);
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={handleCopy}
|
|
className="text-muted-foreground text-[11px]"
|
|
>
|
|
{copied ? (
|
|
<>
|
|
<IconCheck aria-hidden={true} className="size-3 text-green-400" />
|
|
<Trans>Copied</Trans>
|
|
</>
|
|
) : (
|
|
<>
|
|
<IconCopy aria-hidden={true} className="size-3" />
|
|
<Trans>Copy</Trans>
|
|
</>
|
|
)}
|
|
</Button>
|
|
);
|
|
}
|