Skip to content

Commit

Permalink
cleanup props
Browse files Browse the repository at this point in the history
  • Loading branch information
Torgeir Pedersen Cook committed Mar 17, 2017
1 parent 135e2a7 commit 08f23cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 16 additions & 2 deletions src/selectors/account-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ import AccountNoMatch from '../account/account-nomatch';
import AccountDetails from '../account/account-details';
import {Account, Locale} from '../util/types';
import {accountFilter} from '../filter/filters';
import classNames from 'classnames';

function AccountSelector(props) {
const {selectedAccount, locale, noMatches, onAccountSelected, accounts} = props;
const {
selectedAccount,
locale,
noMatches,
onAccountSelected,
accounts,
id,
className
} = props;
return (
<div className='account-selector'>
<div
className={classNames('account-selector', className)}
id={id}
>
<BaseSelector
renderSuggestion={(account) => <AccountSuggestionItem account={account} locale={locale}/>}
renderNoMatches={() => <AccountNoMatch value={noMatches}/>}
Expand All @@ -32,6 +44,8 @@ AccountSelector.propTypes = {
locale: Locale.isRequired,
selectedAccount: Account,
noMatches: PropTypes.string,
id: PropTypes.string,
className : PropTypes.string,
};

export default AccountSelector;
8 changes: 3 additions & 5 deletions src/selectors/base-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class BaseSelector extends Component {
value,
placeholder,
suggestionsHeightMax,
id,
ariaInvalid,
} = this.props;
const {showSuggestions, highlightedSuggestionIndex, suggestionListId} = this.state;
return (
Expand All @@ -195,15 +195,14 @@ class BaseSelector extends Component {
value={value}
onChange={this.onInputChange}
onReset={this.onInputResetClick}
resetLabel={''}
onKeyDown={this.onInputKeyDown}
isSuggestionsShowing={showSuggestions}
id={id}
placeholder={placeholder}
onBlur={this.onBlur}
onFocus={this.onFocus}
highlightedIndex={highlightedSuggestionIndex}
suggestionListId={suggestionListId}
ariaInvalid={ariaInvalid}
/>
{showSuggestions &&
<SuggestionsList
Expand Down Expand Up @@ -233,8 +232,8 @@ BaseSelector.propTypes = {
onBlur: PropTypes.func,
onReset: PropTypes.func,
onFocus: PropTypes.func,
id: PropTypes.string,
placeholder : PropTypes.string,
ariaInvalid : PropTypes.bool,
suggestionsHeightMax : PropTypes.number,
};

Expand All @@ -243,7 +242,6 @@ BaseSelector.defaultProps = {
onBlur: () => {},
onFocus: () => {},
onReset: () => {},
ariaInvalid: false,
placeholder : '',
};

Expand Down
4 changes: 1 addition & 3 deletions src/selectors/input-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Input extends Component {
placeholder,
isSuggestionsShowing,
ariaInvalid,
resetLabel,
onBlur,
onReset,
inputFieldRef,
Expand Down Expand Up @@ -42,7 +41,6 @@ class Input extends Component {
/>
{ value.length > 0 &&
<button
aria-label={ resetLabel }
className='reset-button'
onMouseDown={ onReset }
tabIndex={-1}
Expand All @@ -60,7 +58,6 @@ Input.propTypes = {
onChange: PropTypes.func.isRequired,
onKeyDown: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
resetLabel: PropTypes.string.isRequired,
onReset: PropTypes.func.isRequired,
isSuggestionsShowing: PropTypes.bool.isRequired,
id: PropTypes.string,
Expand All @@ -77,6 +74,7 @@ Input.defaultProps = {
onBlur: () => {},
onFocus: () => {},
inputFieldRef: () => {},
ariaInvalid : false,
};

export default Input;

0 comments on commit 08f23cb

Please sign in to comment.