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

Formik Form Snippet #25

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following projects are "internal open source" at Launchpad. That means that
Project | Language | Visibility | Description
--- | --- | --- | ---
[Client Template](https://github.com/LaunchPadLab/client-template) | JS, React, Redux | Private | Template app for React/Redux SPAs.
[Ionic Client Template](https://github.com/LaunchPadLab/ionic-client-template) | JS, React, Redux, Ionic | Private | Template app for Ionic-based React/Redux SPAs.
Copy link
Author

Choose a reason for hiding this comment

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

Added the Ionic template, which was missing.

[Decanter](https://github.com/LaunchPadLab/decanter) | Ruby, Rails | Public | Gem that makes it easy to transform incoming data before it hits the controller action or model.
[Flight Readiness Review](https://github.com/LaunchPadLab/flight_readiness_review) | Bash | Private | Utility to set up a macOS laptop for design and development at LaunchPad Lab.
[Fuel](https://github.com/LaunchPadLab/fuel) (no longer maintained) | Ruby, Rails | Public | Stop developing Rails blogs and start writing your actual blog posts with this dead simple blogging engine for Rails.
Expand All @@ -36,6 +37,6 @@ Project | Language | Visibility | Description

## Gists

One function of Opex is to set standard processes by which we do our work. These processes are documented in the [gists](gists) folder of this repository.
One function of Opex is to set standard processes by which we do our work. These processes are documented in the [gists](gists) folder of this repository.

These documents are fairly limited in scope, and there are few of them by design. This prevents information overload and encourages us to encapsulate as many of our best practices as possible in our app template repositories. Still, they may come in handy as a general reference / anti-[bikeshedding](https://css-tricks.com/what-is-bikeshedding) tool.
46 changes: 46 additions & 0 deletions gists/snippets/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,52 @@ Copy the following into your `javascript.json` snippet file:
")(${1:MyFormComponent})"
],
"description": "LP-Form enhanced Redux-Form form component"
},
chawes13 marked this conversation as resolved.
Show resolved Hide resolved

"React Formik Component": {
"prefix": "reactFormikComponent",
"body": [
"import React from 'react'",
"import PropTypes from 'prop-types'",
"import { Formik, Form } from 'formik'",
"import * as Yup from 'yup'",
"import { SubmitButton } from 'lp-components'",
"",
"const propTypes = {",
"\thandleSubmit: PropTypes.func.isRequired,",
"}",
"const defaultProps = {}",
"",
"const BASE_INITIAL_VALUES = {",
"}",
chawes13 marked this conversation as resolved.
Show resolved Hide resolved
"const VALIDATION_SCHEMA = Yup.object({",
"})",
"",
"function ${1:MyFormComponent} ({ handleSubmit }) {",
"\treturn (",
"\t\t<Formik",
"\t\t\tinitialValues={BASE_INITIAL_VALUES}",
"\t\t\tvalidationSchema={VALIDATION_SCHEMA}",
"\t\t\tonSubmit={handleSubmit}",
"\t\t>",
"\t\t\t{({ isSubmitting }) => (",
"\t\t\t\t<Form>",
"\t\t\t\t\t$0",
"\t\t\t\t\t<SubmitButton submitting={isSubmitting}>",
"\t\t\t\t\t\tSubmit",
"\t\t\t\t\t</SubmitButton>",
"\t\t\t\t</Form>",
"\t\t\t)}",
"\t\t</Formik>",
"\t)",
"}",
"",
"${1:MyFormComponent}.propTypes = propTypes",
"${1:MyFormComponent}.defaultProps = defaultProps",
"",
"export default ${1:MyFormComponent}",
],
"description": "Formik-based form component"
}
}
```