From 7a3317701448c7d754a434b9504523c89324e256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Mon, 25 May 2020 20:48:27 +0200 Subject: [PATCH] Card-ify login components (#53) * Card-ify login components * Fix lint warnings * Replace HTML with react-bootstrap components * Remove now obsolete flex div * Apply fixed width to fa-icons * Reset sign-in buttons to normal size --- .../social-link-button/social-link-button.tsx | 4 +- .../landing/pages/login/auth/via-email.tsx | 76 ++++++++++--------- .../landing/pages/login/auth/via-ldap.tsx | 76 ++++++++++--------- .../landing/pages/login/auth/via-open id.tsx | 59 -------------- .../landing/pages/login/auth/via-openid.tsx | 61 +++++++++++++++ src/components/landing/pages/login/login.scss | 3 - src/components/landing/pages/login/login.tsx | 53 ++++++------- 7 files changed, 167 insertions(+), 165 deletions(-) delete mode 100644 src/components/landing/pages/login/auth/via-open id.tsx create mode 100644 src/components/landing/pages/login/auth/via-openid.tsx delete mode 100644 src/components/landing/pages/login/login.scss diff --git a/src/components/landing/pages/login/auth/social-link-button/social-link-button.tsx b/src/components/landing/pages/login/auth/social-link-button/social-link-button.tsx index f4032f077..1594a2b8a 100644 --- a/src/components/landing/pages/login/auth/social-link-button/social-link-button.tsx +++ b/src/components/landing/pages/login/auth/social-link-button/social-link-button.tsx @@ -15,9 +15,9 @@ export const SocialLinkButton: React.FC = ({title, background - + - + {children} diff --git a/src/components/landing/pages/login/auth/via-email.tsx b/src/components/landing/pages/login/auth/via-email.tsx index 40a2e5dbb..412f3c062 100644 --- a/src/components/landing/pages/login/auth/via-email.tsx +++ b/src/components/landing/pages/login/auth/via-email.tsx @@ -1,6 +1,6 @@ import {Trans, useTranslation} from "react-i18next"; -import {Alert, Button, Form} from "react-bootstrap"; -import React, {Fragment, useState} from "react"; +import {Alert, Button, Card, Form} from "react-bootstrap"; +import React, {useState} from "react"; import {postEmailLogin} from "../../../../../api/user"; import {getAndSetUser} from "../../../../../utils/apiUtils"; @@ -27,42 +27,46 @@ export const ViaEMail: React.FC = () => { }; return ( - -
- -
-
- - setEmail(event.currentTarget.value)} - /> - + + + + + - - setPassword(event.currentTarget.value)} - /> - + + + setEmail(event.currentTarget.value)} + className="bg-dark text-white" + /> + - - - + + setPassword(event.currentTarget.value)} + className="bg-dark text-white" + /> + - - -
+ + + + + + + + ); } \ No newline at end of file diff --git a/src/components/landing/pages/login/auth/via-ldap.tsx b/src/components/landing/pages/login/auth/via-ldap.tsx index 5e5346313..716b70796 100644 --- a/src/components/landing/pages/login/auth/via-ldap.tsx +++ b/src/components/landing/pages/login/auth/via-ldap.tsx @@ -1,6 +1,6 @@ -import React, {Fragment, useState} from "react"; +import React, {useState} from "react"; import {Trans, useTranslation} from "react-i18next"; -import {Alert, Button, Form} from "react-bootstrap"; +import {Alert, Button, Card, Form} from "react-bootstrap"; import {postLdapLogin} from "../../../../../api/user"; import {getAndSetUser} from "../../../../../utils/apiUtils"; import {useSelector} from "react-redux"; @@ -33,43 +33,47 @@ const ViaLdap: React.FC = () => { } return ( - -
- -
-
- - setUsername(event.currentTarget.value)} - /> - + + + + + - - setPassword(event.currentTarget.value)} - /> - + + + setUsername(event.currentTarget.value)} + className="bg-dark text-white" + /> + - - - + + setPassword(event.currentTarget.value)} + className="bg-dark text-white" + /> + - - -
+ + + + + + + + ); }; diff --git a/src/components/landing/pages/login/auth/via-open id.tsx b/src/components/landing/pages/login/auth/via-open id.tsx deleted file mode 100644 index 5ba319835..000000000 --- a/src/components/landing/pages/login/auth/via-open id.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, {Fragment, useState} from "react"; -import {Trans, useTranslation} from "react-i18next"; -import {Alert, Button, Form} from "react-bootstrap"; -import {postOpenIdLogin} from "../../../../../api/user"; -import {getAndSetUser} from "../../../../../utils/apiUtils"; - -const ViaOpenId: React.FC = () => { - useTranslation(); - const [openId, setOpenId] = useState(""); - const [error, setError] = useState(false); - - const doAsyncLogin = () => { - (async () => { - try { - await postOpenIdLogin(openId); - await getAndSetUser(); - } catch { - setError(true); - } - })(); - } - - const onFormSubmit = (event: any) => { - doAsyncLogin(); - event.preventDefault(); - } - - return ( - -
- -
-
- - setOpenId(event.currentTarget.value)} - /> - - - - - - - -
-
- ); -}; - -export { ViaOpenId } diff --git a/src/components/landing/pages/login/auth/via-openid.tsx b/src/components/landing/pages/login/auth/via-openid.tsx new file mode 100644 index 000000000..3883e9acd --- /dev/null +++ b/src/components/landing/pages/login/auth/via-openid.tsx @@ -0,0 +1,61 @@ +import React, {useState} from "react"; +import {Trans, useTranslation} from "react-i18next"; +import {Alert, Button, Card, Form} from "react-bootstrap"; +import {postOpenIdLogin} from "../../../../../api/user"; +import {getAndSetUser} from "../../../../../utils/apiUtils"; + +const ViaOpenId: React.FC = () => { + useTranslation(); + const [openId, setOpenId] = useState(""); + const [error, setError] = useState(false); + const doAsyncLogin = () => { + (async () => { + try { + await postOpenIdLogin(openId); + await getAndSetUser(); + } catch { + setError(true); + } + })(); + } + + const onFormSubmit = (event: any) => { + doAsyncLogin(); + event.preventDefault(); + } + + return ( + + + + + + +
+ + setOpenId(event.currentTarget.value)} + className="bg-dark text-white" + /> + + + + + + + +
+
+
+ ); +}; + +export { ViaOpenId } diff --git a/src/components/landing/pages/login/login.scss b/src/components/landing/pages/login/login.scss deleted file mode 100644 index 598e0d928..000000000 --- a/src/components/landing/pages/login/login.scss +++ /dev/null @@ -1,3 +0,0 @@ -.social-button-container { - min-width: 30%; -} diff --git a/src/components/landing/pages/login/login.tsx b/src/components/landing/pages/login/login.tsx index 7597f3f63..2ee5547cc 100644 --- a/src/components/landing/pages/login/login.tsx +++ b/src/components/landing/pages/login/login.tsx @@ -1,14 +1,12 @@ import React from "react" -import {Col, Jumbotron, Row} from "react-bootstrap" +import {Card, Col, Row} from "react-bootstrap" import {Trans, useTranslation} from "react-i18next"; import {ViaEMail} from "./auth/via-email"; import {OneClickType, ViaOneClick} from "./auth/via-one-click"; import {ViaLdap} from "./auth/via-ldap"; import {useSelector} from "react-redux"; import {ApplicationState} from "../../../../redux"; -import {ViaOpenId} from "./auth/via-open id"; -import "./login.scss"; -import {ElementSeparator} from "../../../element-separator/element-separator"; +import {ViaOpenId} from "./auth/via-openid"; import {Redirect} from "react-router"; import {LoginStatus} from "../../../../redux/user/types"; @@ -40,26 +38,23 @@ const Login: React.FC = () => { } return ( - -
- - { - authProviders.email || authProviders.ldap || authProviders.openid ? - - }> - {emailForm} - {ldapForm} - {openIdForm} - -
- - : null - } - -
- -
-
+
+ + { + authProviders.email || authProviders.ldap || authProviders.openid ? + + {emailForm} + {ldapForm} + {openIdForm} + + : null + } + + + + + + { Object.values(OneClickType) .filter((value) => authProviders[value]) @@ -77,11 +72,11 @@ const Login: React.FC = () => { ) }) } -
- - -
- + + + +
+
) }