feat [org]: Wrote Editor docs
This commit is contained in:
parent
3d01c0136c
commit
0c1d886e94
53 changed files with 1054 additions and 496 deletions
|
@ -3,7 +3,7 @@ import { copyToClipboard } from '@freesewing/utils'
|
|||
import { CopyIcon, OkIcon } from '@freesewing/react/components/Icon'
|
||||
import { LoadingStatusContext } from '@freesewing/react/context/LoadingStatus'
|
||||
|
||||
const handleCopied = (content, setCopied, setLoadingStatus, label) => {
|
||||
const handleCopied = (content, setCopied, setLoadingStatus, label, handler=false) => {
|
||||
copyToClipboard(content)
|
||||
setCopied(true)
|
||||
setLoadingStatus([
|
||||
|
@ -13,6 +13,7 @@ const handleCopied = (content, setCopied, setLoadingStatus, label) => {
|
|||
true,
|
||||
])
|
||||
setTimeout(() => setCopied(false), 1000)
|
||||
if (typeof handler === 'function') handler(content, label)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,12 +22,14 @@ const handleCopied = (content, setCopied, setLoadingStatus, label) => {
|
|||
* @component
|
||||
* @param {object} props - All component props
|
||||
* @param {JSX.element} props.children - The component children
|
||||
* @param {string} [props.btnClasses = 'tw:daisy-btn tw:daisy-btn-ghost tw:hover:border-transparent w:hover:border-transparent tw:hover:shadow-none'] - The content that should be copied to the clipboard
|
||||
* @param {string} props.content - The content that should be copied to the clipboard
|
||||
* @param {string} props.label - The label to show when the content is copied
|
||||
* @param {function} [props.onCopy=false] - An optional handler to call after copying to the clipboard, receives content, label as parameters
|
||||
* @param {boolean} props.sup - Set this to true to render as superscript (above the line)
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
export const CopyToClipboardButton = ({ children, content, label = false, sup = false }) => {
|
||||
export const CopyToClipboardButton = ({ children, content, label = false, sup = false, btnClasses="tw:daisy-btn tw:daisy-btn-ghost tw:hover:border-transparent w:hover:border-transparent tw:hover:shadow-none", onCopy=false }) => {
|
||||
const [copied, setCopied] = useState(false)
|
||||
const { setLoadingStatus } = useContext(LoadingStatusContext)
|
||||
|
||||
|
@ -36,9 +39,10 @@ export const CopyToClipboardButton = ({ children, content, label = false, sup =
|
|||
<button
|
||||
className={
|
||||
(copied ? 'tw:text-success ' : '') +
|
||||
'tw:daisy-btn tw:w-full tw:daisy-btn-ghost tw:lg:w-auto tw:hover:bg-transparent tw:hover:border-transparent tw:group tw:hover:shadow-none'
|
||||
btnClasses +
|
||||
' tw:w-full tw:lg:w-auto tw:group tw:flex tw:flex-row tw:justify-between'
|
||||
}
|
||||
onClick={() => handleCopied(content, setCopied, setLoadingStatus, label)}
|
||||
onClick={() => handleCopied(content, setCopied, setLoadingStatus, label, onCopy)}
|
||||
>
|
||||
{sup ? children : null}
|
||||
{copied ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue