refactor: run yarn format

This commit is contained in:
lucataglia 2023-08-23 11:42:39 +02:00
parent 6e71a04e8c
commit 2ccdf15bc9
4 changed files with 26 additions and 14 deletions

View File

@ -190,7 +190,12 @@ const App = () => (
Sort object keys with <code>sortObjectKeys</code> prop. Sort object keys with <code>sortObjectKeys</code> prop.
</p> </p>
<div> <div>
<JSONTree data={data} theme={theme} sortObjectKeys expandCollapseAll={{}}/> <JSONTree
data={data}
theme={theme}
sortObjectKeys
expandCollapseAll={{}}
/>
</div> </div>
<p>Collapsed root node</p> <p>Collapsed root node</p>
<div> <div>

View File

@ -177,7 +177,7 @@ export default function JSONNestedNode(props: Props) {
itemType, itemType,
createItemString(data, collectionLimit), createItemString(data, collectionLimit),
keyPath, keyPath,
expandedRef.current, expandedRef.current
); );
const stylingArgs = [ const stylingArgs = [
keyPath, keyPath,

View File

@ -123,30 +123,37 @@ function CollapseButton({
return <></>; return <></>;
} }
function CopyToClipboardButton({copyToClipboardIcon, copiedToClipboardIcon, value}:CopyToClipboardButtonProps) { function CopyToClipboardButton({
copyToClipboardIcon,
copiedToClipboardIcon,
value,
}: CopyToClipboardButtonProps) {
const [isCopied, setIsCopied] = useState(false); const [isCopied, setIsCopied] = useState(false);
const handleOnCopyToClipboard = async () => { const handleOnCopyToClipboard = async () => {
await navigator.clipboard.writeText(JSON.stringify(value, null, 2)); await navigator.clipboard.writeText(JSON.stringify(value, null, 2));
setIsCopied(true) setIsCopied(true);
} };
useEffect(() => { useEffect(() => {
if (isCopied) { if (isCopied) {
setTimeout(() => setIsCopied(false), 6000) setTimeout(() => setIsCopied(false), 6000);
} }
}, [isCopied]) }, [isCopied]);
if (isCopied) { if (isCopied) {
return (<div role="presentation" onClick={handleOnCopyToClipboard}> return (
<div role="presentation" onClick={handleOnCopyToClipboard}>
{copiedToClipboardIcon || <FontAwesomeIcon icon={faCheck} />} {copiedToClipboardIcon || <FontAwesomeIcon icon={faCheck} />}
</div>); </div>
);
} }
return ( return (
<div role="presentation" onClick={handleOnCopyToClipboard}> <div role="presentation" onClick={handleOnCopyToClipboard}>
{copyToClipboardIcon || <FontAwesomeIcon icon={faCopy} />} {copyToClipboardIcon || <FontAwesomeIcon icon={faCopy} />}
</div>) </div>
);
} }
function DefaultButton({ defaultIcon }: DefaultButtonProps) { function DefaultButton({ defaultIcon }: DefaultButtonProps) {

View File

@ -11,7 +11,7 @@ export type GetItemString = (
itemType: React.ReactNode, itemType: React.ReactNode,
itemString: string, itemString: string,
keyPath: KeyPath, keyPath: KeyPath,
isExpanded: boolean, isExpanded: boolean
) => React.ReactNode; ) => React.ReactNode;
export type LabelRenderer = ( export type LabelRenderer = (