I am using Polymer 1.8 (a starter template). I want to know how to create a custom search filter element, for example at https://codelabs.developers.google.com/
Desired Result:
As you can see, it filters out the cards below it, with each keystroke typed in the search bar, leaving only the cards containing the desired search words.
I would like to find words in both:
- heading
<paper-card>(text in heading) - and in internal
divs(description <paper-card>)
The only examples of the search box found are this page from 2015 and on this page the Polymer Elements Catalog , which uses a similar search box, but I could not adapt them to my custom elements.
Here's the my-preview-cardscustom element:
It contains the cards themselves:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="shared-styles.html">
<dom-module id="my-preview-cards">
<template>
<style>
:host {
display: inline-block;
}
</style>
<div>
<paper-card heading="Color picture" image="http://lorempixel.com/300/200">
<div class="card-content">An RGB picture</div>
<div class="card-actions">
<paper-button>Button</paper-button>
</div>
</paper-card>
<paper-card heading="Grey image" image="http://lorempixel.com/g/300/200">
<div class="card-content">That a grey picture</div>
<div class="card-actions">
<paper-button>Button</paper-button>
</div>
</paper-card>
</div>
</template>
<script>
Polymer({
is: 'my-preview-cards',
});
</script>
</dom-module>
I created a separate user element my-search-barfor the search bar:
It contains a search string:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="shared-styles.html">
<dom-module id="my-search-bar">
<template>
<style>
:host {
display: inline-block;
}
</style>
<form on-submit="performSearch" class="flex">
<paper-input id="query" value="{{query::keyup}}" type="search" placeholder="search"></paper-input>
</form>
</template>
<script>
Polymer({
is: 'my-search-bar',
});
</script>
</dom-module>
Both custom items are displayed on my-homepageas:
<div>
<my-search-bar></my-search-bar>
</div>
<div>...</div>
<div>
<my-preview-cards></my-preview-cards>
</div>
PS
I understand that this is a difficult question. As soon as I get 75 repressions, I will assign 50 points to this question, and those who provide a working solution will receive it.