UNPKG

@mantine/code-highlight

Version:

Code highlight with Mantine theme

28 lines (25 loc) 862 B
'use client'; import { jsx } from 'react/jsx-runtime'; import { useClipboard } from '@mantine/hooks'; import { CodeHighlightControl } from '../CodeHighlightControl/CodeHighlightControl.mjs'; import { CopyIcon } from './CopyIcon.mjs'; function CopyCodeButton({ code, copyLabel = "Copy", copiedLabel = "Copied" }) { const clipboard = useClipboard(); return /* @__PURE__ */ jsx( CodeHighlightControl, { onClick: () => clipboard.copy(code.trim()), variant: "none", tooltipLabel: clipboard.copied ? copiedLabel : copyLabel, "aria-label": clipboard.copied ? copiedLabel : `${copyLabel} code`, children: /* @__PURE__ */ jsx(CopyIcon, { copied: clipboard.copied }) } ); } CopyCodeButton.displayName = "@mantine/code-highlight/CopyCodeButton"; export { CopyCodeButton }; //# sourceMappingURL=CopyCodeButton.mjs.map