Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

new copy button #24

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/content/UserPage/UserPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const UserPage = () => {
const [inputTextValue, inputTextSetValue] = React.useState('')
const [outputTextValue, outputTextSetValue] = React.useState('')
const [loading, loadingSetValue] = React.useState('')
const [copyButton, setCopyButton] = React.useState('')
const textAreaRef = React.useRef(null)

const inputTextOnChange = e => {
inputTextSetValue(e.target.value)
Expand Down Expand Up @@ -43,12 +45,19 @@ const UserPage = () => {
xhr.send(inputTextValue)
loadingSetValue(true)
}
setCopyButton(true)
}

const cleanText = () => {
inputTextSetValue('')
}

const handleCopy = e => {
textAreaRef.current.select()
document.execCommand('copy')
e.target.focus()
}

return (
<div>
{loading ? <Loading /> : null}
Expand Down Expand Up @@ -114,11 +123,17 @@ const UserPage = () => {
rows={20}
className='user-page-text-area-second'
placeholder='Texto revisado'
ref={textAreaRef}
/>
<br />
<Button className='copy-Button' kind='secondary'>
Copiar texto
</Button>
{copyButton
? <Button
onClick={handleCopy}
className='copy-Button'
kind='secondary'
>
Copiar texto
</Button> : null}
<div className='click-here'>
<span>
<strong>A revisão não está correta?</strong>
Expand Down