@mantine/code-highlight
Version:
Code highlight with Mantine theme
21 lines (20 loc) • 925 B
JavaScript
"use client";
import { CodeHighlightControl } from "../CodeHighlightControl/CodeHighlightControl.mjs";
import { CopyIcon } from "./CopyIcon.mjs";
import { useClipboard } from "@mantine/hooks";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/code-highlight/src/CodeHighlight/CopyCodeButton/CopyCodeButton.tsx
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";
//#endregion
export { CopyCodeButton };
//# sourceMappingURL=CopyCodeButton.mjs.map