-
Notifications
You must be signed in to change notification settings - Fork 1
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
KLO-227 : Copy button is not giving feedback of copying. #146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { CopySimple, Question } from '@jengaicons/react'; | ||
import { CopySimple, Question, Check } from '@jengaicons/react'; | ||
import { ReactNode, useState } from 'react'; | ||
import { ProdLogo } from '~/components/branding/prod-logo'; | ||
import { WorkspacesLogo } from '~/components/branding/workspace-logo'; | ||
|
@@ -82,25 +82,27 @@ export const CopyButton = ({ | |
title: ReactNode; | ||
value: string; | ||
}) => { | ||
const [_, setCopyIcon] = useState(<CopySimple />); | ||
// const [_, setCopyIcon] = useState(<CopySimple />); | ||
const [copied, setCopied] = useState(false); | ||
const { copy } = useClipboard({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): The introduction of the |
||
onSuccess: () => { | ||
setTimeout(() => { | ||
setCopyIcon(<CopySimple />); | ||
setCopied(false); | ||
}, 1000); | ||
}, | ||
}); | ||
|
||
return ( | ||
<div | ||
onClick={() => { | ||
setCopied(true); | ||
copy(value); | ||
}} | ||
className="flex flex-row gap-md items-center select-none group cursor-pointer" | ||
> | ||
<span>{title}</span> | ||
<span className="invisible group-hover:visible"> | ||
<CopySimple size={10} /> | ||
{copied ? <Check size={12} /> : <CopySimple size={12} />} | ||
</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): The change in icon size from the default to 12 for both |
||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Copy, Trash } from '@jengaicons/react'; | ||
import { Copy, Trash, Check } from '@jengaicons/react'; | ||
import { Link, useParams } from '@remix-run/react'; | ||
import { useState } from 'react'; | ||
import { toast } from '~/components/molecule/toast'; | ||
|
@@ -58,12 +58,20 @@ const ExtraButton = ({ onDelete }: { onDelete: () => void }) => { | |
|
||
const RepoUrlView = ({ name }: { name: string }) => { | ||
const { account } = useParams(); | ||
const { copy } = useClipboard({ | ||
onSuccess() { | ||
toast.success('Registry url copied successfully.'); | ||
}, | ||
}); | ||
const { copy } = useClipboard({}); | ||
const url = `${registryHost}/${account}/${name}`; | ||
const [copied, setCopied] = useState(false); | ||
|
||
const handleCopy = () => { | ||
copy(url); | ||
setCopied(true); | ||
toast.success('Registry url copied successfully.'); | ||
|
||
setTimeout(() => { | ||
setCopied(false); | ||
}, 3000); | ||
}; | ||
|
||
Comment on lines
+65
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): The |
||
return ( | ||
<ListBody | ||
data={ | ||
|
@@ -72,14 +80,22 @@ const RepoUrlView = ({ name }: { name: string }) => { | |
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
copy(url); | ||
if (!copied) { | ||
handleCopy(); | ||
} | ||
}} | ||
Comment on lines
+83
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code_refinement): The conditional check |
||
title={url} | ||
> | ||
<span className="truncate">{url}</span> | ||
<span> | ||
<Copy size={16} /> | ||
</span> | ||
{copied ? ( | ||
<span> | ||
<Check size={16} /> | ||
</span> | ||
) : ( | ||
<span> | ||
<Copy size={16} /> | ||
</span> | ||
)} | ||
</div> | ||
} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (code_refinement): Commenting out the previous state declaration without removing it indicates a transition phase or an uncertainty about the removal. If the
copied
state fully replaces the need forsetCopyIcon
, it's cleaner to remove the commented-out code to avoid confusion and maintain code cleanliness.