Coder Social home page Coder Social logo

link2twenty / l2t-paper-rating Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 38 KB

Polymer element to display "star" ratings in a paper style

Home Page: https://www.webcomponents.org/element/Link2Twenty/l2t-paper-rating

HTML 100.00%
rating star-rating web-components

l2t-paper-rating's Introduction

Published on webcomponents.org Published on Vaadin  Directory Stars on vaadin.com/directory

<l2t-paper-rating>

A polymer element to display "star" ratings in a paper style

Install with bower

First you need bower, see their site for details

bower install --save l2t-paper-rating

Examples

  <l2t-paper-rating></l2t-paper-rating> <br/>
  <l2t-paper-rating rating="2" readonly></l2t-paper-rating> <br/>
  <l2t-paper-rating rating="3" total="4"></l2t-paper-rating>

A11y/ARIA

For screen readers it's helpful to have a label though the traditional label element will not work with custom elements so we'll need to change the aria-label or aria-labelledby properties directly.

There are examples of both methods on the demo page.

Styling

The following custom properties are available for styling:

Custom property Description Default
--rating-icon-color The color of the icons --primary-text-color
--rating-icon-size The size of the icon (square) 28px
--rating-icon-padding The size of the padding between icons 2px
--rating-ink-color The color of the ripple on icon tap --primary-text-color
--rating-unselected-opacity The opacity of stars 'non-active' 0.4

Properties

Public

Attribute Name Functionality Type Default
icon the icon to use (iron-icons) String star
rating numbers of star selected (reflectToAttribute) Number 1
readonly can the rate be modified Boolean false
total maximum number of stars selectable Number 5

l2t-paper-rating's People

Contributors

link2twenty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

clowin

l2t-paper-rating's Issues

Unable to set no rating (rating eq 0)

I have a list of things and those things has a rating.
Items may not have rating at all. I would expect it to render 5 stars but without highlighting any star.
This visually confirms that the item do not have rating.\

Duplicate variable declaration

In l2t-paper-rating.html on line 275. e gets defined twice

_tapHandler(e) {
  if (this.readonly)
    return
  if (!e.path) {
    this.rating = e.currentTarget.getAttribute("value");
  } else {
    this.rating = e.path.find(function (e) {
      if (e.classList) {
        return e.classList.contains("icon-container")
      } else {
        return false
      }
    }).getAttribute("value");
  }
}

Half star

Need a way to indicate a non-integer ratings,
Half the star still transparent?
Only in readonly mode? (users should not be able to set non-integer ratings themselves)

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.