From f470636a70943a8ecad8bddc791a1c2dddd28e1e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 4 May 2019 21:13:12 +0300 Subject: Components -> UI --- vnext/src/ui/LoginButton.js | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 vnext/src/ui/LoginButton.js (limited to 'vnext/src/ui/LoginButton.js') diff --git a/vnext/src/ui/LoginButton.js b/vnext/src/ui/LoginButton.js new file mode 100644 index 00000000..cd26252e --- /dev/null +++ b/vnext/src/ui/LoginButton.js @@ -0,0 +1,90 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import Icon from './Icon'; +import Modal from './Modal'; +import Button from './Button'; +import Input from './Input'; +import { useFormState } from 'react-use-form-state'; + +import { me, facebookLink, vkLink } from '../api'; + +function LoginButton({ onAuth, title }) { + const [open, setOpen] = useState(false); + const [formState, { text, password }] = useFormState(); + + let onToggle = (event) => { + if (event) { + event.preventDefault(); + } + setOpen(!open); + }; + let onSubmit = (event) => { + event.preventDefault(); + me(formState.values.username, formState.values.password) + .then(response => { + onToggle(); + onAuth(response); + } + ).catch(ex => { + console.log(ex); + }); + }; + return ( + <> + + + {title} + + +
+

Please, introduce yourself:

+
+ + Log in + + + + Log in + +
+

Already registered?

+
+
+
+ +
+
+
+ + ); +} + +LoginButton.propTypes = { + title: PropTypes.string.isRequired, + onAuth: PropTypes.func.isRequired +}; + +const socialButtonsStyle = { + display: 'flex', + justifyContent: 'space-evenly', + padding: '4px' +}; + +const facebookButtonStyle = { + color: '#fff', + padding: '2px 14px', + background: '#3b5998' +}; + +const vkButtonStyle = { + color: '#fff', + padding: '2px 14px', + background: '#4c75a3' +}; + +export default LoginButton; -- cgit v1.2.3