-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(onboarding-ui): Rewrite
AwaitingConfirmationPage
page (#1183)
- Loading branch information
1 parent
d5b2694
commit c3835a6
Showing
10 changed files
with
174 additions
and
46 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/onboarding-ui": patch | ||
--- | ||
|
||
refactor(onboarding-ui): Rewrite `AwaitingConfirmationPage` page |
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
19 changes: 19 additions & 0 deletions
19
packages/onboarding-ui/src/forms/AwaitConfirmationForm/AwaitConfirmationForm.spec.tsx
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,19 @@ | ||
import ReactDOM from 'react-dom'; | ||
|
||
import AwaitConfirmationForm from './AwaitConfirmationForm'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render( | ||
<AwaitConfirmationForm | ||
currentStep={4} | ||
stepCount={4} | ||
securityCode='Funny Tortoise In The Hat' | ||
emailAddress='[email protected]' | ||
onResendEmailRequest={() => true} | ||
onChangeEmailRequest={() => true} | ||
/>, | ||
div | ||
); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/onboarding-ui/src/forms/AwaitConfirmationForm/AwaitConfirmationForm.stories.tsx
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,30 @@ | ||
import type { Story, Meta } from '@storybook/react'; | ||
import type { ComponentProps } from 'react'; | ||
|
||
import AwaitConfirmationForm from './AwaitConfirmationForm'; | ||
|
||
type Args = ComponentProps<typeof AwaitConfirmationForm>; | ||
|
||
export default { | ||
title: 'forms/AwaitConfirmationForm', | ||
component: AwaitConfirmationForm, | ||
parameters: { | ||
actions: { argTypesRegex: '^on.*' }, | ||
layout: 'centered', | ||
}, | ||
argTypes: { | ||
onResendEmailRequest: { action: 'resetEmailRequest' }, | ||
onChangeEmailRequest: { action: 'changeEmailRequest' }, | ||
}, | ||
args: { | ||
currentStep: 4, | ||
stepCount: 4, | ||
securityCode: 'Funny Tortoise In The Hat', | ||
emailAddress: '[email protected]', | ||
}, | ||
} as Meta<Args>; | ||
|
||
export const _AwaitConfirmationForm: Story<Args> = (args) => ( | ||
<AwaitConfirmationForm {...args} /> | ||
); | ||
_AwaitConfirmationForm.storyName = 'AwaitConfirmationForm'; |
65 changes: 65 additions & 0 deletions
65
packages/onboarding-ui/src/forms/AwaitConfirmationForm/AwaitConfirmationForm.tsx
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,65 @@ | ||
import { Box, Label } from '@rocket.chat/fuselage'; | ||
import { Form } from '@rocket.chat/layout'; | ||
import type { ReactElement } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import EmailCodeFallback from '../../common/EmailCodeFallback'; | ||
|
||
type AwaitingConfirmationFormProps = { | ||
currentStep: number; | ||
stepCount: number; | ||
securityCode: string; | ||
emailAddress: string; | ||
onResendEmailRequest: () => void; | ||
onChangeEmailRequest: () => void; | ||
}; | ||
|
||
const AwaitingConfirmationForm = ({ | ||
currentStep, | ||
stepCount, | ||
securityCode, | ||
emailAddress, | ||
onResendEmailRequest, | ||
onChangeEmailRequest, | ||
}: AwaitingConfirmationFormProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Form> | ||
<Form.Header> | ||
<Form.Steps currentStep={currentStep} stepCount={stepCount} /> | ||
<Form.Title>{t('form.awaitConfirmationForm.title')}</Form.Title> | ||
</Form.Header> | ||
<Form.Container> | ||
<Box fontScale='c1' mbe={24}> | ||
<Trans i18nKey='form.awaitConfirmationForm.content.sentEmail'> | ||
Email sent to <strong>{{ emailAddress }}</strong> with a | ||
confirmation link.Please verify that the security code below matches | ||
the one in the email. | ||
</Trans> | ||
</Box> | ||
<Label> | ||
{t('form.awaitConfirmationForm.content.securityCode')} | ||
<Box | ||
padding='12px' | ||
width='full' | ||
fontScale='p2b' | ||
lineHeight='20px' | ||
backgroundColor='tint' | ||
elevation='1' | ||
> | ||
{securityCode} | ||
</Box> | ||
</Label> | ||
</Form.Container> | ||
<Form.Footer> | ||
<EmailCodeFallback | ||
onResendEmailRequest={onResendEmailRequest} | ||
onChangeEmailRequest={onChangeEmailRequest} | ||
/> | ||
</Form.Footer> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default AwaitingConfirmationForm; |
1 change: 1 addition & 0 deletions
1
packages/onboarding-ui/src/forms/AwaitConfirmationForm/index.ts
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 @@ | ||
export { default } from './AwaitConfirmationForm'; |
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 |
---|---|---|
|
@@ -12,13 +12,19 @@ export default { | |
actions: { argTypesRegex: '^on.*' }, | ||
layout: 'fullscreen', | ||
}, | ||
argTypes: { | ||
onResendEmailRequest: { action: 'resetEmailRequest' }, | ||
onChangeEmailRequest: { action: 'changeEmailRequest' }, | ||
}, | ||
args: { | ||
currentStep: 4, | ||
stepCount: 4, | ||
securityCode: 'Funny Tortoise In The Hat', | ||
emailAddress: '[email protected]', | ||
}, | ||
} as Meta<Args>; | ||
|
||
export const _AwaitingConfirmationPage: Story<Args> = (args) => ( | ||
<AwaitingConfirmationPage {...args} /> | ||
); | ||
_AwaitingConfirmationPage.storyName = 'AwaitingConfirmationPage'; | ||
_AwaitingConfirmationPage.args = { | ||
securityCode: 'Funny Tortoise In The Hat', | ||
emailAddress: '[email protected]', | ||
}; |
69 changes: 32 additions & 37 deletions
69
packages/onboarding-ui/src/pages/AwaitingConfirmationPage/AwaitingConfirmationPage.tsx
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 |
---|---|---|
@@ -1,55 +1,50 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import colors from '@rocket.chat/fuselage-tokens/colors.json'; | ||
import { | ||
HeroLayout, | ||
HeroLayoutTitle, | ||
HeroLayoutSubtitle, | ||
} from '@rocket.chat/layout'; | ||
import type { ReactElement } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { BackgroundLayer } from '@rocket.chat/layout'; | ||
import type { ReactElement, ReactNode } from 'react'; | ||
|
||
import EmailCodeFallback from '../../common/EmailCodeFallback'; | ||
import type { FormPageLayoutStyleProps } from '../../Types'; | ||
import FormPageLayout from '../../common/FormPageLayout'; | ||
import AwaitingConfirmationForm from '../../forms/AwaitConfirmationForm'; | ||
|
||
type AwaitingConfirmationPageProps = { | ||
title?: ReactNode; | ||
description?: ReactNode; | ||
currentStep: number; | ||
stepCount: number; | ||
emailAddress: string; | ||
securityCode: string; | ||
onResendEmailRequest: () => void; | ||
onChangeEmailRequest: () => void; | ||
}; | ||
|
||
const pageLayoutStyleProps: FormPageLayoutStyleProps = { | ||
justifyContent: 'center', | ||
}; | ||
|
||
const AwaitingConfirmationPage = ({ | ||
title, | ||
description, | ||
currentStep, | ||
stepCount, | ||
securityCode, | ||
emailAddress, | ||
onResendEmailRequest, | ||
onChangeEmailRequest, | ||
}: AwaitingConfirmationPageProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<HeroLayout> | ||
<HeroLayoutTitle>{t('page.awaitingConfirmation.title')}</HeroLayoutTitle> | ||
<HeroLayoutSubtitle> | ||
{t('page.awaitingConfirmation.subtitle', { emailAddress })} | ||
</HeroLayoutSubtitle> | ||
|
||
<Box | ||
maxWidth={498} | ||
padding={18} | ||
width='full' | ||
fontSize='x22' | ||
lineHeight='x32' | ||
backgroundColor={colors.n700} | ||
borderRadius='x3' | ||
> | ||
{securityCode} | ||
</Box> | ||
|
||
<EmailCodeFallback | ||
}: AwaitingConfirmationPageProps): ReactElement => ( | ||
<BackgroundLayer> | ||
<FormPageLayout | ||
title={title} | ||
styleProps={pageLayoutStyleProps} | ||
description={description} | ||
> | ||
<AwaitingConfirmationForm | ||
currentStep={currentStep} | ||
stepCount={stepCount} | ||
securityCode={securityCode} | ||
emailAddress={emailAddress} | ||
onResendEmailRequest={onResendEmailRequest} | ||
onChangeEmailRequest={onChangeEmailRequest} | ||
/> | ||
</HeroLayout> | ||
); | ||
}; | ||
|
||
</FormPageLayout> | ||
</BackgroundLayer> | ||
); | ||
export default AwaitingConfirmationPage; |