A Polymer element for searching Google Books.
This is not an official Google web component. You can find those here.
Alternatively you can follow this link to load a "bundled" version. polymer-bundler (formerly called vulcanize) is a tool provided by the Polymer folks, and it "recursively pulls in all your imports, flattens their dependencies and spits out something that can potentially reduce the number of network requests your app makes." In other words: it should help with performance.
This is a pretty simple element with minimal styling.
For better performance I only request the fields from Google Books that are actually being displayed in the results. What's being returned is thus called a "partial response".
Hat tip to paranoida for pointing out ::-webkit-search-decoration
to me.
I also created a "reactive version" of this element using React and ReactiveElements. You can find it in the reactive-element branch.
-
Clone the repository
-
Go to the project folder and use Bower to fetch the dependencies:
$ bower install
-
Import Web Components' polyfill:
<script src="path/to/webcomponents-lite.js"></script>
-
Import Custom Element:
<link rel="import" href="path/to/google-books-search.html">
-
Start using it!
<google-books-search></google-books-search>
To run it locally, use the Polymer CLI:
$ polymer serve
Then just navigate to the URL given by the CLI using any modern browser.
To run the tests you can navigate to the URL given by the CLI (see above) followed by "/test", or use the Polymer CLI:
$ polymer test
Attribute | Options | Default | Description |
---|---|---|---|
query |
string | `` | The text to query for. |
max-results |
integer | 5 | The max number of results to return. |
order-by |
relevance, newest | relevance |
The parameter to order the results by. |
subtitle-max-length |
integer | 75 | The max number of characters of the subtitle to be displayed. |
snippet-max-length |
integer | 250 | The max number of characters of the text snippets to be displayed. |
Event | Description |
---|---|
google-books-search-success |
Triggers when search results were received successfully. |
google-books-search-error |
Triggers when something with the search goes wrong. |
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
For detailed changelog, check Releases.