Skip to content

Commit

Permalink
feat(SuggestList/SuggestItem): Allow adding custom classes to the sug…
Browse files Browse the repository at this point in the history
…gest list and suggest item
  • Loading branch information
karanjthakkar committed Jan 10, 2017
1 parent 056c3a1 commit ed69df6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -229,12 +229,24 @@ Default: `null`

If the `label` and a `id` prop (see "Others") were supplied, a `<label>` tag with the passed label text will be rendered. The `<label>` element's `for` attribute will correctly point to the `id` of the `<input>` element.

#### suggestsClassName
Type: `String`
Default: `''`

Add an additional class to suggest list.

#### suggestsHiddenClassName
Type: `String`
Default: `null`

Additional `className` to toggle as the list of suggestions changes visibility.

#### suggestItemClassName
Type: `String`
Default: `''`

Add an additional class to suggest item.

#### suggestItemActiveClassName
Type: `String`,
Default: `null`
Expand Down
2 changes: 2 additions & 0 deletions src/Geosuggest.jsx
Expand Up @@ -404,6 +404,8 @@ class Geosuggest extends React.Component {
suggestionsList = <SuggestList isHidden={this.state.isSuggestsHidden}
style={this.props.style.suggests}
suggestItemStyle={this.props.style.suggestItem}
suggestsClassName={this.props.suggestsClassName}
suggestItemClassName={this.props.suggestItemClassName}
suggests={this.state.suggests}
hiddenClassName={this.props.suggestsHiddenClassName}
suggestItemActiveClassName={this.props.suggestItemActiveClassName}
Expand Down
2 changes: 2 additions & 0 deletions src/prop-types.js
Expand Up @@ -10,7 +10,9 @@ export default {
disabled: React.PropTypes.bool,
className: React.PropTypes.string,
inputClassName: React.PropTypes.string,
suggestsClassName: React.PropTypes.string,
suggestsHiddenClassName: React.PropTypes.string,
suggestItemClassName: React.PropTypes.string,
suggestItemActiveClassName: React.PropTypes.string,
location: React.PropTypes.object,
radius: React.PropTypes.oneOfType([
Expand Down
1 change: 1 addition & 0 deletions src/suggest-item.jsx
Expand Up @@ -35,6 +35,7 @@ export default class SuggestItem extends React.Component {
const classes = classnames(
'geosuggest__item',
this.props.className,
this.props.suggestItemClassName,
{'geosuggest__item--active': this.props.isActive},
{[this.props.activeClassname]: this.props.activeClassname ?
this.props.isActive : null}
Expand Down
2 changes: 2 additions & 0 deletions src/suggest-list.jsx
Expand Up @@ -46,6 +46,7 @@ export default class SuggestList extends React.Component {
render() {
const classes = classnames(
'geosuggest__suggests',
this.props.suggestsClassName,
{'geosuggest__suggests--hidden': this.isHidden()},
{[this.props.hiddenClassName]: this.props.hiddenClassName ?
this.isHidden() : null}
Expand All @@ -60,6 +61,7 @@ export default class SuggestList extends React.Component {
className={suggest.className}
suggest={suggest}
style={this.props.suggestItemStyle}
suggestItemClassName={this.props.suggestItemClassName}
isActive={isActive}
activeClassname={this.props.suggestItemActiveClassName}
onMouseDown={this.props.onSuggestMouseDown}
Expand Down

0 comments on commit ed69df6

Please sign in to comment.