Skip to content
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

fix: otp new styles and flow #1250

Merged
merged 12 commits into from
Jan 21, 2025
Merged

fix: otp new styles and flow #1250

merged 12 commits into from
Jan 21, 2025

Conversation

jcaleb4
Copy link
Collaborator

@jcaleb4 jcaleb4 commented Dec 20, 2024

Pull Request Checklist

Here is a video sample of the changes.
NOTE: Styles and logic for the verified stage is complete in the code, however I am still working on how to show that view for a few seconds before redirecting to the authenticated home view.
This is a screenshot of the styles in the app:
Screenshot 2024-12-18 at 10 03 34 PM

Task: https://app.asana.com/0/1205598840815267/1209006976980114/f
Change: We were using the default outline style for focus elements, this is open to each browser or OS since all of them can display the focus differently; what we did here is disable the default focus style and set a custom style for when the input field is focused, this should display the same way in all browsers and OSs.
This also aligns better with the styles for the regular input field when focussed in other sections.

Chrome Before change:
Screenshot 2024-12-17 at 10 49 32 AM

iPhone Before change:
Screenshot 2024-12-17 at 10 49 05 AM

Chrome After change:
Screenshot 2024-12-17 at 12 52 14 PM

iPhone After change:
Screenshot 2024-12-17 at 12 52 39 PM

Task: https://app.asana.com/0/1205598840815267/1208982122598661/f
Change: Removing the "otp_completing" view step to keep the OTP input field in view while the validation happens.
On error the message will be shown bellow the input field.
On new focus after error, the error state will reset so the user can try again.
When the last value is set into the input, the input is disabled to prevent changes while validating.

ticket: https://app.asana.com/0/1205598840815267/1208982122598661/f
Figma: https://www.figma.com/design/bUj0hMD0o8c5UqYyz5kJ44/WS-Login-Modal?node-id=38-1928&p=f&m=dev
changes: Here I am adding an enum to be used instead of strings for the auth steps and flow, the reason is that this way we centralize the source of the options we have, we avoid typos and we also make sure to keep a better order while integrating new steps and flows.
We're also adding some important style changes to the OTP flow when we have a "verifying", "error" or initial stages, there is the implementation for the "verified" stage but I am still working on showing it since right now as soon as the code is validated the view changes to the home page I am still investigation on why is this the case or how to let us see the verified stage for at least 3 seconds before moving to the next screen but is taking more time than I was expecting.

Screenshot 2024-12-18 at 3 58 04 PM
Screenshot 2024-12-18 at 4 03 35 PM
Screenshot 2024-12-18 at 10 03 34 PM


PR-Codex overview

This PR focuses on enhancing the user authentication flow by introducing new status handling and UI updates for the OTP verification process, along with adding new color variants and improving the overall code structure.

Detailed summary

  • Added fg-success color variant in utils.test.ts and theme.ts.
  • Introduced AuthStepStatus enum in context.ts for better status management.
  • Updated LoadingOtp component to handle new states and display messages.
  • Removed CompletingOtp component.
  • Modified EmailNotReceivedDisclaimer to reflect OTP verification status.
  • Improved OTPInput props and handling of verified state.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 6:53pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 6:53pm

Copy link

graphite-app bot commented Dec 20, 2024

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

@dphilipson dphilipson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this work, it looks great! Left a few nitpicky comments inline.

},
onSuccess: () => {
if (isConnected) {
setAuthStep({ type: "complete" });
setAuthStep({ ...authStep, status: AuthStepStatus.success });
setTitleText(ls.loadingOtp.verified);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like we might be able to derive the title text from the auth step, so we don't need to maintain state for it. Is that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the state since the error text is not only updated by the auth step but also the input field which is a child component, the error can come from there too.

setErrorText(errorText);

if (errorText) {
setTitleText(ls.loadingOtp.title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does resetting the OTP only reset the title if there is error text?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so we don't call that function in case there wasn't an error, in that case the text doesn't have to be updated, but since removing the conditional is not affecting the functionality I'll just do it.
Thanks

className={`text-xs font-normal underline ${
isOTPVerifying ? "text-fg-disabled" : "text-btn-primary"
}`}
style={isOTPVerifying ? { opacity: 1 } : {}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, can we use the tailwind class opacity-100 instead of a style prop here?

setTitleText(ls.loadingOtp.verified);
setTimeout(() => {
setAuthStep({ type: "complete" });
}, 3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's extract this delay into a top-level constant in this file.

type: "otp_verify";
email: string;
error?: Error;
status?: AuthStepStatus | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The | null is a bit out of place compared to the rest of these types. Can we have it as just status?: AuthStepStatus?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I will replace the null with a base state, good feedback, thanks.

focus:outline-none focus:border-active
${!disabled && "bg-bg-surface-default text-fg-primary"}
${!!errorText && "border-fg-critical"}
${isVerified && "border-fg-success"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe pretty nitpicky, but this can end up adding classes with names like "null", "undefined", or "false", which due to the global nature of CSS could maybe conceivably be classes defined in the surrounding app and therefore inadvertently add styling to this element. I know it's pretty unlikely someone would choose those classnames, but it would still be more correct to do these with ternaries, e.g.

${isVerified ? "border-fg-success" : ""}

If writing that all the time is too burdensome, we can make ourselves a helper similar to clsx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No nitpicky at all, this is great feedback, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants