[react] feat: Added docs for components/Uuid
This commit is contained in:
parent
b50228e0f9
commit
d8705ecc75
4 changed files with 39 additions and 13 deletions
|
@ -1,25 +1,29 @@
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { shortUuid } from '@freesewing/utils'
|
import { shortUuid } from '@freesewing/utils'
|
||||||
import { Link } from '@freesewing/react/components/Link'
|
import { Link as WebLink } from '@freesewing/react/components/Link'
|
||||||
import { CopyToClipboardButton } from '@freesewing/react/components/Button'
|
import { CopyToClipboardButton } from '@freesewing/react/components/Button'
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Displays a UUID, but shorter
|
* A component to display a short version of a (v4) UUID
|
||||||
*
|
*
|
||||||
* @param {object} props - All React props
|
* @component
|
||||||
* @param {string} uuid - The UUID
|
* @param {object} props - All component props
|
||||||
* @param {string} href - An optional href to make this UUID a link
|
* @param {React.FC} [props.Link = false] - An optional framework-specific Link component
|
||||||
* @param {string} label - An optional label to show in the loading status
|
* @param {string} props.uuid - The UUID
|
||||||
|
* @param {string} [props.href = false] - An optional href to make this into a link
|
||||||
|
* @param {string} [props.label = false] - An optional label to pass to the CopyToClipboardButton
|
||||||
|
* @returns {JSX.Element}
|
||||||
*/
|
*/
|
||||||
export const Uuid = ({ uuid, href = false, label = false }) => {
|
export const Uuid = ({ uuid, href = false, label = "UUID", Link = false }) => {
|
||||||
const [full, setFull] = useState()
|
const [full, setFull] = useState()
|
||||||
const short = shortUuid(uuid)
|
const short = shortUuid(uuid)
|
||||||
|
if (!Link) Link = WebLink
|
||||||
|
|
||||||
if (href === false)
|
if (href === false)
|
||||||
return (
|
return (
|
||||||
<span className="flex flex-row items-center">
|
<span className="flex flex-row items-center">
|
||||||
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
|
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
|
||||||
<CopyToClipboardButton content={uuid} label="UUID" sup />
|
<CopyToClipboardButton content={uuid} label={label} sup />
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +32,7 @@ export const Uuid = ({ uuid, href = false, label = false }) => {
|
||||||
<Link href={href} title={uuid}>
|
<Link href={href} title={uuid}>
|
||||||
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
|
<span className="daisy-badge daisy-badge-secondary font-mono">{shortUuid(uuid)}</span>
|
||||||
</Link>
|
</Link>
|
||||||
<CopyToClipboardButton content={uuid} label="UUID" sup label />
|
<CopyToClipboardButton content={uuid} label={label} sup />
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,3 +39,4 @@ jsdoc -c jsdoc.json components/Stats/* > ../../sites/dev/prebuild/jsdoc/react/co
|
||||||
jsdoc -c jsdoc.json components/Tab/* > ../../sites/dev/prebuild/jsdoc/react/components/tab.json
|
jsdoc -c jsdoc.json components/Tab/* > ../../sites/dev/prebuild/jsdoc/react/components/tab.json
|
||||||
jsdoc -c jsdoc.json components/Table/* > ../../sites/dev/prebuild/jsdoc/react/components/table.json
|
jsdoc -c jsdoc.json components/Table/* > ../../sites/dev/prebuild/jsdoc/react/components/table.json
|
||||||
jsdoc -c jsdoc.json components/Time/* > ../../sites/dev/prebuild/jsdoc/react/components/time.json
|
jsdoc -c jsdoc.json components/Time/* > ../../sites/dev/prebuild/jsdoc/react/components/time.json
|
||||||
|
jsdoc -c jsdoc.json components/Uuid/* > ../../sites/dev/prebuild/jsdoc/react/components/uuid.json
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { Uuid } from '@freesewing/react/components/Uuid'
|
||||||
|
|
||||||
|
export const UuidExample = () => <Uuid uuid="08bf6a94-6dfb-4921-b359-3b5f1bc51349" label="UUID with custom label" />
|
|
@ -2,6 +2,23 @@
|
||||||
title: Uuid
|
title: Uuid
|
||||||
---
|
---
|
||||||
|
|
||||||
:::note
|
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
||||||
This page is yet to be created
|
import { ComponentDocs } from '@site/src/components/component-docs.js'
|
||||||
:::
|
import * as jsdoc from '@site/prebuild/jsdoc/components.uuid.mjs'
|
||||||
|
import { UuidExample } from './_examples.js'
|
||||||
|
|
||||||
|
<DocusaurusDoc>
|
||||||
|
|
||||||
|
- [Components](#components)
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
The **Uuid** component family provides the following components:
|
||||||
|
|
||||||
|
- [Uuid](#uuid)
|
||||||
|
|
||||||
|
### Uuid
|
||||||
|
|
||||||
|
<ComponentDocs docs={jsdoc.jsdocUuid} example={UuidExample} />
|
||||||
|
|
||||||
|
</DocusaurusDoc>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue