Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mmirus/gatsby-plugin-formol

Support Formol's webpack/Babel requirements on Gatsby
https://github.com/mmirus/gatsby-plugin-formol

form formol gatsby gatsby-plugin

Last synced: 1 day ago
JSON representation

Support Formol's webpack/Babel requirements on Gatsby

Awesome Lists containing this project

README

        

# gatsby-plugin-formol

Support Formol's webpack/Babel requirements on Gatsby

Learn more about Formol here: https://github.com/Kozea/formol

## Installing

Run:

`yarn add gatsby-plugin-formol formol date-fns@next`

`yarn add -D @babel/plugin-proposal-decorators babel-plugin-add-react-static-displayname`

## Using Formol

### Add to `gatsby-config.js`

```js
module.exports = {
plugins: [
`gatsby-plugin-formol`,
],
}
```

### Create your form

```js
import React from "react";
import Formol, { Field } from "formol";
import "formol/lib/default.css";

const handleSubmit = async values => {
console.log(values);

// process submission (e.g., send to API)...
};

const SignUpForm = () => (

First Name
Last Name

Email


patternMismatch && "Zip must be a five-digit number"
}
>
Zip


);

export default SignUpForm;
```

### Display it in a page

```js
import React from "react";
import { Link } from "gatsby";

import Layout from "../components/layout";
import SEO from "../components/seo";
import SignUpForm from "../components/SignUpForm";

const HomePage = () => (


Hi people


Welcome to your new Gatsby site.


Now go build something great.

Go to page 2

);

export default HomePage;
```