-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-step log in/sign up modal, with user type #849
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3b7d0c4
multi-step modal login/signup flow
austensen cc1d308
+
austensen dd08c25
ignore unused footer for now
austensen 0beb6b3
add preview urls pattern to cors whitelist
austensen 8343e22
add back preview urls to whitelist
austensen 7c9eb33
clean up styles for login - text styles, padding, etc.
austensen dd804a8
refactor error handling in input components, clean type
austensen 64768ca
login flow ending
austensen 33a66af
ix double padding on subscribed box
austensen c266c18
prettier
austensen 3b99332
clean up styles and fix subscribed icon
austensen c35e754
update headers and existinguser alerts on building apge
austensen b7e7220
update verify copy/styles, fix input-level errors for sign up
austensen 3df1a46
update password props on reset and change pages
austensen 7228b2b
fix account settings pw input styles
austensen 670de39
remove unused icon
austensen edd268a
fix duplicate id on change password page
austensen ece5b38
don't show input-lvel error on bad pw format during login
austensen 34d4c4a
make setError required for password input
austensen 4bd4fe0
use same showError props for usertype error handling
austensen be1f499
add input props extends for email/pw, set auto focus on modal
austensen fff9d57
remove old id prop for pw input
austensen da8d76f
prevent extra i18n prop getting passed to input
austensen 85e3760
usertype input remove preventDefault bug radio not updating
austensen 3e5a4bb
add "didn't get link" line to on page verify reminder
austensen 45c4318
show footer on login as well as sign up in modal
austensen 5b5ff59
Merge branch 'email-alerts-account-signup' into user-type-modal
austensen baa71c5
fix typo in usertype input error
austensen 0d603be
Merge branch 'email-alerts-account-signup' into user-type-modal
austensen fa1cf67
Merge branch 'email-alerts-account-signup' into user-type-modal
austensen bb7cb97
more updates for base 16px rem units
austensen f2ea547
undo account settings rem changes (doubled up)
austensen cae9622
remove duplicates cors regex from merge update
austensen 7eed028
update register operations to include user type
austensen c28cc16
delete commented code, fix js var case format
austensen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { ChangeEvent, forwardRef } from "react"; | ||
import { t } from "@lingui/macro"; | ||
import { I18n } from "@lingui/core"; | ||
import { withI18n } from "@lingui/react"; | ||
import { AlertIcon } from "./Icons"; | ||
|
||
import "styles/EmailInput.css"; | ||
import "styles/_input.scss"; | ||
import classNames from "classnames"; | ||
|
||
interface EmailInputProps extends React.ComponentPropsWithoutRef<"input"> { | ||
i18n: I18n; | ||
email: string; | ||
error: boolean; | ||
setError: React.Dispatch<React.SetStateAction<boolean>>; | ||
showError: boolean; | ||
onChange: (e: ChangeEvent<HTMLInputElement>) => void; | ||
i18nHash?: string; | ||
} | ||
|
||
const EmailInputWithoutI18n = forwardRef<HTMLInputElement, EmailInputProps>( | ||
({ i18n, i18nHash, email, error, setError, showError, onChange, ...props }, ref) => { | ||
const isBadEmailFormat = (value: string) => { | ||
/* valid email regex rules | ||
alpha numeric characters are ok, upper/lower case agnostic | ||
username: leading \_ ok, chars \_\.\-\+ ok in all other positions | ||
domain name: chars \.\- ok as long as not leading. must end in a \. and at least two alphabet chars */ | ||
const pattern = | ||
"^([a-zA-Z0-9_]+[a-zA-Z0-9+_.-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-zA-Z]{2,})$"; | ||
|
||
// HTML input element has loose email validation requirements, so we check the input against a custom regex | ||
const passStrictRegex = value.match(pattern); | ||
const passAutoValidation = document.querySelectorAll("input:invalid").length === 0; | ||
|
||
return !passAutoValidation || !passStrictRegex; | ||
}; | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
onChange(e); | ||
const emailIsInvalid = isBadEmailFormat(e.target.value); | ||
setError(emailIsInvalid); | ||
}; | ||
|
||
return ( | ||
<div className="email-input-field"> | ||
<div className="email-input-label"> | ||
<label htmlFor="email-input">{i18n._(t`Email address`)}</label> | ||
</div> | ||
{showError && error && ( | ||
<div className="email-input-errors"> | ||
<span id="input-field-error"> | ||
<AlertIcon /> | ||
{i18n._(t`Please enter a valid email address.`)} | ||
</span> | ||
</div> | ||
)} | ||
<div className="email-input"> | ||
<input | ||
type="email" | ||
id="email-input" | ||
className={classNames("input", { invalid: showError && error })} | ||
onChange={handleChange} | ||
value={email} | ||
{...props} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
); | ||
|
||
const EmailInput = withI18n({ withHash: false })(EmailInputWithoutI18n); | ||
|
||
export default EmailInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{email}
is showing up as plaintext here!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's working on local so I'm pretty sure this is just that issue with not having done
lingui extract
yet, but I've been holding off until everything is merged intoemail-alerts..