Skip to content

Commit

Permalink
refactor: run yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
lucataglia committed Aug 23, 2023
1 parent 6e71a04 commit 2ccdf15
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
7 changes: 6 additions & 1 deletion packages/react-json-tree/examples/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ const App = () => (
Sort object keys with <code>sortObjectKeys</code> prop.
</p>
<div>
<JSONTree data={data} theme={theme} sortObjectKeys expandCollapseAll={{}}/>
<JSONTree
data={data}
theme={theme}
sortObjectKeys
expandCollapseAll={{}}
/>
</div>
<p>Collapsed root node</p>
<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-json-tree/src/JSONNestedNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default function JSONNestedNode(props: Props) {
itemType,
createItemString(data, collectionLimit),
keyPath,
expandedRef.current,
expandedRef.current
);
const stylingArgs = [
keyPath,
Expand Down
29 changes: 18 additions & 11 deletions packages/react-json-tree/src/expandCollapseButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,37 @@ function CollapseButton({
return <></>;
}

function CopyToClipboardButton({copyToClipboardIcon, copiedToClipboardIcon, value}:CopyToClipboardButtonProps) {
function CopyToClipboardButton({
copyToClipboardIcon,
copiedToClipboardIcon,
value,
}: CopyToClipboardButtonProps) {
const [isCopied, setIsCopied] = useState(false);

const handleOnCopyToClipboard = async () => {
await navigator.clipboard.writeText(JSON.stringify(value, null, 2));
setIsCopied(true)
}
setIsCopied(true);
};

useEffect(() => {
if(isCopied){
setTimeout(() => setIsCopied(false), 6000)
if (isCopied) {
setTimeout(() => setIsCopied(false), 6000);
}
}, [isCopied])
}, [isCopied]);

if(isCopied){
return (<div role="presentation" onClick={handleOnCopyToClipboard}>
{copiedToClipboardIcon || <FontAwesomeIcon icon={faCheck} />}
</div>);
if (isCopied) {
return (
<div role="presentation" onClick={handleOnCopyToClipboard}>
{copiedToClipboardIcon || <FontAwesomeIcon icon={faCheck} />}
</div>
);
}

return (
<div role="presentation" onClick={handleOnCopyToClipboard}>
{copyToClipboardIcon || <FontAwesomeIcon icon={faCopy} />}
</div>)
</div>
);
}

function DefaultButton({ defaultIcon }: DefaultButtonProps) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-json-tree/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type GetItemString = (
itemType: React.ReactNode,
itemString: string,
keyPath: KeyPath,
isExpanded: boolean,
isExpanded: boolean
) => React.ReactNode;

export type LabelRenderer = (
Expand Down

0 comments on commit 2ccdf15

Please sign in to comment.