Skip to content

Commit

Permalink
Merge pull request #411 from appfolio/correctHMFRow
Browse files Browse the repository at this point in the history
gt -  Add className to HMFRow
  • Loading branch information
gthomas-appfolio authored May 30, 2018
2 parents d314c13 + 8fb1e08 commit 13128ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/components/HasManyFieldsRow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import * as React from 'react';

interface HasManyFieldsRowProps {
children: (JSX.Element | string) | (JSX.Element | string)[];
className?: string;
onDelete?: React.MouseEventHandler<any>;
disabled?: boolean;
disabledReason: (JSX.Element | string) | (JSX.Element | string)[];
disabledReasonPlacement: string;
disabledReason?: (JSX.Element | string) | (JSX.Element | string)[];
disabledReasonPlacement?: string;
}
declare class HasManyFieldsRow extends React.Component<HasManyFieldsRowProps, {}> { }
export default HasManyFieldsRow;
6 changes: 5 additions & 1 deletion src/components/HasManyFieldsRow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import noop from 'lodash.noop';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import React from 'react';
import Button from './Button';
import ConfirmationButton from './ConfirmationButton';
Expand All @@ -17,6 +18,7 @@ function getID() {
export default class HasManyFieldsRow extends React.Component {
static propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
disabled: PropTypes.bool,
disabledReason: PropTypes.node,
disabledReasonPlacement: PropTypes.string,
Expand All @@ -36,15 +38,17 @@ export default class HasManyFieldsRow extends React.Component {
render() {
const {
children,
className,
disabledReason,
onDelete,
disabled,
disabledReasonPlacement
} = this.props;

const classNames = classnames('mb-3', className);
// The `disabled ? <Button> : <ConfirmationButton>` code works around Tooltips not show on `disabled` elements:
return (
<Row className="mb-3" noGutters>
<Row className={classNames} noGutters>
<Col>{children}</Col>
<Col xs="auto" className="pl-3 d-flex">
{disabled ? (
Expand Down
12 changes: 6 additions & 6 deletions stories/HasManyFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const items = [
];

storiesOf('HasManyFields', module)
.addWithInfo('Row Wrapper', () =>
.addWithInfo('Row Wrapper', () => (
<HasManyFieldsRow
onDelete={action('onDelete')}
disabled={boolean('disabled', false)}
Expand All @@ -32,13 +32,13 @@ storiesOf('HasManyFields', module)
defaultValue="I can put an input (or whatever else) inside a HasManyFieldsRow"
/>
</HasManyFieldsRow>
)
.addWithInfo('Add Item Button', () =>
))
.addWithInfo('Add Item Button', () => (
<HasManyFieldsAdd onClick={action('onClick')}>
Button Label Content
</HasManyFieldsAdd>
)
.addWithInfo('Full Example', () =>
))
.addWithInfo('Full Example', () => (
<HasManyFields
defaultValue={items}
template={AddressInput}
Expand All @@ -50,4 +50,4 @@ storiesOf('HasManyFields', module)
onUpdate={action('hasManyFields onUpdate')}
onChange={action('hasManyFields onChange')}
/>
);
));

0 comments on commit 13128ad

Please sign in to comment.