Skip to content

Commit

Permalink
Merge pull request #20 from CalderaWP/master
Browse files Browse the repository at this point in the history
Add button field type #19
  • Loading branch information
Shelob9 authored Jul 26, 2018
2 parents 8282f37 + 5f805b8 commit 625b0e2
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 341 deletions.
1 change: 0 additions & 1 deletion src/components/RenderGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,5 @@ RenderGroup.classNames = {
fieldGroup: 'caldera-config-group',
fieldWrapper: 'caldera-config-field',
input: 'field-config',
button: 'caldera-config-button',

};
61 changes: 0 additions & 61 deletions src/components/__snapshots__/renderGroup.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,66 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The render group component Button fields inside render groups Button RenderGroup snapshots Renders a regular button 1`] = `
<div
className="caldera-config-field-setup"
>
<div
className="caldera-config-group"
>
<div
className="caldera-config-field"
>
<label
htmlFor="RendersARegularButtonSnapShotTest"
>
Submit
</label>
<button
aria-describedby={null}
className="field-config field-config caldera-config-button"
disabled={false}
id="RendersARegularButtonSnapShotTest"
onBlur={undefined}
onClick={[Function]}
onFocus={undefined}
/>
</div>
</div>
</div>
`;

exports[`The render group component Button fields inside render groups Button RenderGroup snapshots Renders a submit input 1`] = `
<div
className="caldera-config-field-setup"
>
<div
className="caldera-config-group"
>
<div
className="caldera-config-field"
>
<label
htmlFor="cf-button-example"
>
Submit
</label>
<input
aria-describedby={null}
className="field-config field-config caldera-config-button"
disabled={false}
id="cf-button-example"
onBlur={undefined}
onClick={[Function]}
onFocus={undefined}
required={undefined}
type="submit"
value={undefined}
/>
</div>
</div>
</div>
`;

exports[`The render group component Rendering with fields Does not error when passed empty array of fields 1`] = `
<div
className="caldera-config-field-setup"
Expand Down
86 changes: 35 additions & 51 deletions src/components/fields/FieldInner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {ariaDescribedbyAttr} from './util';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {RenderGroup} from '../RenderGroup';
import {Button} from "./button/Button";

/**
* Creates the field inside of a field group
*
Expand All @@ -33,58 +31,44 @@ export const FieldInner = (props) => {
*/
function inputClassName() {
return classNames([
props.fieldClassName,
RenderGroup.classNames.input
]
props.fieldClassName,
RenderGroup.classNames.input
]
);
}

switch (props.type) {
case 'select':
case 'dropdown':
const options = Array.isArray(props.options) ? props.options : [];
return (
<SelectField
id={props.id}
fieldClassName={inputClassName()}
ariaDescribedbyAttr={ariaIdAttr()}
value={props.value}
onValueChange={props.onValueChange}
inputType={props.inputType}
options={options}
disabled={props.disabled}
onBlur={props.onBlur}
onFocus={props.onFocus}
/>
);
case 'button' :
return (
<Button
onClick={props.onClick}
id={props.id}
fieldClassName={inputClassName()}
ariaDescribedbyAttr={ariaIdAttr()}
value={props.value}
inputType={props.inputType}
disabled={props.disabled}
onBlur={props.onBlur}
onFocus={props.onFocus}
/>
);
default:
case 'input':
return (
<Input
id={props.id}
fieldClassName={inputClassName()}
ariaDescribedbyAttr={ariaIdAttr()}
value={props.value}
onValueChange={props.onValueChange}
inputType={props.inputType}
disabled={props.disabled}
onBlur={props.onBlur}
onFocus={props.onFocus}
/>);
switch( props.type ){
case 'select':
case 'dropdown':
const options = Array.isArray(props.options) ? props.options : [];
return (
<SelectField
id={props.id}
fieldClassName={inputClassName()}
ariaDescribedbyAttr={ariaIdAttr()}
value={props.value}
onValueChange={props.onValueChange}
inputType={props.inputType}
options={options}
disabled={props.disabled}
onBlur={props.onBlur}
onFocus={props.onFocus}
/>
);
default:
case 'input':
return (
<Input
id={props.id}
fieldClassName={inputClassName()}
ariaDescribedbyAttr={ariaIdAttr()}
value={props.value}
onValueChange={props.onValueChange}
inputType={props.inputType}
disabled={props.disabled}
onBlur={props.onBlur}
onFocus={props.onFocus}
/>);
}

};
Expand Down
69 changes: 0 additions & 69 deletions src/components/fields/button/Button.js

This file was deleted.

108 changes: 0 additions & 108 deletions src/components/fields/button/Button.test.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/components/fields/button/__snapshots__/Button.test.js.snap

This file was deleted.

Loading

0 comments on commit 625b0e2

Please sign in to comment.