aboutsummaryrefslogtreecommitdiffstats
path: root/components/Form.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-08-09 21:36:03 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-08-09 21:37:03 +0200
commit464e470441287572cfda8d95484f781236b9db35 (patch)
tree87177837cb6ee6ee000f0d39fa5ba7ee6bb2943e /components/Form.js
downloadmy_apps-464e470441287572cfda8d95484f781236b9db35.tar.gz
my_apps-464e470441287572cfda8d95484f781236b9db35.tar.bz2
my_apps-464e470441287572cfda8d95484f781236b9db35.zip
init commit
Diffstat (limited to 'components/Form.js')
-rw-r--r--components/Form.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/components/Form.js b/components/Form.js
new file mode 100644
index 0000000..fc14a75
--- /dev/null
+++ b/components/Form.js
@@ -0,0 +1,46 @@
+import React from 'react'
+import PropTypes from 'prop-types'
+
+const Form = ({errorMessage, onSubmit, isLogin}) => (
+ <form className='window window--popup' onSubmit={onSubmit}>
+ <div className="window__content--popup">
+ {isLogin ? 'Login to access your notes' : 'Register new user'}
+ </div>
+ <input type="email" name="email" placeholder="email" required />
+ <input type="password" name="password" minLength="6" placeholder="password" required />
+
+ <input className='window__button' type="submit" value={isLogin ? 'Login' : 'Register'} />
+
+ {errorMessage && <p className="error">{errorMessage}</p>}
+
+ <style jsx>{`
+ form,
+ label {
+ display: flex;
+ flex-flow: column;
+ }
+ label > span {
+ font-weight: 600;
+ }
+ input[type=email],
+ input[type=password] {
+ padding: .5em;
+ margin: .5em 0;
+ border: 1px solid #ccc;
+ border-radius: .25px;
+ }
+ .error {
+ text-align: center;
+ color: brown;
+ margin: 1rem 0 0;
+ }
+ `}</style>
+ </form>
+)
+
+export default Form
+
+Form.propTypes = {
+ errorMessage: PropTypes.string,
+ onSubmit: PropTypes.func,
+}