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

New form component #2693

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c42d500
form component with step highlight
clxandstuff Feb 9, 2023
fafaebf
demo
clxandstuff Feb 13, 2023
c703009
demo prep
clxandstuff Feb 13, 2023
e0aa7b0
demo prep
clxandstuff Feb 13, 2023
12a6854
step changing improvements
clxandstuff Feb 14, 2023
96c98ca
Merge branch 'master' into DS-4956-new-form-component
clxandstuff Mar 13, 2023
fbcd6ad
animate overlay
clxandstuff Mar 14, 2023
80b92f1
fix stylelint error
clxandstuff Mar 14, 2023
a46b4bf
fix wrong scroll position of the form
clxandstuff Mar 14, 2023
41ccf49
export FormStep as Form.Step
clxandstuff Mar 27, 2023
45df7ad
implement registration form example
clxandstuff May 5, 2023
a06c746
implement 3 forms to test flow
clxandstuff May 9, 2023
f8e5a6c
add onComplete props to Wizard
clxandstuff May 9, 2023
7d6f41f
allow all form attributes to be passed to Wizard.Step
clxandstuff May 10, 2023
12a6d87
work in progress on compatibility with useBrainlyForm
clxandstuff May 11, 2023
d0c533d
add "as" prop to switch how wizard step operates
clxandstuff May 15, 2023
7245a81
add "as" prop to enable custom form management
clxandstuff May 17, 2023
466fb30
change component names
clxandstuff May 17, 2023
91c49c8
add navigation buttons
clxandstuff May 23, 2023
b1c1425
Merge branch 'master' into DS-4956-new-form-component
clxandstuff May 23, 2023
5c0d5ff
fix navigation buttons layout
clxandstuff May 23, 2023
d1d7069
Merge branch 'master' into DS-4956-new-form-component
clxandstuff May 24, 2023
f24ec53
create stories for demo
clxandstuff May 24, 2023
42c0572
fix broken scss imports
clxandstuff May 25, 2023
fc54d3d
fix broken scss imports
clxandstuff May 25, 2023
8ee773b
add animation on last step on create account form
clxandstuff May 29, 2023
09e599d
adjust animation to big screens
clxandstuff May 29, 2023
9d66d11
resolve import errors
clxandstuff May 29, 2023
512db96
fix prettier errors
clxandstuff May 29, 2023
29265e3
fix typescript errors
clxandstuff May 29, 2023
6972019
style navigation
clxandstuff May 29, 2023
0265222
move success screen out of wizard
clxandstuff May 29, 2023
dce8825
add keyboard arrows navigation
clxandstuff May 29, 2023
0729766
add parent-child radio animations
clxandstuff May 30, 2023
176278f
fix prettier errors
clxandstuff May 30, 2023
f1f3e51
Merge branch 'master' into DS-4956-new-form-component
clxandstuff May 30, 2023
d892fa7
Merge branch 'master' into DS-4956-new-form-component
clxandstuff May 31, 2023
7e9fcf8
remove temp files
clxandstuff Jun 14, 2023
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
1 change: 1 addition & 0 deletions .storybook/public/animations/brand-heroes-lottie.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .storybook/public/animations/confetti-lottie.json

Large diffs are not rendered by default.

