From 39edec79cbf8f84565e9125133ac600909b26a6e Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 27 Aug 2018 15:51:59 +0200 Subject: [PATCH] Adapt SignIn --- src/core/client/auth/components/App.css | 3 +- .../client/auth/components/ForgotPassword.tsx | 3 +- .../client/auth/components/ResetPassword.tsx | 3 +- src/core/client/auth/components/SignIn.css | 6 - src/core/client/auth/components/SignIn.tsx | 132 ++++++++++-------- src/core/client/auth/components/SignUp.tsx | 4 +- .../auth/containers/SignInContainer.tsx | 25 +--- .../auth/containers/SignUpContainer.tsx | 20 +-- src/core/client/ui/shared/typography.css | 14 +- src/locales/en-US/auth.ftl | 19 +++ 10 files changed, 118 insertions(+), 111 deletions(-) delete mode 100644 src/core/client/auth/components/SignIn.css create mode 100644 src/locales/en-US/auth.ftl diff --git a/src/core/client/auth/components/App.css b/src/core/client/auth/components/App.css index 99be430a5..c36dceb31 100644 --- a/src/core/client/auth/components/App.css +++ b/src/core/client/auth/components/App.css @@ -12,6 +12,7 @@ .root { width: 100%; - padding: var(--spacing-unit); + padding: var(--spacing-unit) var(--spacing-unit) calc(2 * var(--spacing-unit)) + var(--spacing-unit); box-sizing: border-box; } diff --git a/src/core/client/auth/components/ForgotPassword.tsx b/src/core/client/auth/components/ForgotPassword.tsx index 68707eea2..49b1be188 100644 --- a/src/core/client/auth/components/ForgotPassword.tsx +++ b/src/core/client/auth/components/ForgotPassword.tsx @@ -1,7 +1,6 @@ import React, { StatelessComponent } from "react"; import { Field, Form } from "react-final-form"; import { OnSubmit } from "talk-framework/lib/form"; -import * as styles from "./SignIn.css"; import { composeValidators, @@ -35,7 +34,7 @@ const ForgotPassword: StatelessComponent = props => { {({ handleSubmit }) => (
- + Forgot Password diff --git a/src/core/client/auth/components/ResetPassword.tsx b/src/core/client/auth/components/ResetPassword.tsx index b459bf460..c16139cdd 100644 --- a/src/core/client/auth/components/ResetPassword.tsx +++ b/src/core/client/auth/components/ResetPassword.tsx @@ -1,7 +1,6 @@ import React, { StatelessComponent } from "react"; import { Field, Form } from "react-final-form"; import { OnSubmit } from "talk-framework/lib/form"; -import * as styles from "./SignIn.css"; import { composeValidators, @@ -38,7 +37,7 @@ const ResetPassword: StatelessComponent = props => { {({ handleSubmit }) => ( - + Reset Password diff --git a/src/core/client/auth/components/SignIn.css b/src/core/client/auth/components/SignIn.css deleted file mode 100644 index 55699399e..000000000 --- a/src/core/client/auth/components/SignIn.css +++ /dev/null @@ -1,6 +0,0 @@ -.root { -} - -.forgotPassword { - text-align: right; -} diff --git a/src/core/client/auth/components/SignIn.tsx b/src/core/client/auth/components/SignIn.tsx index 406891a84..46dc0a910 100644 --- a/src/core/client/auth/components/SignIn.tsx +++ b/src/core/client/auth/components/SignIn.tsx @@ -1,3 +1,4 @@ +import { Localized } from "fluent-react/compat"; import React, { StatelessComponent } from "react"; import { Field, Form } from "react-final-form"; import { OnSubmit } from "talk-framework/lib/form"; @@ -6,7 +7,6 @@ import { composeValidators, required, validateEmail, - validatePassword, } from "talk-framework/lib/validation"; import { @@ -14,6 +14,7 @@ import { CallOut, Flex, FormField, + HorizontalGutter, InputLabel, TextField, Typography, @@ -21,7 +22,6 @@ import { } from "talk-ui/components"; import AutoHeightContainer from "../containers/AutoHeightContainer"; -import * as styles from "./SignIn.css"; interface FormProps { email: string; @@ -30,8 +30,8 @@ interface FormProps { export interface SignInForm { onSubmit: OnSubmit; - goToSignUp: () => void; - goToForgotPassword: () => void; + onGotoSignUp: () => void; + onGotoForgotPassword: () => void; } const SignIn: StatelessComponent = props => { @@ -40,10 +40,12 @@ const SignIn: StatelessComponent = props => { {({ handleSubmit, submitting, submitError }) => ( - - - Sign in to join the conversation - + + + + Sign in to join the conversation + + {submitError && ( @@ -57,16 +59,24 @@ const SignIn: StatelessComponent = props => { > {({ input, meta }) => ( - Email Address - + + Email Address + + + + {meta.touched && (meta.error || meta.submitError) && ( - + {meta.error || meta.submitError} )} @@ -74,63 +84,75 @@ const SignIn: StatelessComponent = props => { )} - + {({ input, meta }) => ( - Password - + + Password + + + + {meta.touched && (meta.error || meta.submitError) && ( - + {meta.error || meta.submitError} )} - - - + + + + + )} - -
+ - - Don't have an account? - - -
-
+ + + + } + > + + {"Don't have an account? "} + + + + )} diff --git a/src/core/client/auth/components/SignUp.tsx b/src/core/client/auth/components/SignUp.tsx index 3b01e7609..42ec23610 100644 --- a/src/core/client/auth/components/SignUp.tsx +++ b/src/core/client/auth/components/SignUp.tsx @@ -34,7 +34,7 @@ interface FormProps { export interface SignUpForm { onSubmit: OnSubmit; - goToSignIn: () => void; + onGotoSignIn: () => void; } const SignUp: StatelessComponent = props => { @@ -179,7 +179,7 @@ const SignUp: StatelessComponent = props => { variant="underlined" size="small" color="primary" - onClick={props.goToSignIn} + onClick={props.onGotoSignIn} > Sign In diff --git a/src/core/client/auth/containers/SignInContainer.tsx b/src/core/client/auth/containers/SignInContainer.tsx index 54077c2e7..fe2b87949 100644 --- a/src/core/client/auth/containers/SignInContainer.tsx +++ b/src/core/client/auth/containers/SignInContainer.tsx @@ -13,21 +13,7 @@ interface SignInContainerProps { setView: SetViewMutation; } -interface SignUpContainerState { - error: string | null; -} - -export type View = "SIGN_UP" | "FORGOT_PASSWORD"; - -class SignInContainer extends Component< - SignInContainerProps, - SignUpContainerState -> { - private setView = (view: View) => { - this.props.setView({ - view, - }); - }; +class SignInContainer extends Component { private onSubmit: SignInForm["onSubmit"] = async (input, form) => { try { await this.props.signIn(input); @@ -36,14 +22,15 @@ class SignInContainer extends Component< return { [FORM_ERROR]: error.message }; } }; - private goToForgotPassword = () => this.setView("FORGOT_PASSWORD"); - private goToSignUp = () => this.setView("SIGN_UP"); + private goToForgotPassword = () => + this.props.setView({ view: "FORGOT_PASSWORD" }); + private goToSignUp = () => this.props.setView({ view: "SIGN_UP" }); public render() { return ( ); } diff --git a/src/core/client/auth/containers/SignUpContainer.tsx b/src/core/client/auth/containers/SignUpContainer.tsx index f18115557..8be2d84ed 100644 --- a/src/core/client/auth/containers/SignUpContainer.tsx +++ b/src/core/client/auth/containers/SignUpContainer.tsx @@ -14,21 +14,7 @@ interface SignUpContainerProps { setView: SetViewMutation; } -interface SignUpContainerState { - error: string | null; -} - -export type View = "SIGN_IN"; - -class SignUpContainer extends Component< - SignUpContainerProps, - SignUpContainerState -> { - private setView = (view: View) => { - this.props.setView({ - view, - }); - }; +class SignUpContainer extends Component { private onSubmit: SignUpForm["onSubmit"] = async (input, form) => { try { return await this.props.signUp(input); @@ -37,9 +23,9 @@ class SignUpContainer extends Component< return { [FORM_ERROR]: error.message }; } }; - private goToSignIn = () => this.setView("SIGN_IN"); + private goToSignIn = () => this.props.setView({ view: "SIGN_IN" }); public render() { - return ; + return ; } } diff --git a/src/core/client/ui/shared/typography.css b/src/core/client/ui/shared/typography.css index 7f99ddf39..3cd3a2c01 100644 --- a/src/core/client/ui/shared/typography.css +++ b/src/core/client/ui/shared/typography.css @@ -1,7 +1,7 @@ @font-face { font-family: "Source Sans Pro"; font-style: normal; - font-display: swap; + font-display: block; font-weight: 300; src: local("Source Sans Pro Light "), local("Source Sans Pro-Light"), url("typeface-source-sans-pro/files/source-sans-pro-latin-300.woff2") @@ -13,7 +13,7 @@ @font-face { font-family: "Source Sans Pro"; font-style: normal; - font-display: swap; + font-display: block; font-weight: 400; src: local("Source Sans Pro Regular italic"), local("Source Sans Pro-Regularitalic"), @@ -26,7 +26,7 @@ @font-face { font-family: "Source Sans Pro"; font-style: normal; - font-display: swap; + font-display: block; font-weight: 600; src: local("Source Sans Pro SemiBold italic"), local("Source Sans Pro-SemiBolditalic"), @@ -39,7 +39,7 @@ @font-face { font-family: "Manuale"; font-style: normal; - font-display: swap; + font-display: block; font-weight: 400; src: local("Manuale Regular "), local("Manuale-Regular"), url("typeface-manuale/files/manuale-latin-400.woff2") format("woff2"), @@ -49,7 +49,7 @@ @font-face { font-family: "Manuale"; font-style: normal; - font-display: swap; + font-display: block; font-weight: 600; src: local("Manuale SemiBold "), local("Manuale-SemiBold"), url("typeface-manuale/files/manuale-latin-600.woff2") format("woff2"), @@ -60,7 +60,7 @@ font-size: calc(24rem / var(--rem-base)); font-weight: var(--font-weight-medium); font-family: var(--font-family-serif); - line-height: calc(32em / 24); + line-height: calc(26em / 24); letter-spacing: calc(0.2em / 24); color: var(--palette-text-primary); } @@ -69,7 +69,7 @@ font-size: calc(20rem / var(--rem-base)); font-weight: var(--font-weight-medium); font-family: var(--font-family-serif); - line-height: calc(24em / 20); + line-height: calc(22em / 20); letter-spacing: calc(0.2em / 20); color: var(--palette-text-primary); } diff --git a/src/locales/en-US/auth.ftl b/src/locales/en-US/auth.ftl new file mode 100644 index 000000000..87e1649ae --- /dev/null +++ b/src/locales/en-US/auth.ftl @@ -0,0 +1,19 @@ +### Localization for the Auth Popup + +## Sign In + +signIn-signInToJoinHeader = Sign in to join the conversation + +signIn-signInAndJoinButton = Sign in and join the conversation + +signIn-emailAddressLabel = Email Address +signIn-emailAddressTextfield = + .placeholder = Email Address + +signIn-passwordLabel = Password +signIn-passwordTextfield = + .placeholder = Password + +signIn-forgotYourPassword = Forgot your password? + +signIn-noAccountSignUp = Don't have an account?