Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 259fdf2

Browse files
feat: copy badge feature (#175) (#224)
* feat: copy badge feature (#175) * feat: added copy feature * Switched to asyc * Removed the console log * Format fix * Updated input * format * Uses classnames * Update src/components/forms/Input.js * Update src/app/account/repo/checks/[id]/form.js Co-authored-by: Eddie Jaoude <[email protected]> * Update src/app/account/repo/checks/[id]/form.js Co-authored-by: Eddie Jaoude <[email protected]> * patch: class names * patch: format * Update src/app/account/repo/checks/[id]/form.js Co-authored-by: Eddie Jaoude <[email protected]> * Update src/app/account/repo/checks/[id]/form.js --------- Co-authored-by: Eddie Jaoude <[email protected]> * fix: simplified copy * fix: badge form label * fix: revert input component --------- Co-authored-by: Adam Basha <[email protected]>
1 parent 0909e2b commit 259fdf2

File tree

1 file changed

+21
-5
lines changed
  • src/app/account/repo/checks/[id]

1 file changed

+21
-5
lines changed

src/app/account/repo/checks/[id]/form.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {
44
DocumentDuplicateIcon,
55
CheckBadgeIcon,
66
} from "@heroicons/react/20/solid";
7+
import { useState } from "react";
78

89
import { performChecks } from "./action";
910
import Input from "@/components/forms/Input";
1011
import { SubmitButton } from "@/components/forms/SubmitButton";
12+
import classNames from "@/utils/classNames";
1113

1214
export default function Form({ id }) {
1315
return (
@@ -19,10 +21,16 @@ export default function Form({ id }) {
1921
}
2022

2123
export function FormBadge({ src }) {
24+
const [copy, setCopy] = useState(false);
25+
const copyHandle = async () => {
26+
const url = `![HealthCheck](${src})`;
27+
await navigator.clipboard.writeText(url);
28+
setCopy(true);
29+
};
2230
return (
2331
<div>
2432
<label
25-
htmlFor="email"
33+
htmlFor="badge"
2634
className="block text-sm font-medium leading-6 text-white"
2735
>
2836
Add badge to your Repo&lsquo;s README to show the latest check status
@@ -44,16 +52,24 @@ export function FormBadge({ src }) {
4452
className="block w-full rounded-md border-0 py-1.5 pl-10 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
4553
/>
4654
</div>
47-
{/* <button
55+
<button
4856
type="button"
4957
className="relative -ml-px inline-flex items-center gap-x-1.5 rounded-r-md px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
58+
onClick={copyHandle}
5059
>
5160
<DocumentDuplicateIcon
5261
aria-hidden="true"
53-
className="-ml-0.5 h-5 w-5 text-gray-400"
62+
className={classNames(
63+
"-ml-0.5 h-5 w-5 text-gray-400",
64+
copy && "text-green-400",
65+
)}
5466
/>
55-
Copy
56-
</button> */}
67+
{copy === true ? (
68+
<span className="text-green-400">Copied!</span>
69+
) : (
70+
<span className="text-gray-400">Copy</span>
71+
)}
72+
</button>
5773
</div>
5874
</div>
5975
);

0 commit comments

Comments
 (0)