sudo-archive/src/components/InputBox.js

37 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-07-13 22:31:37 +00:00
import React from 'react';
import { Arrow } from './Arrow';
import './InputBox.css'
// props = { onSubmit: (str) => {}, placeholder: string}
export function InputBox({ onSubmit, placeholder }) {
2021-07-14 15:15:25 +00:00
const [searchTerm, setSearchTerm] = React.useState("");
const [type, setType] = React.useState("movie");
const showContentType = type === "show" ? false : true;
2021-07-13 22:31:37 +00:00
return (
<form className="inputBar" onSubmit={(e) => {
e.preventDefault();
2021-07-14 15:15:25 +00:00
onSubmit(searchTerm, type)
2021-07-13 22:31:37 +00:00
return false;
}}>
2021-07-14 15:15:25 +00:00
<select name="type" id="type" className="inputDropdown" onChange={(e) => setType(e.target.value)} required>
<option value="movie">Movie</option>
<option value="show">TV Show</option>
</select>
2021-07-13 22:31:37 +00:00
<input
type='text'
className="inputTextBox"
id="inputTextBox"
placeholder={placeholder}
2021-07-14 15:15:25 +00:00
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
required
2021-07-13 22:31:37 +00:00
/>
2021-07-14 15:15:25 +00:00
<input type='text' className='inputOptionBox' id='inputOptionBoxSeason' placeholder='s' required={showContentType} hidden={showContentType}/>
<input type='text' className='inputOptionBox' id='inputOptionBoxEpisode' placeholder='e' required={showContentType} hidden={showContentType}/>
<button className="inputSearchButton"><span className="text">Search<span className="arrow"><Arrow /></span></span></button>
2021-07-13 22:31:37 +00:00
</form>
)
}