Giter Club home page Giter Club logo

paper-dropdown-input's Introduction

paper-dropdown-input

A paper-input that provides the user with input suggestions

Demo and API Docs

Examples

Basic input

    <paper-dropdown-input label="Your favorite dinosaur"
                          items='["Velociraptor","Deinonychus","Allosaurus","Brontosaurus","Carcharodontosaurus","Diplodocus","T-Rex"]'>
    </paper-dropdown-input>

Basic input demo

Custom template

complexItems is an array of objects of the form:

{
  "value": "Deinonychus",
  "type": "carnivore"
}
<paper-dropdown-input label="Your favorite dinosaur" items='[[complexItems]]'>
  <template>
    <p disabled>Carnivores</p>
    <template is="dom-repeat" items="[[_getCarnivores(items)]]" as="item">
      <paper-item>[[item.value]]</paper-item>
    </template>
    <hr disabled>
    <p disabled>Herbivores</p>
    <template is="dom-repeat" items="[[_getHerbivores(items)]]" as="item">
      <paper-item>[[item.value]]</paper-item>
    </template>
  </template>
</paper-dropdown-input>

Custom template demo

Completely custom template

complexItems is an array of objects of the form:

{
  "dinoName": "Deinonychus",
  "avatar": "deinonychus.png",
  "type": "carnivore",
  "description": "Deinonychus is a genus of carnivorous dromaeosaurid coelurosaurian dinosaurs, with one described species, Deinonychus antirrhopus. This species, which could grow up to 3.4 metres (11 ft) long, lived during the early Cretaceous Period, about 115โ€“108 million years ago (from the mid-Aptian to early Albian stages). Fossils have been recovered from the U.S. states of Montana, Utah, Wyoming, and Oklahoma, in rocks of the Cloverly Formation, Cedar Mountain Formation and Antlers Formation, though teeth that may belong to Deinonychus have been found much farther east in Maryland."
}

Notice the absence of the value property in the object. The name of the property to filter on in objects can be set using filterProperty.

    <paper-dropdown-input label="Your favorite dinosaur"
                          items='[[complexItems]]'
                          filter-property="dinoName">
      <template>
        <template is="dom-repeat" items="[[items]]" as="item">
          <dinosaur-card data="[[item]]"></dinosaur-card>
        </template>
      </template>
    </paper-dropdown-input>

    <dom-module id="dinosaur-card">
      <template>
        <style>/* ... */</style>

        <div horizontal layout>
          <img src="[[data.avatar]]" alt="[[data.name]]" />
          <div>
            <h3>[[data.value]]</h3>
            <p>[[data.description]]</p>
          </div>
        </div>

      </template>
      <script>
        Polymer({
          is: 'dinosaur-card',
          properties: {
            data: Object,
            label: {
              type: String,
              computed: "_getLabel(data)"
            }
          },
          listeners: {
            "tap": "dinotap"
          },
          dinotap: function(event) {
            event.stopPropagation();
            this.fire('iron-select', {item: this});
          },
          _getLabel: function(data) {
            return data.dinoName;
          }
        });
      </script>
    </dom-module>

Completely custom template demo

Styling

The items in the dropdown list reside in the light DOM, so you are free to style them however you like.

Additionaly, paper-dropdown-input implements the same styling as paper-dropdown-menu.

paper-dropdown-input's People

Contributors

azariah001 avatar juravenator avatar lecogiteur avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.