Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

feat(Formbot): support for yup via validationSchema; Add Context provider and EasyInput consumer #20

Merged
merged 20 commits into from
Feb 26, 2019

Conversation

choochootrain
Copy link

@choochootrain choochootrain commented Feb 22, 2019

@choochootrain choochootrain requested a review from a team February 22, 2019 23:51
@codecov-io
Copy link

Codecov Report

Merging #20 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #20   +/-   ##
=======================================
  Coverage   71.91%   71.91%           
=======================================
  Files          12       12           
  Lines         146      146           
  Branches       19       19           
=======================================
  Hits          105      105           
  Misses         31       31           
  Partials       10       10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e783265...6725c09. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Feb 22, 2019

Codecov Report

Merging #20 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #20   +/-   ##
=======================================
  Coverage   71.91%   71.91%           
=======================================
  Files          12       12           
  Lines         146      146           
  Branches       19       19           
=======================================
  Hits          105      105           
  Misses         31       31           
  Partials       10       10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e783265...e32d5d8. Read the comment docs.

@kylealwyn
Copy link
Contributor

Let's add docz example using yup

src/Form/Formbot.js Outdated Show resolved Hide resolved
src/Form/Formbot.js Outdated Show resolved Hide resolved
src/Form/Formbot.js Outdated Show resolved Hide resolved
src/Form/FormGroup.js Outdated Show resolved Hide resolved
@kylealwyn
Copy link
Contributor

screen shot 2019-02-22 at 5 05 27 pm
After clicking submit in new yup example

Copy link
Contributor

@cehsu cehsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting an error:
"TypeError: this.validatable.map is not a function[Learn More]"
Do we need to add something like this? Or am I doing something wrong?

  constructor(props) {
    this.validatable = [];
  }

src/Form/Formbot.example.js Outdated Show resolved Hide resolved
src/index.js Outdated
@@ -16,6 +16,7 @@ export Flex from './Flex';
export Formbot from './Form/Formbot';
export FormError from './Form/FormError';
export FormGroup from './Form/FormGroup';
export FieldSet from './Form/FormGroup';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fieldset should be an entirely new component. FormGroups refer to https://getbootstrap.com/docs/4.0/components/forms/#form-groups which adds bottom margin to adjacent inputs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added but FieldSet does something similar in the presence of adjacent elements - unclear how one would mix usage of FieldSet and FormGroup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm also web-app has a different FieldSet which has a sublegend and is styled differently - should we leave them as is or theme FieldSets?

@choochootrain
Copy link
Author

theres also PhoneInput, DateInput in web-app so this PR will get pretty big

i can ship this as is and update the EMR and we can do a second pass to clean up the web-app next hack day

@kylealwyn
Copy link
Contributor

@choochootrain

Supernit: Can we rename FieldSet to Fieldset? HTML tag reads fieldset so I'd prefer sticking to convention and start casing?


added but FieldSet does something similar in the presence of adjacent elements - unclear how one would mix usage of FieldSet and FormGroup

Our FormGroup and Field are very similar. Most (should be all) of our input components are wrapped in <Field />, which adds top margin to siblings. FormGroup, on the other hand, always applies a bottom margin.

Fieldset is used for optionally grouping related fields if multiple sets exist and conventionally has the legend element as first descendant. See edit-profile.js in web app, where we group personal and address information.

The css class form-group in Bootstrap always applies a margin bottom, and we use it to wrap components in a form which may not have a margin applied, or most commonly, a row of inputs within columns where the css sibling selector breaks. This is more a sugar component for consistency, as we could do <Box mb={3}> and get the same results

<Form>
  <Fieldset legend="Some group of fields">
    <Input />
    <Input /> {/* Here we have adjacent Fields so this one has a top margin applied */}
  </Fieldset>

  <Fieldset legend="Some other group of fields">
    <FormGroup>
      <Row>
         <Col>
            <Input />
         </Col>
         <Col>
            <Input />
         </Col>
      </Row>
    </FormGroup>
  </Fieldset>

  <Button type="submit" />
</Form>

theres also PhoneInput, DateInput in web-app so this PR will get pretty big

i can ship this as is and update the EMR and we can do a second pass to clean up the web-app next hack day

This is the right call.

@choochootrain
Copy link
Author

@kylealwyn looks like FormGroup uses Box in favor of bootstrap's form-group class

const FormGroup = ({ children, padding = 3 }) => <Box mb={padding}>{children}</Box>;

@kylealwyn
Copy link
Contributor

kylealwyn commented Feb 25, 2019

@choochootrain sorry, only using bootstrap class as reference for why it exists

@choochootrain choochootrain changed the title Feat(formbot): Support validation via yup schema Feat(formbot): more convenient validation and state management Feb 25, 2019
@choochootrain
Copy link
Author

@sappira-inc/engineering take a look at the last change, i'm open to suggestions

@kylealwyn kylealwyn changed the title Feat(formbot): more convenient validation and state management feat(Formbot): more convenient validation and state management Feb 25, 2019
@kylealwyn kylealwyn changed the title feat(Formbot): more convenient validation and state management feat(Formbot): support for yup via validationSchema; Add Context provider and EasyInput consumer Feb 25, 2019
@kylealwyn kylealwyn merged commit 2e457be into master Feb 26, 2019
@choochootrain choochootrain deleted the fix/validate-yup branch February 26, 2019 18:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants