Unlock the full power of the Amazon autocompletion engine right into your search input. JavaScript Plugin.
Unlock the full power of the Amazon autocompletion engine right into your search input. JavaScript Plugin.
AmazonAutocomplete is a vanilla JavaScript plugin to unlock the full power of the Amazon autocompletion engine right into your search input.
Demo: http://carlosroso.com/amazon-autocomplete
Tiny footprint (
...
## Usage
Create a text input in your html file for the search field.
```html
Edit your main JavaScript file to create an AmazonAutocomplete instance with your search field CSS selector.
let searchInput = new AmazonAutocomplete('#search-input');Now you got a search field on steroids. Go ahead and apply some styles to make it shine.
This is a pretty lightweight JavaScript library so it applies just a few styles to some elements to make it work. You can apply your own styles and customize the look of all the components within the widget. If you’re not that much into CSS, you can grab the following snippet and safely shot it into your stylesheet to get a decent default look. As you can see, AmazonAutocomplete goes all the way BEM.
/* Words container */
.ac__inner{
background: #f6f6f6;
}
/* Individual word element */
.ac__word{
margin: 0;
padding: 5px;
}
/* Word prefix style. It’s the span containing the search keyword within the word. */
.ac__prefix{
font-weight: bold;
}
/* Style applied to each words while navigating through the list or on hover */
.ac__word--selected, .ac__word:hover{
background-color: #e3e3e3;
}
…
javascript
//Create the AmazonAutocomplete with our desired properties
let searchInput = new AmazonAutocomplete({
selector: '#search-input',
delay: 200,
showWords: false,
hideOnblur: false
});
//Log the selected word to the console
searchInput.onSelectedWord(word => console.log(`searching for ${word}...`));
//Populate your custom panel whenever there are new suggested words available
searchInput.onNewWords(words => words.forEach(word => addWordToCustomPanel(word)));AmazonAutocomplete is licensed under MIT licence.
No open issues yet, or sync has not completed.