Skip to content

Commit

Permalink
feat(developer): add copy to clipboard to keys table and key page
Browse files Browse the repository at this point in the history
Closes #276
  • Loading branch information
stdavis committed May 16, 2024
1 parent 4a5570a commit 04dbf92
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/developer/src/components/CopyToClipboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default function CopyToClipboard({ text, className }) {
<CopyToClipboard_lib
text={text}
className={twMerge(
className,
'h-8 cursor-pointer hover:text-wavy-400 dark:hover:text-mustard-500',
className,
)}
onCopy={() => setCopied(true)}
>
Expand Down
4 changes: 3 additions & 1 deletion src/developer/src/components/page/Key.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useRef } from 'react';
import { useLoaderData, useNavigate, useParams } from 'react-router-dom';
import { useFirestore, useFunctions } from 'reactfire';
import { timeSince } from '../../../functions/time';
import CopyToClipboard from '../CopyToClipboard';
import EditableText from '../EditableText';
import Button, { RouterButtonLink } from '../design-system/Button';
import Card from '../design-system/Card';
Expand Down Expand Up @@ -200,9 +201,10 @@ export const Component = () => {
<div>
<h2
id="key-creation"
className="uppercase text-wavy-600 dark:text-wavy-200"
className="flex items-center uppercase text-wavy-600 dark:text-wavy-200"
>
{key}
<CopyToClipboard text={key} className="ml-1 inline" />
</h2>
<p className="text-wavy-400">
{status === 'pending' ? 'fetching metadata...' : data?.pattern}
Expand Down
21 changes: 6 additions & 15 deletions src/developer/src/components/page/Keys.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { InformationCircleIcon } from '@heroicons/react/20/solid';
import { useQuery } from '@tanstack/react-query';
import { createColumnHelper } from '@tanstack/react-table';
import { httpsCallable } from 'firebase/functions';
import { Link, useLoaderData } from 'react-router-dom';
import { useFunctions } from 'reactfire';
import CopyToClipboard from '../CopyToClipboard';
import Button, { RouterButtonLink } from '../design-system/Button';
import Spinner from '../design-system/Spinner';
import Table from '../design-system/Table';
Expand Down Expand Up @@ -54,20 +54,11 @@ const columns = [
// }),
columnHelper.accessor('action', {
header: null,
cell: (info) => {
return (
<div className="flex justify-end">
<InformationCircleIcon
className="h-6 cursor-pointer text-fuchsia-600 hover:text-fuchsia-900"
onClick={(event) => {
event.stopPropagation();

console.log(info.row.getValue('key'));
}}
/>
</div>
);
},
cell: (info) => (
<div className="flex justify-end">
<CopyToClipboard text={info.row.getValue('key')} className="h-6" />
</div>
),
}),
];

Expand Down

0 comments on commit 04dbf92

Please sign in to comment.