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

Add button field type #20

Merged
merged 3 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
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