@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
9 lines (8 loc) • 743 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { HiClipboardCopy } from 'react-icons/hi';
import { useState } from 'react';
const HoverableValue = ({ value, truncatedValue }) => {
const [isHovered, setIsHovered] = useState(false);
return (_jsxs("button", { "aria-label": "Copy to clipboard", className: "relative flex cursor-pointer items-center", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onClick: () => navigator.clipboard.writeText(value), children: [_jsx("span", { title: value, children: truncatedValue }), isHovered && _jsx(HiClipboardCopy, { className: "ml-2 text-gray-500 hover:text-gray-800", title: "Copy to clipboard" })] }));
};
export default HoverableValue;