From 6c602261dd26f8eebf8a4ebd32e0bed8a08522ef Mon Sep 17 00:00:00 2001 From: David Date: Fri, 11 Dec 2020 10:53:22 -0800 Subject: [PATCH] feat: update input group to have type dropdown --- docs/lib/examples/InputGroupButton.js | 46 ++++++++++++--------------- src/InputGroup.js | 7 ++++ src/__tests__/InputGroup.spec.js | 7 ++++ 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/docs/lib/examples/InputGroupButton.js b/docs/lib/examples/InputGroupButton.js index 13d42864b..0972f7ec1 100644 --- a/docs/lib/examples/InputGroupButton.js +++ b/docs/lib/examples/InputGroupButton.js @@ -24,34 +24,30 @@ const Example = (props) => {
- + - - - Button Dropdown - - - Header - Action - Another Action - - Another Action - - + + Button Dropdown + + + Header + Action + Another Action + + Another Action +
- - - - - - Header - Action - Another Action - - Another Action - - + + + + + Header + Action + Another Action + + Another Action + diff --git a/src/InputGroup.js b/src/InputGroup.js index f0a73d7e0..6d638ad94 100644 --- a/src/InputGroup.js +++ b/src/InputGroup.js @@ -2,9 +2,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { mapToCssModules, tagPropType } from './utils'; +import Dropdown from './Dropdown'; const propTypes = { tag: tagPropType, + type: PropTypes.bool, size: PropTypes.string, className: PropTypes.string, cssModule: PropTypes.object, @@ -19,6 +21,7 @@ const InputGroup = (props) => { className, cssModule, tag: Tag, + type, size, ...attributes } = props; @@ -28,6 +31,10 @@ const InputGroup = (props) => { size ? `input-group-${size}` : null ), cssModule); + if (props.type === 'dropdown') { + return + } + return ( ); diff --git a/src/__tests__/InputGroup.spec.js b/src/__tests__/InputGroup.spec.js index 281fae8ba..78b26cba7 100644 --- a/src/__tests__/InputGroup.spec.js +++ b/src/__tests__/InputGroup.spec.js @@ -1,6 +1,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { InputGroup } from '../'; +import Dropdown from '../Dropdown'; describe('InputGroup', () => { it('should render with "div" tag', () => { @@ -39,4 +40,10 @@ describe('InputGroup', () => { expect(wrapper.type()).toBe('main'); }); + + it('should render Dropdown when type is dropdown', () => { + const wrapper = shallow(); + + expect(wrapper.type()).toBe(Dropdown); + }); });