Skip to content

Commit

Permalink
fix(clerk-js): SignIn/SignUp component spacing adjustment (#2716)
Browse files Browse the repository at this point in the history
* fix(clerk-js): Spacing fixes for Sign In & Sign Up components

* fix(clerk-js): Spacing fixes for Sign In / Sign Up components

* fix(clerk-js): Fix social button font size

* chore(repo): Add Changeset

* fix(clerk-js): Move errors outside of header
  • Loading branch information
octoper authored Feb 5, 2024
1 parent e246c7e commit e1c8ea0
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .changeset/thin-trees-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const AlternativeMethodsList = (props: AlternativeMethodListProps) => {
<Flow.Part part={asForgotPassword ? 'forgotPasswordMethods' : 'alternativeMethods'}>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title
localizationKey={localizationKeys(
asForgotPassword ? 'signIn.forgotPasswordAlternativeMethods.title' : 'signIn.alternativeMethods.title',
Expand All @@ -50,11 +49,12 @@ const AlternativeMethodsList = (props: AlternativeMethodListProps) => {
<Header.Subtitle localizationKey={localizationKeys('signIn.alternativeMethods.subtitle')} />
)}
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{/*TODO: extract main in its own component */}
<Flex
direction='col'
elementDescriptor={descriptors.main}
gap={6}
gap={3}
>
{asForgotPassword && resetPasswordFactor && (
<Button
Expand Down
6 changes: 3 additions & 3 deletions packages/clerk-js/src/ui/components/SignIn/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export const _ResetPassword = () => {
return (
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.resetPassword.title')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Col
elementDescriptor={descriptors.main}
gap={8}
Expand Down Expand Up @@ -145,7 +145,7 @@ export const _ResetPassword = () => {
</Form.ControlRow>
)}
</Col>
<Col gap={4}>
<Col gap={3}>
<Form.SubmitButton
isDisabled={!canSubmit}
localizationKey={localizationKeys('signIn.resetPassword.formButtonPrimary')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const _ResetPasswordSuccess = () => {
return (
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.resetPassword.title')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Col
elementDescriptor={descriptors.main}
gap={8}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const _SignInAccountSwitcher = () => {
<Flow.Part part='accountSwitcher'>
<Card.Root>
<Card.Content sx={t => ({ padding: `${t.space.$8} ${t.space.$none} ${t.space.$none}` })}>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Title localizationKey={localizationKeys('signIn.accountSwitcher.title')} />
<Header.Subtitle localizationKey={localizationKeys('signIn.accountSwitcher.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Col
elementDescriptor={descriptors.main}
gap={8}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ export const SignInFactorOnePasswordCard = (props: SignInFactorOnePasswordProps)
return (
<Flow.Part part='password'>
<Card.Root>
<Card.Content gap={4}>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root gap={1}>
<Card.Content>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.password.title')} />
<Header.Subtitle localizationKey={localizationKeys('signIn.password.subtitle')} />
<IdentityPreview
Expand All @@ -103,6 +102,7 @@ export const SignInFactorOnePasswordCard = (props: SignInFactorOnePasswordProps)
onClick={goBack}
/>
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{/*TODO: extract main in its own component */}
<Flex
direction='col'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ const AlternativeMethodsList = (props: AlternativeMethodsProps & { onHavingTroub
<Flow.Part part='alternativeMethods'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.alternativeMethods.title')} />
<Header.Subtitle localizationKey={localizationKeys('signIn.alternativeMethods.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{/*TODO: extract main in its own component */}
<Col
elementDescriptor={descriptors.main}
gap={4}
gap={3}
>
<Col gap={2}>
{supportedSecondFactors.sort(backupCodePrefFactorComparator).map((factor, i) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export const SignInFactorTwoBackupCodeCard = (props: SignInFactorTwoBackupCodeCa
return (
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.backupCodeMfa.title')} />
<Header.Subtitle
localizationKey={
Expand All @@ -76,6 +75,7 @@ export const SignInFactorTwoBackupCodeCard = (props: SignInFactorTwoBackupCodeCa
}
/>
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Col
elementDescriptor={descriptors.main}
gap={8}
Expand All @@ -88,17 +88,19 @@ export const SignInFactorTwoBackupCodeCard = (props: SignInFactorTwoBackupCodeCa
onActionClicked={onShowAlternativeMethodsClicked}
/>
</Form.ControlRow>
<Form.SubmitButton hasArrow />
<Col gap={3}>
<Form.SubmitButton hasArrow />
<Card.Action elementId='alternativeMethods'>
{onShowAlternativeMethodsClicked && (
<Card.ActionLink
localizationKey={localizationKeys('footerActionLink__useAnotherMethod')}
onClick={onShowAlternativeMethodsClicked}
/>
)}
</Card.Action>
</Col>
</Form.Root>
</Col>
<Card.Action elementId='alternativeMethods'>
{onShowAlternativeMethodsClicked && (
<Card.ActionLink
localizationKey={localizationKeys('footerActionLink__useAnotherMethod')}
onClick={onShowAlternativeMethodsClicked}
/>
)}
</Card.Action>
</Card.Content>

<Card.Footer />
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ export function _SignInStart(): JSX.Element {
<Flow.Part part='start'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signIn.start.title')} />
<Header.Subtitle localizationKey={localizationKeys('signIn.start.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{/*TODO: extract main in its own component */}
<Col
elementDescriptor={descriptors.main}
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/components/SignUp/SignUpContinue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ function _SignUpContinue() {
<Flow.Part part='complete'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signUp.continue.title')} />
<Header.Subtitle localizationKey={localizationKeys('signUp.continue.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Flex
direction='col'
elementDescriptor={descriptors.main}
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/components/SignUp/SignUpStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ function _SignUpStart(): JSX.Element {
<Flow.Part part='start'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={localizationKeys('signUp.start.title')} />
<Header.Subtitle localizationKey={localizationKeys('signUp.start.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Flex
direction='col'
elementDescriptor={descriptors.main}
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ApplicationLogo = (props: ApplicationLogoProps) => {
{...props}
sx={[
theme => ({
height: getContainerHeightForImageRatio(imageRef, theme.sizes.$6),
height: getContainerHeightForImageRatio(imageRef, theme.sizes.$4),
objectFit: 'cover',
justifyContent: 'center',
}),
Expand Down
11 changes: 4 additions & 7 deletions packages/clerk-js/src/ui/elements/Card/CardContent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';

import { descriptors, Flex, generateFlowPartClassname, Icon, useAppearance } from '../../customizables';
import { descriptors, Flex, generateFlowPartClassname, Icon } from '../../customizables';
import { Close } from '../../icons';
import { type PropsOfComponent } from '../../styledSystem';
import { ApplicationLogo } from '..';
import { useFlowMetadata } from '../contexts';
import { IconButton } from '../IconButton';
import { useUnsafeModalContext } from '../Modal';
Expand All @@ -12,14 +11,12 @@ type CardContentProps = PropsOfComponent<typeof Flex>;
export const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>((props, ref) => {
const { children, sx, ...rest } = props;
const flowMetadata = useFlowMetadata();
const appearance = useAppearance();
const { toggle } = useUnsafeModalContext();

return (
<Flex
direction='col'
className={generateFlowPartClassname(flowMetadata)}
{...rest}
elementDescriptor={descriptors.card}
sx={[
t => ({
Expand All @@ -31,16 +28,16 @@ export const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>((p
boxShadow: t.shadows.$cardContentShadow,
borderRadius: t.radii.$lg,
position: 'relative',
padding: t.space.$8,
gap: t.space.$8,
padding: `${t.space.$8} ${t.space.$10}`,
justifyContent: 'center',
alignContent: 'center',
}),
sx,
]}
gap={8}
ref={ref}
{...rest}
>
{appearance.parsedLayout.logoPlacement === 'inside' && <ApplicationLogo />}
{toggle && (
<IconButton
elementDescriptor={descriptors.modalCloseButton}
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/elements/ErrorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const ErrorCard = (props: ErrorCardProps) => {
<Flow.Part part='havingTrouble'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={props.cardTitle || 'Error'} />
{props.cardSubtitle && <Header.Subtitle localizationKey={props.cardSubtitle} />}
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{/*TODO: extract main in its own component */}
<Flex
direction='col'
Expand Down
22 changes: 17 additions & 5 deletions packages/clerk-js/src/ui/elements/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import React from 'react';

import { Col, descriptors, Heading, Text } from '../customizables';
import { Col, descriptors, Heading, Text, useAppearance } from '../customizables';
import type { PropsOfComponent } from '../styledSystem';
import { ApplicationLogo } from './ApplicationLogo';

export type HeaderProps = PropsOfComponent<typeof Col> & {
showLogo?: boolean;
};

const Root = React.memo(
React.forwardRef<HTMLDivElement, PropsOfComponent<typeof Col>>((props, ref) => {
const { sx, ...rest } = props;
React.forwardRef<HTMLDivElement, HeaderProps>((props, ref) => {
const { sx, children, showLogo = false, ...rest } = props;
const appearance = useAppearance();

const logoIsVisible = appearance.parsedLayout.logoPlacement === 'inside' && showLogo;

return (
<Col
ref={ref}
elementDescriptor={descriptors.header}
gap={1}
gap={6}
sx={sx}
{...rest}
/>
>
{logoIsVisible && <ApplicationLogo />}
<Col gap={1}>{children}</Col>
</Col>
);
}),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/elements/PhoneInput/PhoneInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const PhoneInputBase = forwardRef<HTMLInputElement, PhoneInputProps>((props, ref
</SelectButton>
<SelectOptionList
sx={{ width: '100%', padding: '0 0' }}
containerSx={{ gap: 0 }}
containerSx={theme => ({ gap: 0, padding: `${theme.space.$0x5} 0` })}
/>
</Select>

Expand Down Expand Up @@ -187,7 +187,7 @@ const CountryCodeListItem = memo((props: CountryCodeListItemProps) => {
theme => ({
width: '100%',
gap: theme.space.$2,
padding: `${theme.space.$0x5} ${theme.space.$4}`,
padding: `${theme.space.$1x5} ${theme.space.$4}`,
}),
sx,
]}
Expand Down
3 changes: 2 additions & 1 deletion packages/clerk-js/src/ui/elements/SocialButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const SocialButtonIcon = forwardRef((props: SocialButtonProps, ref: Ref<HTMLButt
elementDescriptor={descriptors.socialButtonsIconButton}
elementId={descriptors.socialButtonsIconButton.setId(id)}
variant='secondary'
textVariant='buttonLarge'
sx={t => ({
minHeight: t.sizes.$8,
width: '100%',
Expand Down Expand Up @@ -243,7 +244,7 @@ const SocialButtonBlock = (props: SocialButtonProps): JSX.Element => {
elementId={descriptors.socialButtonsBlockButtonText.setId(id)}
as='span'
truncate
variant='buttonSmall'
variant='buttonLarge'
localizationKey={textLocalizationKey}
>
{label}
Expand Down
6 changes: 3 additions & 3 deletions packages/clerk-js/src/ui/elements/VerificationCodeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export const VerificationCodeCard = (props: PropsWithChildren<VerificationCodeCa
return (
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={props.cardTitle} />
<Header.Subtitle localizationKey={props.cardSubtitle} />
<IdentityPreview
Expand All @@ -53,6 +52,7 @@ export const VerificationCodeCard = (props: PropsWithChildren<VerificationCodeCa
onClick={!props.onBackLinkClicked ? props.onIdentityPreviewEditClicked : undefined}
/>
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{children}
<Col
elementDescriptor={descriptors.main}
Expand All @@ -63,7 +63,7 @@ export const VerificationCodeCard = (props: PropsWithChildren<VerificationCodeCa
label={props.inputLabel}
resendButton={props.resendButton}
/>
<Col gap={4}>
<Col gap={3}>
<Button
elementDescriptor={descriptors.formButtonPrimary}
block
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/elements/VerificationLinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export const VerificationLinkCard = (props: VerificationLinkCardProps) => {
<Flow.Part part='emailLinkVerify'>
<Card.Root>
<Card.Content>
<Card.Alert>{card.error}</Card.Alert>
<Header.Root>
<Header.Root showLogo>
<Header.Title localizationKey={props.cardTitle} />
<VerificationLink
formTitle={props.formTitle}
Expand All @@ -50,6 +49,7 @@ export const VerificationLinkCard = (props: VerificationLinkCardProps) => {
/>
</VerificationLink>
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Card.Action elementId='alternativeMethods'>
{props.onShowAlternativeMethodsClicked && (
<Card.ActionLink
Expand Down

0 comments on commit e1c8ea0

Please sign in to comment.