Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/ui/src/components/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Root as SignInRoot } from '@clerk/elements/sign-in';
import * as React from 'react';

import { GetHelpContext } from '~/components/sign-in/hooks/use-get-help';
import { SignInChooseSession } from '~/components/sign-in/steps/choose-session';
import { SignInChooseStrategy } from '~/components/sign-in/steps/choose-strategy';
import { SignInForgotPassword } from '~/components/sign-in/steps/forgot-password';
import { SignInGetHelp } from '~/components/sign-in/steps/get-help';
Expand All @@ -10,8 +11,6 @@ import { SignInStart } from '~/components/sign-in/steps/start';
import { SignInVerifications } from '~/components/sign-in/steps/verifications';
import { type Appearance, AppearanceProvider, useAppearance } from '~/contexts';

import { SignInChooseSession } from './steps/choose-session';

/**
* Implementation Details:
*
Expand Down
15 changes: 3 additions & 12 deletions packages/ui/src/components/sign-in/steps/choose-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { cva } from 'cva';
import { Button } from 'react-aria-components';

import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useLocalizations } from '~/hooks/use-localizations';
import * as Card from '~/primitives/card';
import * as Icon from '~/primitives/icon';
Expand Down Expand Up @@ -60,16 +59,8 @@ const sessionAction = cva({
export function SignInChooseSession() {
const { signOut } = useClerk();
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const isDev = useDevModeWarning();
const { branded } = useDisplayConfig();

const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { footerProps } = useCard();

return (
<SignIn.Step name='choose-session'>
Expand Down Expand Up @@ -160,7 +151,7 @@ export function SignInChooseSession() {
</div>
</Card.Body>
</Card.Content>
<Card.Footer {...cardFooterProps}>
<Card.Footer {...footerProps}>
<Card.FooterAction>
<Button
onPress={() => {
Expand Down
21 changes: 4 additions & 17 deletions packages/ui/src/components/sign-in/steps/choose-strategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { Connections } from '~/common/connections';
import { GlobalError } from '~/common/global-error';
import { useGetHelp } from '~/components/sign-in/hooks/use-get-help';
import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useEnabledConnections } from '~/hooks/use-enabled-connections';
import { useLocalizations } from '~/hooks/use-localizations';
import { Button } from '~/primitives/button';
Expand Down Expand Up @@ -48,23 +47,11 @@ function FirstFactorConnections({
export function SignInChooseStrategy() {
const enabledConnections = useEnabledConnections();
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();
const { setShowHelp } = useGetHelp();

const hasConnection = enabledConnections.length > 0;
const isDev = useDevModeWarning();
const cardLogoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { logoProps, footerProps } = useCard();

return (
<Common.Loading scope='global'>
Expand All @@ -74,7 +61,7 @@ export function SignInChooseStrategy() {
<Card.Root banner={isDev ? LOCALIZATION_NEEDED.developmentMode : null}>
<Card.Content>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.alternativeMethods.title')}</Card.Title>
<Card.Description>{t('signIn.alternativeMethods.subtitle')}</Card.Description>
</Card.Header>
Expand Down Expand Up @@ -197,7 +184,7 @@ export function SignInChooseStrategy() {
</div>
</Card.Body>
</Card.Content>
<Card.Footer {...cardFooterProps}>
<Card.Footer {...footerProps}>
<Card.FooterAction>
<Card.FooterActionText>
{t('signIn.alternativeMethods.actionText')}{' '}
Expand Down
21 changes: 4 additions & 17 deletions packages/ui/src/components/sign-in/steps/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { Connections } from '~/common/connections';
import { GlobalError } from '~/common/global-error';
import { useGetHelp } from '~/components/sign-in/hooks/use-get-help';
import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useLocalizations } from '~/hooks/use-localizations';
import { Button } from '~/primitives/button';
import * as Card from '~/primitives/card';
Expand All @@ -17,22 +16,10 @@ import { Separator } from '~/primitives/separator';

export function SignInForgotPassword() {
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();
const { setShowHelp } = useGetHelp();

const isDev = useDevModeWarning();
const cardLogoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { logoProps, footerProps } = useCard();

return (
<Common.Loading scope='global'>
Expand All @@ -42,7 +29,7 @@ export function SignInForgotPassword() {
<Card.Root banner={isDev ? LOCALIZATION_NEEDED.developmentMode : null}>
<Card.Content>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.forgotPasswordAlternativeMethods.title')}</Card.Title>
</Card.Header>

Expand Down Expand Up @@ -152,7 +139,7 @@ export function SignInForgotPassword() {
</SignIn.Action>
</Card.Body>
</Card.Content>
<Card.Footer {...cardFooterProps}>
<Card.Footer {...footerProps}>
<Card.FooterAction>
<Card.FooterActionText>
{t('signIn.alternativeMethods.actionText')}{' '}
Expand Down
21 changes: 4 additions & 17 deletions packages/ui/src/components/sign-in/steps/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,18 @@ import { CheckboxField } from '~/common/checkbox-field';
import { GlobalError } from '~/common/global-error';
import { PasswordField } from '~/common/password-field';
import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useLocalizations } from '~/hooks/use-localizations';
import { Button } from '~/primitives/button';
import * as Card from '~/primitives/card';
import { LinkButton } from '~/primitives/link';

export function SignInResetPassword() {
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();

const isDev = useDevModeWarning();
const cardLogoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { logoProps, footerProps } = useCard();

return (
<Common.Loading scope='global'>
Expand All @@ -39,7 +26,7 @@ export function SignInResetPassword() {
<Card.Root banner={isDev ? LOCALIZATION_NEEDED.developmentMode : null}>
<Card.Content>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.resetPassword.title')}</Card.Title>
</Card.Header>

Expand Down Expand Up @@ -92,7 +79,7 @@ export function SignInResetPassword() {
</SignIn.Action>
</Card.Actions>
</Card.Content>
<Card.Footer {...cardFooterProps} />
<Card.Footer {...footerProps} />
</Card.Root>
</SignIn.Step>
);
Expand Down
21 changes: 5 additions & 16 deletions packages/ui/src/components/sign-in/steps/start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { PhoneNumberField } from '~/common/phone-number-field';
import { PhoneNumberOrUsernameField } from '~/common/phone-number-or-username-field';
import { UsernameField } from '~/common/username-field';
import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useAttributes } from '~/hooks/use-attributes';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useEnabledConnections } from '~/hooks/use-enabled-connections';
Expand All @@ -26,27 +26,16 @@ import { Separator } from '~/primitives/separator';
export function SignInStart() {
const enabledConnections = useEnabledConnections();
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const { enabled: usernameEnabled } = useAttributes('username');
const { enabled: phoneNumberEnabled } = useAttributes('phone_number');
const { enabled: emailAddressEnabled } = useAttributes('email_address');
const { enabled: passkeyEnabled } = useAttributes('passkey');
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();
const { applicationName } = useDisplayConfig();

const hasConnection = enabledConnections.length > 0;
const hasIdentifier = emailAddressEnabled || usernameEnabled || phoneNumberEnabled;
const isDev = useDevModeWarning();
const cardLogoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { logoProps, footerProps } = useCard();

return (
<Common.Loading scope='global'>
Expand All @@ -56,7 +45,7 @@ export function SignInStart() {
<Card.Root banner={isDev ? LOCALIZATION_NEEDED.developmentMode : null}>
<Card.Content>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.start.title', { applicationName })}</Card.Title>
<Card.Description>{t('signIn.start.subtitle', { applicationName })}</Card.Description>
</Card.Header>
Expand Down Expand Up @@ -180,7 +169,7 @@ export function SignInStart() {
</Card.Actions>
</Card.Content>

<Card.Footer {...cardFooterProps}>
<Card.Footer {...footerProps}>
<Card.FooterAction>
<Card.FooterActionText>
{t('signIn.start.actionText')}{' '}
Expand Down
33 changes: 11 additions & 22 deletions packages/ui/src/components/sign-in/steps/verifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GlobalError } from '~/common/global-error';
import { OTPField } from '~/common/otp-field';
import { PasswordField } from '~/common/password-field';
import { LOCALIZATION_NEEDED } from '~/constants/localizations';
import { useAppearance } from '~/contexts';
import { useCard } from '~/hooks/use-card';
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning';
import { useDisplayConfig } from '~/hooks/use-display-config';
import { useLocalizations } from '~/hooks/use-localizations';
Expand All @@ -19,22 +19,11 @@ import { formatSafeIdentifier } from '~/utils/format-safe-identifier';

export function SignInVerifications() {
const { t } = useLocalizations();
const { layout } = useAppearance().parsedAppearance;
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();
const { applicationName } = useDisplayConfig();

const isDev = useDevModeWarning();
const isPasswordResetSupported = useResetPasswordFactor();
const cardLogoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const cardFooterProps = {
branded,
helpPageUrl: layout?.helpPageUrl,
privacyPageUrl: layout?.privacyPageUrl,
termsPageUrl: layout?.termsPageUrl,
};
const { logoProps, footerProps } = useCard();

return (
<Common.Loading scope='global'>
Expand All @@ -45,7 +34,7 @@ export function SignInVerifications() {
<Card.Content>
<SignIn.Strategy name='password'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.password.title')}</Card.Title>
<Card.Description>{t('signIn.password.subtitle')}</Card.Description>
<Card.Description>
Expand Down Expand Up @@ -122,7 +111,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='passkey'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.passkey.title')}</Card.Title>
<Card.Description>{t('signIn.passkey.subtitle')}</Card.Description>
<Card.Description>
Expand Down Expand Up @@ -176,7 +165,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='backup_code'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.backupCodeMfa.title')}</Card.Title>
<Card.Description>{t('signIn.backupCodeMfa.subtitle')}</Card.Description>
</Card.Header>
Expand Down Expand Up @@ -222,7 +211,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='email_code'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.emailCode.title')}</Card.Title>
<Card.Description>{t('signIn.emailCode.subtitle', { applicationName })}</Card.Description>
<Card.Description>
Expand Down Expand Up @@ -301,7 +290,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='phone_code'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.phoneCode.title')}</Card.Title>
<Card.Description>{t('signIn.phoneCode.subtitle', { applicationName })}</Card.Description>
<Card.Description>
Expand Down Expand Up @@ -381,7 +370,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='email_link'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.emailLink.title')}</Card.Title>
<Card.Description>{t('signIn.emailLink.formSubtitle', { applicationName })}</Card.Description>
<Card.Description>
Expand Down Expand Up @@ -492,7 +481,7 @@ export function SignInVerifications() {

<SignIn.Strategy name='totp'>
<Card.Header>
<Card.Logo {...cardLogoProps} />
<Card.Logo {...logoProps} />
<Card.Title>{t('signIn.totpMfa.formTitle')}</Card.Title>
<Card.Description>{t('signIn.totpMfa.subtitle', { applicationName })}</Card.Description>
</Card.Header>
Expand Down Expand Up @@ -534,7 +523,7 @@ export function SignInVerifications() {
</Card.Actions>
</SignIn.Strategy>
</Card.Content>
<Card.Footer {...cardFooterProps} />
<Card.Footer {...footerProps} />
</Card.Root>
</SignIn.Step>
);
Expand Down
Loading