Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #285 #681

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"prism-react-renderer": "^2.3.0",
"qs": "^6.11.2",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a corresponding change in pnpm-lock.yaml, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure I will update the lock file aswell

"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2",
"react-icons": "^5.0.1",
Expand All @@ -86,6 +87,7 @@
"@types/node": "^20.10.1",
"@types/qs": "^6.9.10",
"@types/react": "^18.2.37",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.2.15",
"@types/react-syntax-highlighter": "^15.5.11",
"@typescript-eslint/eslint-plugin": "^6.10.0",
Expand Down
36 changes: 36 additions & 0 deletions frontend/app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 21 additions & 17 deletions frontend/app/src/components/ui/copy-to-clipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { Button } from './button';
import { CopyIcon } from '@radix-ui/react-icons';
import { CheckIcon } from '@heroicons/react/24/outline';
import { CopyToClipboard as Copy } from 'react-copy-to-clipboard';
import { cn } from '@/lib/utils';

type Props = {
Expand All @@ -14,30 +15,33 @@ const CopyToClipboard: React.FC<Props> = ({ text, className, withText }) => {
const [successCopy, setSuccessCopy] = useState(false);

return (
<Button
className={cn(
className,
withText
? 'cursor-pointer flex flex-row gap-2 items-center mt-2'
: 'w-6 h-6 p-0 cursor-pointer',
)}
variant={withText ? 'default' : 'ghost'}
onClick={() => {
navigator.clipboard.writeText(text);
<Copy
text={text}
onCopy={() => {
setSuccessCopy(true);

setTimeout(() => {
setSuccessCopy(false);
}, 2000);
}}
>
{successCopy ? (
<CheckIcon className="w-4 h-4" />
) : (
<CopyIcon className="w-4 h-4" />
)}
{withText && (successCopy ? 'Copied' : 'Copy to clipboard')}
</Button>
<Button
className={cn(
className,
withText
? 'cursor-pointer flex flex-row gap-2 items-center mt-2'
: 'w-6 h-6 p-0 cursor-pointer',
)}
variant={withText ? 'default' : 'ghost'}
>
{successCopy ? (
<CheckIcon className="w-4 h-4" />
) : (
<CopyIcon className="w-4 h-4" />
)}
{withText && (successCopy ? 'Copied' : 'Copy to clipboard')}
</Button>
</Copy>
);
};

Expand Down
Loading