@@ -4,10 +4,12 @@ import {
44 DocumentDuplicateIcon ,
55 CheckBadgeIcon ,
66} from "@heroicons/react/20/solid" ;
7+ import { useState } from "react" ;
78
89import { performChecks } from "./action" ;
910import Input from "@/components/forms/Input" ;
1011import { SubmitButton } from "@/components/forms/SubmitButton" ;
12+ import classNames from "@/utils/classNames" ;
1113
1214export default function Form ( { id } ) {
1315 return (
@@ -19,10 +21,16 @@ export default function Form({ id }) {
1921}
2022
2123export function FormBadge ( { src } ) {
24+ const [ copy , setCopy ] = useState ( false ) ;
25+ const copyHandle = async ( ) => {
26+ const url = `` ;
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‘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