Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation doesn't show how to enable half-stars, or how to hook to selection events #10

Closed
assafmuller opened this issue Aug 10, 2020 · 2 comments

Comments

@assafmuller
Copy link

It would be awesome if you could show a demo or document how to implement half stars. You package an image called half-star but I didn't see code support for half stars. Can you please clarify?

Additionally, how would I hook on to click events? Say, a user selected the 3rd stay, and I'd like to fire off a function when that happens. Can you please document how would one do that?

@brunodbo
Copy link

brunodbo commented Aug 24, 2020

I was looking for this as well, and it looks like half stars aren't supported - see #8.

My need for half stars was on the display side (i.e., displaying of averages of rating results, for 1-5 star ratings), and I was able to get it working like this (importing the library's SASS file into my own, and adding this):

// Support half stars when displaying rating results
#{sr(parent)} .#{sr(base-classname)}-stars.s15 > span:nth-child(-1n+1),
#{sr(parent)} .#{sr(base-classname)}-stars.s25 > span:nth-child(-1n+2),
#{sr(parent)} .#{sr(base-classname)}-stars.s35 > span:nth-child(-1n+3),
#{sr(parent)} .#{sr(base-classname)}-stars.s45 > span:nth-child(-1n+4) {
  background-image: sr(star-full);
}

#{sr(parent)} .#{sr(base-classname)}-stars.s5 > span:nth-child(1),
#{sr(parent)} .#{sr(base-classname)}-stars.s15 > span:nth-child(2),
#{sr(parent)} .#{sr(base-classname)}-stars.s25 > span:nth-child(3),
#{sr(parent)} .#{sr(base-classname)}-stars.s35 > span:nth-child(4),
#{sr(parent)} .#{sr(base-classname)}-stars.s45 > span:nth-child(5) {
  background-image: sr(star-half);
}

@pryley
Copy link
Owner

pryley commented Jan 23, 2021

Additionally, how would I hook on to click events? Say, a user selected the 3rd stay, and I'd like to fire off a function when that happens. Can you please document how would one do that?

Simply use the native change event on the SELECT element.

@pryley pryley closed this as completed Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants