Skip to content

Commit

Permalink
feat(ui): Add email link strategy for SignIn (#3715)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-bell authored Jul 15, 2024
1 parent a688093 commit df1f823
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .changeset/big-ads-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
61 changes: 56 additions & 5 deletions packages/ui/src/components/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function SignInComponentLoaded() {
<button
type='button'
className='text-accent-9 focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
aria-label='Edit email address'
aria-label='Start again'
>
<Icon.PencilUnderlined />
</button>
Expand Down Expand Up @@ -286,7 +286,7 @@ export function SignInComponentLoaded() {
<button
type='button'
className='text-accent-9 focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
aria-label='Edit email address'
aria-label='Start again'
>
<Icon.PencilUnderlined />
</button>
Expand Down Expand Up @@ -349,6 +349,60 @@ export function SignInComponentLoaded() {
</Card.Body>
</SignIn.Strategy>

<SignIn.Strategy name='email_link'>
<Card.Header>
{logoImageUrl ? (
<Card.Logo
href={homeUrl}
src={logoImageUrl}
alt={applicationName}
/>
) : null}
<Card.Title>{t('signIn.emailLink.title')}</Card.Title>
<Card.Description>{t('signIn.emailLink.formSubtitle', { applicationName })}</Card.Description>
<Card.Description>
<span className='flex items-center justify-center gap-2'>
<SignIn.SafeIdentifier />
<SignIn.Action
navigate='start'
asChild
>
<button
type='button'
className='text-accent-9 focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
aria-label='Start again'
>
<Icon.PencilUnderlined />
</button>
</SignIn.Action>
</span>
</Card.Description>
</Card.Header>

<Card.Body>
<Common.GlobalError>
{({ message }) => {
return <Alert>{message}</Alert>;
}}
</Common.GlobalError>
<SignIn.Action
asChild
resend
// eslint-disable-next-line react/no-unstable-nested-components
fallback={({ resendableAfter }) => (
<p className='text-gray-11 border border-transparent px-2.5 py-1.5 text-center text-base font-medium'>
{t('signIn.emailLink.resendButton')} (
<span className='tabular-nums'>{resendableAfter}</span>)
</p>
)}
>
<LinkButton type='button'>{t('signIn.emailLink.resendButton')}</LinkButton>
</SignIn.Action>

<LinkButton type='button'>{t('footerActionLink__useAnotherMethod')}</LinkButton>
</Card.Body>
</SignIn.Strategy>

<SignIn.Strategy name='reset_password_email_code'>
<Card.Header>
<Card.Title>{t('signIn.forgotPassword.title')}</Card.Title>
Expand Down Expand Up @@ -424,9 +478,6 @@ export function SignInComponentLoaded() {
<div className='flex flex-col gap-2'>
<Connections disabled={isGlobalLoading} />

{
// To be implemented in SDKI-72
}
<SignIn.SupportedStrategy
name='email_link'
asChild
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/sign-up/sign-up.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function SignUpComponentLoaded() {
<button
type='button'
className='focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
aria-label='Edit phone number'
aria-label='Start again'
>
<Icon.PencilUnderlined />
</button>
Expand Down Expand Up @@ -251,7 +251,7 @@ function SignUpComponentLoaded() {
<button
type='button'
className='focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
aria-label='Edit email address'
aria-label='Start again'
>
<Icon.PencilUnderlined />
</button>
Expand Down

0 comments on commit df1f823

Please sign in to comment.