Skip to content

Commit

Permalink
refactor(rename): Change one of the keys in classNames prop from cont…
Browse files Browse the repository at this point in the history
…ainer to root

This change is backward compatible: classNames.container is deprecated but is still supported in
this version.
  • Loading branch information
hibiken committed Jul 18, 2016
1 parent f4d47a8 commit 9af47bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ Type: `Object`,
Required: `false`

You can give a custom css classes to elements.
Accepted keys are `container`, `label`, `input`, `autocompleteContainer`
Accepted keys are `root`, `label`, `input`, `autocompleteContainer`

```js
// classNames example
render() {
const cssClasses = {
container: 'form-group',
root: 'form-group',
label: 'form-label',
input: 'form-control',
autocompleteContainer: 'my-autocomplete-container'
Expand Down
5 changes: 3 additions & 2 deletions src/PlacesAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,13 @@ class PlacesAutocomplete extends React.Component {
)
}

// TODO: remove `classNames.container` in the next version release.
render() {
const { classNames, placeholder, value } = this.props
return (
<div
style={defaultStyles.autocompleteContainer}
className={classNames.container || ''}
className={classNames.root || classNames.container || ''}
>
{this.renderLabel()}
<input
Expand All @@ -203,7 +204,7 @@ PlacesAutocomplete.propTypes = {
hideLabel: React.PropTypes.bool,
autocompleteItem: React.PropTypes.func,
classNames: React.PropTypes.shape({
container: React.PropTypes.string,
root: React.PropTypes.string,
label: React.PropTypes.string,
input: React.PropTypes.string,
autocompleteContainer: React.PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('autocomplete dropdown', () => {

describe('custom classNames, placeholder', () => {
const classNames = {
container: 'my-container',
root: 'my-container',
label: 'my-label',
input: 'my-input',
autocompleteContainer: 'my-autocomplete-container'
Expand Down

0 comments on commit 9af47bd

Please sign in to comment.