Skip to content

Commit

Permalink
feat(DropdownToggle - noCaret option): Adds the noCaret option (patte…
Browse files Browse the repository at this point in the history
…rnfly#893)

* feat(DropdownToggle - noCaret option): Adds the noCaret option

* IconComponent

* proptype

* lowercase

* reacttype
  • Loading branch information
jschuler authored and amarie401 committed Nov 8, 2018
1 parent 88d61cc commit 21e6e64
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface DropdownToggleProps extends HTMLProps<HTMLButtonElement> {
isFocused?: boolean;
isHovered?: boolean;
isActive?: boolean;
iconComponent?: ReactType;
}

declare const DropdownToggle: SFC<DropdownToggleProps>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Toggle from './Toggle';
import styles from '@patternfly/patternfly-next/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';

const DropdownToggle = ({ children, ...props }) => (
const DropdownToggle = ({ children, iconComponent: IconComponent, ...props }) => (
<Toggle {...props}>
{children}
<CaretDownIcon className={css(styles.dropdownToggleIcon)} />
{IconComponent && <IconComponent className={css(styles.dropdownToggleIcon)} />}
</Toggle>
);

Expand All @@ -30,7 +30,9 @@ DropdownToggle.propTypes = {
/** Forces hover state */
isHovered: PropTypes.bool,
/** Forces active state */
isActive: PropTypes.bool
isActive: PropTypes.bool,
/** The icon to display for the toggle. Defaults to CaretDownIcon. Set to null to not show an icon. */
iconComponent: PropTypes.func
};

DropdownToggle.defaultProps = {
Expand All @@ -41,7 +43,8 @@ DropdownToggle.defaultProps = {
isFocused: false,
isHovered: false,
isActive: false,
onToggle: Function.prototype
onToggle: Function.prototype,
iconComponent: CaretDownIcon
};

export default DropdownToggle;
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ exports[`dropdown basic 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -1365,6 +1366,7 @@ exports[`dropdown basic 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down Expand Up @@ -1536,6 +1538,7 @@ exports[`dropdown dropup + right aligned 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -1553,6 +1556,7 @@ exports[`dropdown dropup + right aligned 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down Expand Up @@ -1707,6 +1711,7 @@ exports[`dropdown dropup 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -1724,6 +1729,7 @@ exports[`dropdown dropup 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down Expand Up @@ -1906,6 +1912,7 @@ exports[`dropdown expanded 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -1923,6 +1930,7 @@ exports[`dropdown expanded 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down Expand Up @@ -2237,6 +2245,7 @@ exports[`dropdown regular 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -2254,6 +2263,7 @@ exports[`dropdown regular 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down Expand Up @@ -2408,6 +2418,7 @@ exports[`dropdown right aligned 1`] = `
toggle={
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand All @@ -2425,6 +2436,7 @@ exports[`dropdown right aligned 1`] = `
>
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`state active 1`] = `
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={true}
isFocused={false}
Expand Down Expand Up @@ -96,6 +97,7 @@ exports[`state focus 1`] = `
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={true}
Expand Down Expand Up @@ -170,6 +172,7 @@ exports[`state hover 1`] = `
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`Dropdown toggle 1`] = `
<DropdownToggle
className=""
iconComponent={[Function]}
id="Dropdown Toggle"
isActive={false}
isFocused={false}
Expand Down

0 comments on commit 21e6e64

Please sign in to comment.