1
0
Fork 0
freesewing/packages/react/components/Uuid/index.mjs
Joost De Cock 51dc1d9732
[breaking]: FreeSewing v4 (#7297)
Refer to the CHANGELOG for all info.

---------

Co-authored-by: Wouter van Wageningen <wouter.vdub@yahoo.com>
Co-authored-by: Josh Munic <jpmunic@gmail.com>
Co-authored-by: Jonathan Haas <haasjona@gmail.com>
2025-04-01 16:15:20 +02:00

34 lines
1.2 KiB
JavaScript

import React, { useState } from 'react'
import { shortUuid } from '@freesewing/utils'
import { Link } from '@freesewing/react/components/Link'
import { CopyToClipboardButton } from '@freesewing/react/components/CopyToClipboardButton'
/*
* Displays a UUID, but shorter
*
* @param {object} props - All React props
* @param {string} uuid - The UUID
* @param {string} href - An optional href to make this UUID a link
* @param {string} label - An optional label to show in the loading status
*/
export const Uuid = ({ uuid, href = false, label = false }) => {
const [full, setFull] = useState()
const short = shortUuid(uuid)
if (href === false)
return (
<span className="flex flex-row items-center">
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
<CopyToClipboard content={uuid} label="UUID" sup />
</span>
)
return (
<span className="flex flex-row items-center">
<Link href={href} title={uuid}>
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
</Link>
<CopyToClipboard content={uuid} label="UUID" sup label />
</span>
)
}