Skip to content

Commit

Permalink
feat: add type to button
Browse files Browse the repository at this point in the history
  • Loading branch information
devharris7 committed Dec 13, 2020
1 parent 3e4775f commit 08cf476
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/Button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { expandDts } from '../../lib/utils';
import './styles.scss';

const Button = props => {
const { bsSize, bsStyle, children, className, disabled, dts, href, inverse, isLoading, size, target } = props;
const { bsSize, bsStyle, children, className, disabled, dts, href, inverse, isLoading, size, target, type } = props;
const baseClass = 'aui--button';
const classes = classNames(
baseClass,
Expand Down Expand Up @@ -49,6 +49,7 @@ const Button = props => {
data-testid="button-wrapper"
disabled={isLoading || disabled}
className={classes}
type={type}
{...expandDts(dts)}
{..._.omit(props, _.keys(adslotButtonPropTypes))}
>
Expand Down Expand Up @@ -83,6 +84,10 @@ const adslotButtonPropTypes = {
* PropTypes.oneOf(['small', 'large'])
*/
size: PropTypes.oneOf(['small', 'large']),
/**
* PropTypes.oneOf(['button', 'reset', 'submit'])
*/
type: PropTypes.oneOf(['button', 'reset', 'submit']),
};

Button.propTypes = { ...adslotButtonPropTypes };
Expand All @@ -93,6 +98,7 @@ Button.defaultProps = {
size: 'small',
bsStyle: 'default',
target: '_self',
type: 'button',
};

export default Button;
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports[`<ConfirmModal /> should show modal when \`show\` is true 1`] = `
class="aui--button btn-primary"
data-test-selector="confirm-modal-confirm"
data-testid="confirm-modal-confirm"
type="button"
>
<div
class="aui--button-children-container"
Expand Down
25 changes: 25 additions & 0 deletions www/containers/props.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,31 @@
"value": "'small'",
"computed": false
}
},
"type": {
"type": {
"name": "enum",
"value": [
{
"value": "'button'",
"computed": false
},
{
"value": "'reset'",
"computed": false
},
{
"value": "'submit'",
"computed": false
}
]
},
"required": false,
"description": "PropTypes.oneOf(['button', 'reset', 'submit'])",
"defaultValue": {
"value": "'button'",
"computed": false
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion www/examples/FilePicker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class FilePickerExample extends React.PureComponent {

render(
<div style={{ width: 400 }}>
<FilePickerExample />
<form>
<FilePickerExample />
</form>
</div>
);
```
Expand Down

0 comments on commit 08cf476

Please sign in to comment.