@@ -10,6 +10,18 @@ scan({
1010 production : true ,
1111} ) ;
1212
13+ const copyToClipboard = ( text ) => {
14+ navigator . clipboard . writeText ( text ) . then ( ( ) => {
15+ const button = document . querySelector ( '.copy-button' ) ;
16+ if ( button ) {
17+ button . textContent = 'Copied!' ;
18+ setTimeout ( ( ) => {
19+ button . textContent = 'Copy' ;
20+ } , 2000 ) ;
21+ }
22+ } ) ;
23+ } ;
24+
1325export const App = ( ) => {
1426 const [ tasks , setTasks ] = useState ( [ ] ) ;
1527
@@ -50,7 +62,7 @@ export const App = () => {
5062
5163 < div className = "task-section" >
5264 < p > Try interacting with this input to see it in action:</ p >
53- < AddTask
65+ < AddTaskBar
5466 onCreate = { ( value ) => {
5567 if ( ! value ) return ;
5668 setTasks ( [ ...tasks , value ] ) ;
@@ -67,12 +79,18 @@ export const App = () => {
6779
6880 < div className = "sticky-footer" >
6981 < p > Get started by adding this script to your app:</ p >
70- < p >
82+ < div className = "code-container" >
7183 < code >
7284 <script
7385 src="https://unpkg.com/react-scan/dist/auto.global.js"></script>
7486 </ code >
75- </ p >
87+ < button
88+ className = "copy-button"
89+ onClick = { ( ) => copyToClipboard ( '<script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>' ) }
90+ >
91+ Copy
92+ </ button >
93+ </ div >
7694 < p >
7795 < small >
7896 < strong > Important:</ strong > Add this before any other scripts run!
@@ -128,7 +146,7 @@ export const Button = ({ onClick, children }) => {
128146 ) ;
129147} ;
130148
131- export const AddTask = ( { onCreate } ) => {
149+ export const AddTaskBar = ( { onCreate } ) => {
132150 const [ value , setValue ] = useState ( '' ) ;
133151 const [ id , setId ] = useState ( 0 ) ;
134152 return (
0 commit comments