Skip to content

Commit b459f51

Browse files
committed
Add buttons to FormTemplate
1 parent 976b2a8 commit b459f51

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

packages/carbon-component-mapper/src/files/form-template.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4-
import { Form as CarbonForm } from 'carbon-components-react';
4+
import { Form as CarbonForm, Button as CarbonButton, ButtonSet } from 'carbon-components-react';
55

66
import FormTemplate from '@data-driven-forms/common/src/form-template';
77

8-
export const Button = ({ label, buttonType, ...props }) => <button {...props}>{label}</button>;
8+
export const Button = ({ label, buttonType, ...props }) => (
9+
<CarbonButton kind={buttonType === 'submit' ? 'primary' : 'secondary'} {...props}>
10+
{label}
11+
</CarbonButton>
12+
);
913

1014
Button.propTypes = {
1115
label: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
1216
buttonType: PropTypes.string
1317
};
1418

15-
export const ButtonGroup = ({ children, ...props }) => <div {...props}>{children}</div>;
19+
export const ButtonGroup = ({ children, ...props }) => <ButtonSet {...props}>{children}</ButtonSet>;
1620

1721
ButtonGroup.propTypes = {
1822
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
@@ -41,7 +45,15 @@ Form.propTypes = {
4145
};
4246

4347
const WrappedFormTemplate = (props) => (
44-
<FormTemplate FormWrapper={Form} Button={Button} ButtonGroup={ButtonGroup} Title={Title} Description={Description} {...props} />
48+
<FormTemplate
49+
FormWrapper={Form}
50+
Button={Button}
51+
ButtonGroup={ButtonGroup}
52+
Title={Title}
53+
Description={Description}
54+
buttonOrder={['cancel', 'reset', 'submit']}
55+
{...props}
56+
/>
4557
);
4658

4759
export default WrappedFormTemplate;

0 commit comments

Comments
 (0)