@whppt/form-builder
@whppt/form-builder
Whppt form builder modules for use with the nuxt framework, @whppt/nuxt and @whppt/api-express
Table of Contents
Features
- Simple Form creation and integration with core Whppt modules to easily build forms and send them via select services.
- Options for Build and Runtime configuration of the site key.
Installation
- Add
@whppt/form-builderdependency to your project
yarn add @whppt/form-builder # or npm install @whppt/form-builder
- Add
@whppt/form-builderto themodulessection ofnuxt.config.js
// ~/nuxt.config.js
{
modules: [
// Simple usage
'@whppt/form-builder',
// With options
[
'@whppt/form-builder',
{
// ... see options below: Setting up Google recaptcha
},
],
];
}
- Make a few updates to your
~/nuxt.config.jsfile.
// ~/nuxt.config.js
export default {
build: {
transpile: ['@whppt/form-builder'],
},
};
- Including the css (optional)
Out of the box we supply some standard styling which can be added to a nuxt project like so.
// ~/nuxt.config.js
export default {
css: [
'@whppt/form-builder/lib/styles/styles.css',
// any other styles you need go here
// if you want to override the default styles, you can include your own css file here
]
}
Usage
Adding in the API module
~/server/index.js
const express = require('express');
const Whppt = require('@whppt/api-express');
/* Import/require the api module from @whppt/form-builder */
const forms = require('@whppt/form-builder/lib/api');
/* Add the module to the options that will be passed to @whppt/api-express */
const options = {
modules: {
forms,
},
};
const app = express();
Whppt(options).then(whppt => app.use(whppt));
module.exports = app;
Registering the component with @whppt/nuxt
Inside any whppt plugin that you wish to use the form-builder component on add the following
/* Import/require the Form definition from @whppt/form-builder, this is a whppt component */
import { Form } from '@whppt/form-builder/lib/components';
export default {
name: 'MyPlugin',
pageType: {
name: 'my-plugin',
label: 'My Plugin',
collection: { name: 'my-plugin-collection' },
components: {
/* Register the Form definition to this plugin, this will now show up as a usable component on the template */
Form,
},
},
};
Setting up Google recaptcha - Build time config (Optional)
This module leverages vue-recaptcha for fast setup and working Google Recaptcha. Don't forget to star their repo on github as well!
- Add in the siteKey option where you register the module (see options for more info)
{
modules: {
['@whppt/form-builder', { recaptcha_sitekey: 'my-google-site-key' }];
}
}
- Add in the env variable
RECAPTCHA_SECRET(see options for more info)
RECAPTCHA_SECRET=MySuperSecretRecaptchaSecretForMyEyesOnly
Setting up Google recaptcha - Run time config (Optional)
This module leverages vue-recaptcha for fast setup and working Google Recaptcha. Don't forget to star their repo on github as well!
- Add in the siteKey option to public runtime config in nuxt.config.js
export default {
publicRuntimeConfig: {
recaptcha_sitekey: '<your public sitekey>',
},
};
- Add in the env variable
RECAPTCHA_SECRET(see options for more info)
RECAPTCHA_SECRET=MySuperSecretRecaptchaSecretForMyEyesOnly
Options
Module Options
| Option | default | Required | type | Description |
|---|---|---|---|---|
| recaptcha_sitekey | undefined | false | string | Google reCAPTCHA V2 sitekey, can be found/generated here. This is required to use the recaptcha field. |
Env Variables
| Option | default | Required | Description |
|---|---|---|---|
| RECAPTCHA_SECRET | undefined | false | Google reCAPTCHA V2 secret key, can be found/generated here. This is required to use the recaptcha field. |
License
Copyright (c) lucas info@sveltestudios.com
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 2.3.7 | ^2.6.14 | MIT | |
| 2.3.6 | ^2.6.14 | MIT | |
| 2.3.5 | ^2.6.14 | MIT | |
| 2.3.4 | ^2.6.14 | MIT | |
| 2.3.3 | ^2.6.14 | MIT | |
| 2.3.1 | ^2.6.14 | MIT | |
| 2.3.0 | ^2.6.14 | MIT | |
| 2.2.1 | ^2.6.14 | MIT | |
| 2.1.22 | ^2.6.14 | MIT | |
| 2.1.20 | ^2.6.14 | MIT | |
| 2.1.19 | ^2.6.14 | MIT | |
| 2.1.18 | ^2.6.14 | MIT | |
| 2.1.17 | ^2.6.14 | MIT | |
| 2.1.16 | ^2.6.14 | MIT | |
| 2.1.15 | ^2.6.14 | MIT | |
| 2.1.14 | ^2.6.14 | MIT | |
| 2.1.13 | ^2.6.14 | MIT | |
| 2.1.12 | ^2.6.14 | MIT | |
| 2.1.11 | ^2.6.14 | MIT | |
| 2.1.8 | ^2.0 | MIT | |
| 2.1.7 | ^2.0 | MIT | |
| 2.1.6 | ^2.0 | MIT | |
| 2.1.5 | ^2.0 | MIT | |
| 2.1.4 | ^2.0 | MIT | |
| 2.1.3 | ^2.0 | MIT | |
| 2.1.2 | ^2.0 | MIT | |
| 2.1.1 | ^2.0 | MIT | |
| 2.1.0 | ^2.0 | MIT | |
| 2.0.2 | ^2.0 | MIT | |
| 2.0.1 | ^2.0 | MIT |
Showing the latest 30 of 34. See every release on npm
Pre-releases (9)
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.0-rc9 | ^2.0 | MIT | |
| 1.0.0-rc8 | ^2.0 | MIT | |
| 1.0.0-rc7 | MIT | ||
| 1.0.0-rc6 | MIT | ||
| 1.0.0-rc5 | MIT | ||
| 1.0.0-rc4 | MIT | ||
| 1.0.0-rc3 | MIT | ||
| 1.0.0-rc2 | MIT | ||
| 1.0.0-rc1 | MIT |