Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 26e25d6

Browse files
author
Greg Rickaby
authored
Merge pull request #99 from WebDevStudios/feature/forms-doc-block-cleanup
Feature/forms doc block cleanup
2 parents 5d4af7e + 285c711 commit 26e25d6

File tree

10 files changed

+46
-28
lines changed

10 files changed

+46
-28
lines changed

components/atoms/Inputs/Checkbox/Checkbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Field} from 'formik'
44
/**
55
* Render Checkbox component.
66
*
7-
* @param {object} props Input props.
7+
* @param {object} props The component attributes as props.
88
* @param {string} props.className Input className.
99
* @param {string|number} props.id Input id.
1010
* @param {string} props.label Input label.

components/atoms/Inputs/CheckboxGroup/CheckboxGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Checkbox from '@/components/atoms/Inputs/Checkbox'
55
/**
66
* Render CheckboxGroup component.
77
*
8-
* @param {object} props CheckboxGroup props.
8+
* @param {object} props The component attributes as props.
99
* @param {Array} props.checkboxes Array of checkbox data objects.
1010
* @param {string} props.className CheckboxGroup wrapper className.
1111
* @param {string|number} props.id CheckboxGroup id.

components/atoms/Inputs/Text/Text.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import PropTypes from 'prop-types'
22
import {Field, ErrorMessage} from 'formik'
33

4+
/**
5+
* Render the Text component.
6+
*
7+
* @author WebDevStudios
8+
* @param {object} props The component attributes as props.
9+
* @param {string} props.className Text wrapper className.
10+
* @param {string} props.description Text description.
11+
* @param {string} props.id Text input id.
12+
* @param {string} props.label Text input label.
13+
* @param {boolean} props.isRequired If input is required.
14+
* @param {string} props.type Text input type.
15+
* @return {Element} The Text component.
16+
*/
417
export default function Text({
518
className,
619
description,
720
id,
821
isRequired,
922
label,
10-
type,
11-
validation
23+
type
1224
}) {
1325
return (
14-
<div className={className} key={id}>
26+
<div className={className}>
1527
{label && <label htmlFor={id}>{label}</label>}
1628
<Field
1729
aria-required={isRequired}
1830
id={id}
1931
name={id}
2032
required={isRequired}
2133
type={type}
22-
validate={validation}
2334
/>
2435
{description && <p>{description}</p>}
2536
<ErrorMessage name={id} />
@@ -33,8 +44,7 @@ Text.propTypes = {
3344
id: PropTypes.string.isRequired,
3445
isRequired: PropTypes.bool,
3546
label: PropTypes.string.isRequired,
36-
type: PropTypes.string.isRequired,
37-
validation: PropTypes.func
47+
type: PropTypes.string.isRequired
3848
}
3949

4050
Text.defaultProps = {

components/molecules/Form/Form.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import styles from './Form.module.css'
44
import PropTypes from 'prop-types'
55
import cn from 'classnames'
66

7-
// TODO Update form title with dynamic heading tag.
8-
7+
/**
8+
* Render Form component.
9+
*
10+
* @param {object} props The component attributes as props.
11+
* @param {Element} props.children Form children elements.
12+
* @param {string} props.className Form wrapper class.
13+
* @param {object} props.formDefaults Formik default data.
14+
* @param {string|number} props.id Form id.
15+
* @param {object} props.validationSchema Yup validation schema object.
16+
* @return {Element} The Form component.
17+
*/
918
export default function Form({
10-
className,
1119
children,
12-
id,
20+
className,
1321
formDefaults,
14-
title,
22+
id,
1523
validationSchema
1624
}) {
1725
return (
@@ -26,7 +34,6 @@ export default function Form({
2634
}}
2735
>
2836
<FormikForm id={id} className={cn(styles.form, className)}>
29-
{title && <h1 className={styles.title}>{title}</h1>}
3037
{children}
3138
<button type="submit">Submit</button>
3239
</FormikForm>
@@ -35,11 +42,10 @@ export default function Form({
3542
}
3643

3744
Form.propTypes = {
38-
className: PropTypes.string,
3945
children: PropTypes.object,
40-
id: PropTypes.string,
46+
className: PropTypes.string,
4147
formDefaults: PropTypes.object,
42-
title: PropTypes.string,
48+
id: PropTypes.string,
4349
validationSchema: PropTypes.object
4450
}
4551

components/molecules/GravityForm/Fields/Checkbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Input from '@/components/atoms/Inputs'
66
/**
77
* Render GravityForms Checkbox field component.
88
*
9-
* @param {object} props GravityForm Checkbox field props.
9+
* @param {object} props GravityForm Checkbox field as props.
1010
* @param {string} props.className GravityForm field wrapper class.
1111
* @param {string} props.description GravityForm field description.
1212
* @param {Array} props.inputs Array of checkbox field input data.

components/molecules/GravityForm/Fields/Select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import * as Input from '@/components/atoms/Inputs'
44
import cn from 'classnames'
55

66
/**
7-
* Render GravityForms Checkbox field component.
7+
* Render GravityForms Select field component.
88
*
9-
* @param {object} props GravityForm Checkbox field props.
9+
* @param {object} props GravityForm Select field as props.
1010
* @param {string} props.className GravityForm field wrapper class.
1111
* @param {string} props.description GravityForm field description.
1212
* @param {string|number} props.id GravityForm field id.
@@ -15,7 +15,7 @@ import cn from 'classnames'
1515
* @param {string} props.size GravityForm field size.
1616
* @param {Array} props.selectChoices GravityForm field selection options.
1717
* @param {boolean} props.visibility GravityForm field visibility.
18-
* @return {Element} The Checkbox component.
18+
* @return {Element} The Select component.
1919
*/
2020
export default function Select({
2121
className,

components/molecules/GravityForm/GravityForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export default function GravityForm({
5959
className={cn(styles.gravityForm, cssClass)}
6060
formDefaults={fieldDefaults}
6161
id={formId && `gform-${formId}`}
62-
title={title}
6362
validationSchema={validationSchema}
6463
>
64+
{title && <h2>{title}</h2>}
6565
{fieldData && (
6666
<Fields fields={fieldData} setFormValidation={setFormValidation} />
6767
)}

functions/gravityForms/getGfFieldId.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* Create a field ID based on GravityForms provided ID.
33
*
4-
* @param {number} fieldId GravityForm field ID.
4+
* @author WebDevStudios
5+
* @param {number} fieldId GravityForm field ID.
56
* @return {string} A unique string identifer for the field.
67
*/
78
export default function getGfFieldId(fieldId) {

functions/gravityForms/getHiddenClassName.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* Determine hidden className.
33
*
4-
* @param {string} visibility setting of GravityForm field.
4+
* @author WebDevStudios
5+
* @param {string} visibility setting of GravityForm field.
56
* @return {string} Classname selector based on visibility.
67
*/
78
export default function getGfHiddenClassName(visibility) {

functions/gravityForms/yupSchema/ArraySchemaFactory.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Yup from 'yup'
55
*
66
* @author WebDevStudios
77
* @see https://github.com/jquense/yup#array
8-
* @return {Object} Yup validationSchema Object.
8+
* @return {object} Yup validationSchema Object.
99
*/
1010
export default class ArraySchemaFactory {
1111
/**
@@ -14,7 +14,7 @@ export default class ArraySchemaFactory {
1414
* Note: wp-graphql-gravity-forms plugin may need to be replaced.
1515
*
1616
* @see https://github.com/harness-software/wp-graphql-gravity-forms
17-
* @param {Object} fieldData from GravityForm GraphQL data Object.
17+
* @param {object} fieldData from GravityForm GraphQL data Object.
1818
*/
1919
constructor(fieldData) {
2020
this.fieldData = fieldData
@@ -26,7 +26,7 @@ export default class ArraySchemaFactory {
2626
* Combine multiple schemas into one.
2727
*
2828
* @see https://github.com/jquense/yup#mixedconcatschema-schema-schema
29-
* @return {Object} Combined Yup validationSchema Object.
29+
* @return {object} Combined Yup validationSchema Object.
3030
*/
3131
get schema() {
3232
return Yup.array().concat(this.getMinLengthSchema())
@@ -36,7 +36,7 @@ export default class ArraySchemaFactory {
3636
* Set a minimum length limit for the array.
3737
*
3838
* @see https://github.com/jquense/yup#arrayminlimit-number--ref-message-string--function-schema
39-
* @return {Object} Yup validationSchema Object.
39+
* @return {object} Yup validationSchema Object.
4040
*/
4141
getMinLengthSchema() {
4242
if (!this.fieldData?.isRequired) {

0 commit comments

Comments
 (0)