(text, button)
| 452 | |
| 453 | // Function to copy text to the clipboard |
| 454 | const copyToClipboard = (text, button) => { |
| 455 | navigator.clipboard.writeText(text).then(() => { |
| 456 | setButtonState(button, 'working', 'copy') |
| 457 | }).catch((err) => { |
| 458 | console.error('Failed to copy code: ', err) |
| 459 | setButtonState(button, 'error', 'copy') |
| 460 | }) |
| 461 | } |
| 462 | |
| 463 | // Function to set the button state and color |
| 464 | const setButtonState = (button, state, type) => { |
no test coverage detected