1
0
Fork 0

wip: Work on apikeys

This commit is contained in:
joostdecock 2024-12-23 10:54:13 +01:00
parent 196bf6decf
commit 1e01442b9e
8 changed files with 236 additions and 3 deletions

View file

@ -20,20 +20,25 @@ const handleCopied = (setCopied, setLoadingStatus, label) => {
setTimeout(() => setCopied(false), 1000)
}
export const CopyToClipboard = ({ content, label = false }) => {
export const CopyToClipboard = ({ content, label = false, sup = false }) => {
const [copied, setCopied] = useState(false)
const { setLoadingStatus } = useContext(LoadingStatusContext)
const text =
typeof content === 'string' ? content : strip(ReactDOMServer.renderToStaticMarkup(content))
const style = sup ? 'w-4 h-4 -mt-4' : 'w-5 h-5'
return (
<Copy text={text} onCopy={() => handleCopied(setCopied, setLoadingStatus, label)}>
<button className={copied ? 'text-success' : ''}>
{copied ? (
<OkIcon className="w-5 h-5 text-success-content bg-success rounded-full p-1" stroke={4} />
<OkIcon
className={`${style} text-success-content bg-success rounded-full p-1`}
stroke={4}
/>
) : (
<CopyIcon className="w-5 h-5 text-inherit" />
<CopyIcon className={`${style} text-inherit`} />
)}
</button>
</Copy>