Binary file added .storybook/public/form_stories__avatar-mock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/cat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/parent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/pinguin_avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/quick-help-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/step-by-step-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/student.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lottie/last-illustration-final.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"meow": "^5.0.0",
"patch-package": "^6.5.1",
"path": "^0.12.7",
"postinstall-postinstall": "^2.1.0"
"postinstall-postinstall": "^2.1.0",
"react-hook-form": "7.37.0"
},
"devDependencies": {
"@babel/cli": "^7.8.3",
Expand Down Expand Up @@ -112,6 +113,7 @@
"husky": "^0.11.3",
"jest": "^24.0.0",
"jest-axe": "^5.0.1",
"lottie-react": "^2.4.0",
"mini-css-extract-plugin": "1.6.2",
"mutationobserver-shim": "^0.3.7",
"polished": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/components/card-interactive/CardCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import cx from 'classnames';
import Checkbox from '../form-elements/checkbox/Checkbox';
import Checkbox from '../form/checkbox/Checkbox';
import generateRandomString from '../../js/generateRandomString';

export interface CardCheckboxPropsType
Expand Down
2 changes: 1 addition & 1 deletion src/components/card-interactive/CardRadio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import cx from 'classnames';
import Radio from '../form-elements/radio/Radio';
import Radio from '../form/radio/Radio';
import generateRandomString from '../../js/generateRandomString';
import {useCardRadioGroupContext} from './CardRadioGroupContext';
import type {StyleType} from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Input, {SIZE, COLOR} from './Input';
import Flex from '../flex/Flex';

<Meta
title="Components/form/Input"
title="Components/Form Elements/Input"
component={Input}
argTypes={{
value: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import hex from '../colors/hex';
import Headline from '../text/Headline';

<Meta
title="Components/form/Select"
title="Components/Form Elements/Select"
component={Select}
argTypes={{
options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import hex from '../colors/hex';
import PageHeader from 'blocks/PageHeader';

<Meta
title="Components/form/Textarea"
title="Components/Form Elements/Textarea"
component={Textarea}
argTypes={{
type: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Checkbox from './Checkbox';
import CheckboxA11y from './stories/Checkbox.a11y.mdx';

<Meta
title="Components/form/Checkbox"
title="Components/Form Elements/Checkbox"
component={Checkbox}
argTypes={{
children: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import RadioGroup from './RadioGroup';
import RadioA11y from './stories/Radio.a11y.mdx';

<Meta
title="Components/form/Radio"
title="Components/Form Elements/Radio"
component={Radio}
argTypes={{
children: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import RadioGroupA11y from './stories/RadioGroup.a11y.mdx';
const colorOptions = ['light', 'dark'];

<Meta
title="Components/Form/Radio group"
title="Components/Form Elements/Radio group"
component={RadioGroup}
argTypes={{
children: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import cx from 'classnames';
import Input, {COLOR, SIZE} from '../form-elements/Input';
import type {InputPropsType} from '../form-elements/Input';
import Input, {COLOR, SIZE} from '../form/Input';
import type {InputPropsType} from '../form/Input';
import Icon from '../icons/Icon';
import Button, {ButtonTypeType} from '../buttons/Button';

Expand Down
2 changes: 1 addition & 1 deletion src/components/select-menu/SelectMenuOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {IconTypeType} from '../icons/Icon';

import SubjectIcon from '../subject-icons/SubjectIcon';
import Icon from '../icons/Icon';
import Checkbox from '../form-elements/checkbox/Checkbox';
import Checkbox from '../form/checkbox/Checkbox';
import Text from '../text/Text';

export type SelectOptionElementPropsType = {
Expand Down
75 changes: 75 additions & 0 deletions src/components/wizard/Wizard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react';
import {Wizard, WizardStep, useWizard} from './Wizard';
import Input from '../form/Input';
import RadioGroup from '../form/radio/RadioGroup';
import Radio from '../form/radio/Radio';
import Dialog from '../dialog/Dialog';
import './_wizard-stories.scss';
import CreateAccountStory from './stories/create-account';
import AskYourQuestionStory from './stories/ask-your-question';
import MonetisationStory from './stories/monetisation';

export default {
title: 'Components/Wizard',
decorators: [
Story => (
<Dialog size="fullscreen" open>
<Story />
</Dialog>
),
],
};

const InputField = ({name}) => {
return <Input name={name} />;
};

const FirstStepForm = () => {
const {next} = useWizard();

return (
<form
onSubmit={() => {
next();
}}
>
<WizardStep.Title>step 1 title</WizardStep.Title>
<InputField name="first_name" />
<WizardStep.Submit>next</WizardStep.Submit>
</form>
);
};

export const Default = () => {
const onComplete = () => {
alert('wizard form completed');
};
const onChange = () => null;

return (
<Wizard onComplete={onComplete}>
<Wizard.ProgressBar>form title</Wizard.ProgressBar>
<WizardStep as="div">
<Wizard.Title subtitle="form subtitle">form title</Wizard.Title>
<FirstStepForm />
</WizardStep>
<WizardStep>
<WizardStep.Title>step 2 title</WizardStep.Title>
<Input name="last_name" />
<WizardStep.Submit>next</WizardStep.Submit>
</WizardStep>
<WizardStep>
<WizardStep.Title>Last step title</WizardStep.Title>
<RadioGroup name="account_type" onChange={onChange}>
<Radio value="student">Student</Radio>
<Radio value="parent">Parent</Radio>
</RadioGroup>
<WizardStep.Submit>next</WizardStep.Submit>
</WizardStep>
</Wizard>
);
};

export const CreateAccount = CreateAccountStory;
export const AskYourQuestion = AskYourQuestionStory;
export const Monetisation = MonetisationStory;
Loading