diff options
| author | Melonai <einebeere@gmail.com> | 2021-01-20 23:18:09 +0100 |
|---|---|---|
| committer | Melonai <einebeere@gmail.com> | 2021-01-20 23:18:09 +0100 |
| commit | 826c7c47785ee01d2b9267919132ada696425344 (patch) | |
| tree | 901cc90be9a953a6c3f968b6c1abe33cc13774b4 /client/src/Components/Form.js | |
| parent | 2953dec527cedaabaa5f0eb48637c5ddd4a4103b (diff) | |
| download | shorest-826c7c47785ee01d2b9267919132ada696425344.tar.zst shorest-826c7c47785ee01d2b9267919132ada696425344.zip | |
Remade the client in SvelteKit
Diffstat (limited to 'client/src/Components/Form.js')
| -rw-r--r-- | client/src/Components/Form.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/client/src/Components/Form.js b/client/src/Components/Form.js deleted file mode 100644 index 979d9c9..0000000 --- a/client/src/Components/Form.js +++ /dev/null @@ -1,39 +0,0 @@ -import React, {useState} from 'react'; -import Button from './Button'; -import isURL from "validator/lib/isURL"; - -function Form(props) { - const [state, setState] = useState({value: '', valid: false}); - - const handleSubmit = () => { - if (state.valid) { - props.addRequest(state.value); - } - }; - - const handleChange = e => { - const userInput = e.target.value; - const valid = isURL('https://' + userInput); - setState({value: userInput, valid: valid}); - }; - - const handlePaste = e => { - e.preventDefault(); - const pattern = /^https?:\/\//; - setState({value: e.clipboardData.getData('Text').replace(pattern, ''), valid: false}); - }; - - return ( - <form id="form" onSubmit={(e) => e.preventDefault()}> - <div className="input-group"> - <div className="input-container"> - <span className="input-field-text">https://</span> - <input className="input-field" required value={state.value} onChange={handleChange} onPaste={handlePaste}/> - </div> - <Button valid={state.valid} submit={handleSubmit}/> - </div> - </form> - ) -} - -export default Form; \ No newline at end of file |
