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

gt - Add className to HMFRow #411

Merged
merged 1 commit into from
May 30, 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
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')}
/>
);
));