-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslation.jsx
28 lines (26 loc) · 1.33 KB
/
Translation.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React from 'react'
import { LANGUAGES } from '../utils/presets'
export default function Translation(props) {
const { textElement, toLanguage, translating, setToLanguage, generateTranslation } = props
return (
<>
{(textElement && !translating) && (
<p>{textElement}</p>
)}
{!translating && (<div className='flex flex-col gap-1 mb-4'>
<p className='text-xs sm:text-sm font-medium text-slate-500 mr-auto'>To language</p>
<div className='flex items-stretch gap-2 sm:gap-4' >
<select value={toLanguage} className='flex-1 outline-none w-full focus:outline-none bg-white duration-200 p-2 rounded' onChange={(e) => setToLanguage(e.target.value)}>
<option value={'Select language'}>Select language</option>
{Object.entries(LANGUAGES).map(([key, value]) => {
return (
<option key={key} value={value}>{key}</option>
)
})}
</select>
<button onClick={generateTranslation} className='specialBtn px-3 py-2 rounded-lg text-blue-400 hover:text-blue-600 duration-200'>Translate</button>
</div>
</div>)}
</>
)
}