From 935fc71c35db0cf27943acd34fceafc9dfee8e7a Mon Sep 17 00:00:00 2001 From: Narendra Shetty Date: Thu, 2 Jun 2016 23:04:27 +0530 Subject: [PATCH] added support for inline styles --- example/src/app.js | 12 ++++++++++++ src/Geosuggest.jsx | 3 +++ src/defaults.js | 7 ++++++- src/input.jsx | 1 + src/prop-types.js | 3 ++- src/suggest-item.jsx | 4 +++- src/suggest-list.jsx | 8 +++++--- 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/example/src/app.js b/example/src/app.js index bb313e54..8d5ff4ec 100644 --- a/example/src/app.js +++ b/example/src/app.js @@ -23,6 +23,18 @@ var App = React.createClass({ // eslint-disable-line onFocus={this.onFocus} onBlur={this.onBlur} onChange={this.onChange} + style={{ + 'input': { + 'borderColor': '#000' + }, + 'suggests': { + 'borderColor': '#000' + }, + 'suggestItem': { + 'borderColor': '#000', + 'borderWidth': 1 + } + }} onSuggestSelect={this.onSuggestSelect} location={new google.maps.LatLng(53.558572, 9.9278215)} radius="20" /> diff --git a/src/Geosuggest.jsx b/src/Geosuggest.jsx index 668f1107..2da27096 100644 --- a/src/Geosuggest.jsx +++ b/src/Geosuggest.jsx @@ -322,11 +322,14 @@ class Geosuggest extends React.Component { onChange={this.onInputChange.bind(this)} onFocus={this.onInputFocus.bind(this)} onBlur={this.onInputBlur.bind(this)} + style={this.props.style.input} onNext={() => this.activateSuggest('next')} onPrev={() => this.activateSuggest('prev')} onSelect={() => this.selectSuggest(this.state.activeSuggest)} onEscape={this.hideSuggests.bind(this)} {...attributes} />, suggestionsList = this.setState({ignoreBlur: true})} diff --git a/src/defaults.js b/src/defaults.js index 9954ce70..15c67236 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -21,5 +21,10 @@ export default { onChange: () => {}, skipSuggest: () => {}, getSuggestLabel: suggest => suggest.description, - autoActivateFirstSuggest: false + autoActivateFirstSuggest: false, + style: { + 'input': {}, + 'suggests': {}, + 'suggestItem': {} + } }; diff --git a/src/input.jsx b/src/input.jsx index 17f179e1..fff2151e 100644 --- a/src/input.jsx +++ b/src/input.jsx @@ -69,6 +69,7 @@ class Input extends React.Component { autoComplete='off' {...attributes} value={this.props.value} + style={this.props.style} onKeyDown={this.onInputKeyDown.bind(this)} onChange={this.onChange.bind(this)} onFocus={this.props.onFocus.bind(this)} diff --git a/src/prop-types.js b/src/prop-types.js index 5aa3bc28..e7aa35ba 100644 --- a/src/prop-types.js +++ b/src/prop-types.js @@ -25,5 +25,6 @@ export default { onChange: React.PropTypes.func, skipSuggest: React.PropTypes.func, getSuggestLabel: React.PropTypes.func, - autoActivateFirstSuggest: React.PropTypes.bool + autoActivateFirstSuggest: React.PropTypes.bool, + style: React.PropTypes.object }; diff --git a/src/suggest-item.jsx b/src/suggest-item.jsx index 7713df01..68bde86b 100644 --- a/src/suggest-item.jsx +++ b/src/suggest-item.jsx @@ -12,7 +12,8 @@ export default ({ suggest = {}, onMouseDown = () => {}, onMouseOut = () => {}, - onSelect = () => {} + onSelect = () => {}, + style = {} }) => { const classes = classnames( 'geosuggest-item', @@ -21,6 +22,7 @@ export default ({ ); return
  • { diff --git a/src/suggest-list.jsx b/src/suggest-list.jsx index 98bb2d77..a36490dc 100644 --- a/src/suggest-list.jsx +++ b/src/suggest-list.jsx @@ -13,14 +13,15 @@ export default ({ activeSuggest, onSuggestMouseDown = () => {}, onSuggestMouseOut = () => {}, - onSuggestSelect = () => {} + onSuggestSelect = () => {}, + style = {}, + suggestItemStyle = {} }) => { const classes = classnames( 'geosuggest__suggests', {'geosuggest__suggests--hidden': isHidden} ); - - return
      + return
        {suggests.map(suggest => { const isActive = activeSuggest && suggest.placeId === activeSuggest.placeId; @@ -28,6 +29,7 @@ export default ({ return