Skip to content

Commit

Permalink
[changed] dropdown props are passed through to the dropdown Button
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 16, 2015
1 parent f97afcc commit 21cab20
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
21 changes: 16 additions & 5 deletions src/DropdownButton.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import React from 'react';
import Dropdown from './Dropdown';
import omit from 'lodash-compat/object/omit';
import pick from 'lodash-compat/object/pick';
import Button from './Button';

class DropdownButton extends React.Component {

render() {
let { title, ...props } = this.props;
let { bsStyle, bsSize, disabled } = this.props;
let { title, children, ...props } = this.props;

let toggleProps = omit(props, Dropdown.ControlledComponent.propTypes);
let dropdownProps = pick(props, Object.keys(Dropdown.ControlledComponent.propTypes));
let toggleProps = omit(props, Object.keys(Dropdown.ControlledComponent.propTypes));

return (
<Dropdown {...props}>
<Dropdown.Toggle {...toggleProps}>
<Dropdown {...dropdownProps}
bsSize={bsSize}
bsStyle={bsStyle}
>
<Dropdown.Toggle
{...toggleProps}
disabled={disabled}
>
{title}
</Dropdown.Toggle>
<Dropdown.Menu>
{this.props.children}
{children}
</Dropdown.Menu>
</Dropdown>
);
}
}

DropdownButton.propTypes = {
disabled: React.PropTypes.bool,
bsStyle: Button.propTypes.bsStyle,
bsSize: Button.propTypes.bsSize,

Expand All @@ -37,6 +47,7 @@ DropdownButton.propTypes = {
};

DropdownButton.defaultProps = {
disabled: false,
pullRight: false,
dropup: false,
navItem: false,
Expand Down
32 changes: 18 additions & 14 deletions src/SplitButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import Button from './Button';
import Dropdown from './Dropdown';
import SplitToggle from './SplitToggle';
import omit from 'lodash-compat/object/omit';
import pick from 'lodash-compat/object/pick';

class SplitButton extends React.Component {

Expand All @@ -12,30 +14,32 @@ class SplitButton extends React.Component {
onClick,
target,
href,
bsSize,
bsStyle,
...props } = this.props;

let { disabled } = props;

let button = (
<Button
onClick={onClick}
bsStyle={bsStyle}
disabled={disabled}
target={target}
href={href}
>
{title}
</Button>
);
let dropdownProps = pick(props, Object.keys(Dropdown.ControlledComponent.propTypes));
let buttonProps = omit(props, Object.keys(Dropdown.ControlledComponent.propTypes));

return (
<Dropdown {...props}>
{button}

<Dropdown {...dropdownProps}>
<Button
{...buttonProps}
onClick={onClick}
bsStyle={bsStyle}
bsSize={bsSize}
disabled={disabled}
target={target}
href={href}
>
{title}
</Button>
<SplitToggle
aria-label={title}
bsStyle={bsStyle}
bsSize={bsSize}
disabled={disabled}
/>
<Dropdown.Menu>
Expand Down

0 comments on commit 21cab20

Please sign in to comment.