Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
feat(autocompleteOptions): expose the autocompleteOptions
Browse files Browse the repository at this point in the history
This could be useful to set the debug flag to `true` without relying on
process.env.NODE_ENV.
  • Loading branch information
redox authored and vvo committed Jun 14, 2016
1 parent f480c78 commit 06c139c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion docs/source/bootstrap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ layout: bootstrap

<script>
places({
container: document.querySelector('#test')
container: document.querySelector('#test'),
autocompleteOptions: {
debug: true
}
});
</script>
11 changes: 11 additions & 0 deletions docs/source/partials/documentation.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ Type: **object**
Algolia [JavaScript API client options](https://github.com/algolia/algoliasearch-client-js#client-options).

This is an advanced option.
</td>
</tr>
<tr>
<td markdown="1">
<div class="api-entry" id="api-options-autocompleteOptions"><code>autocompleteOptions</code></div>

Type: **object**
</td>
<td markdown="1">
[autocomplete.js options](https://github.com/algolia/autocomplete.js#options) to configure the underlying
autocomplete.js instance.
</td>
</tr>
</tbody>
Expand Down
12 changes: 5 additions & 7 deletions src/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ import pinIcon from './icons/address.svg';
export default function places(options) {
const {
container,
style
style,
autocompleteOptions: userAutocompleteOptions = {}
} = options;

const placesInstance = new EventEmitter();

// https://github.com/algolia/autocomplete.js#options
const autocompleteOptions = {
autoselect: true,
hint: false,
cssClasses: {
root: 'algolia-places' + (style === false ? '-nostyle' : ''),
prefix: 'ap' + (style === false ? '-nostyle' : '')
}
},
debug: process.env.NODE_ENV === 'development' ? true : false,
...userAutocompleteOptions
};

if (process.env.NODE_ENV === 'development') {
autocompleteOptions.debug = true;
}

const autocompleteDataset = createAutocompleteDataset({
...options,
algoliasearch,
Expand Down

0 comments on commit 06c139c

Please sign in to comment.