Comments (5)
I used the Unicode for my implementation. Works great.
from starability.
@StudioJunkyard: can you link to your version if it happens to be open source?
from starability.
It's within the styling for LibreCMS, but I can give you the CSS
.rat{
display:inline-block;
unicode-bidi:bidi-override;
direction:rtl
}
.rat > span{
position:relative;
width:1em;
text-shadow:0 1px 1px #000
}
.rat > span.set,
.rat > span.set ~ span{
color:transparent
}
.rat > span.set:after,
.rat > span.set ~ span:after{
content:"\2605";
position:absolute;
left:0;
color:gold
}
.rating{
position:relative;
float:left
}
.rating:not(:checked) > input{
position:absolute;
top:-9999px;
clip:rect(0,0,0,0)
}
.rating:not(:checked) > label{
float:right;
width:1em;
padding:0 .1em;
overflow:hidden;
white-space:nowrap;
cursor:pointer;
font-size:150%;
line-height:1.2;
color:#ddd;
text-shadow:1px 1px #bbb, 2px 2px #666,.1em .1em .2em rgba(0,0,0,.5)
}
.rating:not(:checked) > label:before{
content:'★ '
}
.rating > input:checked ~ label{
color:#f70;
text-shadow:1px 1px #c60,2px 2px #940,.1em .1em .2em rgba(0,0,0,.5)
}
.rating:not(:checked) > label:hover,
.rating:not(:checked) > label:hover ~ label{
color:gold;
text-shadow:1px 1px goldenrod,2px 2px #B57340,.1em .1em .2em rgba(0,0,0,.5)
}
.rating > input:checked + label:hover,
.rating > input:checked + label:hover ~ label,
.rating > input:checked ~ label:hover,
.rating > input:checked ~ label:hover ~ label,
.rating > label:hover ~ input:checked ~ label{
color:#ea0;
text-shadow:1px 1px goldenrod,2px 2px #B57340,.1em .1em .2em rgba(0,0,0,.5)
}
.rating > label:active{
position:relative;
top:2px;
left:2px
}
.rating > label:after{
content:attr(data-title);
position:absolute;
display:block;
top:auto;
bottom:30px;
width:5px;
height:auto;
padding-left:7px;
color:#000;
font-size:10px;
font-weight:400;
text-shadow:0 0 0;
word-wrap:break-word
}
and the HTML for displaying with the interaction:
<span class="rat">
<span<?php if($rr['cid']==5)echo' class="set"';?>>☆</span>
<span<?php if($rr['cid']==4)echo' class="set"';?>>☆</span>
<span<?php if($rr['cid']==3)echo' class="set"';?>>☆</span>
<span<?php if($rr['cid']==2)echo' class="set"';?>>☆</span>
<span<?php if($rr['cid']==1)echo' class="set"';?>>☆</span>
</span>
And here's a front facing review form used from LibreCMS, there are tags that will be no good as they only pertain to the theme system in the CMS, but it should give you an idea on how to implement it.
<review>
<div id="review" class="list-group">
<form id="reviewform" target="review" class="list-group-item" method="post" action="core/add_review.php" role="form">
<input type="hidden" name="id" value="<print content=id>">
<input type="hidden" name="emailtrap" value="">
<h4 role="heading">Add a Review</h4>
<div class="form-group form-group-sm">
<label class="control-label col-xs-3"><small>Rating</small></label>
<div class="input-group col-xs-9 rating">
<input type="radio" id="star5" name="rating" value="5" checked>
<label for="star5" data-title="5" title="Awesome!">5 stars</label>
<input type="radio" id="star4" name="rating" value="4">
<label for="star4" data-title="4" title="Great!">4 stars</label>
<input type="radio" id="star3" name="rating" value="3">
<label for="star3" data-title="3" title="Meh!">3 stars</label>
<input type="radio" id="star2" name="rating" value="2">
<label for="star2" data-title="2" title="So So!">2 stars</label>
<input type="radio" id="star1" name="rating" value="1">
<label for="star1" data-title="1" title="Bad!">1 star</label>
</div>
</div>
<div class="form-group form-group-sm">
<label for="email" class="control-label col-xs-3"><small>Email</small></label>
<div class="input-group col-xs-9">
<input type="text" id="email" class="form-control input-sm" name="email" value="" required aria-required="true" role="textbox">
</div>
</div>
<div class="form-group form-group-sm">
<label for="name" class="control-label col-xs-3"><small>Name</small></label>
<div class="input-group col-xs-9">
<input type="text" id="name" class="form-control input-sm" name="name" value="" role="textbox">
</div>
</div>
<div class="form-group form-group-sm">
<label for="review" class="control-label col-xs-3"><small>Review</small></label>
<div class="input-group col-xs-9">
<textarea id="review" class="form-control input-sm" name="review" role="textbox"></textarea>
</div>
</div>
<div class="form-group form-group-sm">
<button type="submit" class="btn btn-success btn-block" role="button">Add Review</button>
</div>
</form>
</div>
<script>
$("#reviewform").submit(function(){
$.post($(this).attr("action"),$(this).serialize(),function(data){
$("#review").html(data);
});
return false;
});
</script>
</review>
from starability.
@dandv @StudioJunkyard I've changed external images to base64 encoded sprites. I tried changing sprites to separate encoded star images, but it could cause problems with backwards compatibility for people with starability-slot animation in use. It also added way too many kB of code. Thank you for your feedback and help. :)
Why base64? Inline SVG seemed hard to implement here, as I take advantage of pseudoelements. I like the look of the star graphics used in starability and Unicode characters are a bit different.
from starability.
Agreed, to have it compatible with unknown places where it could be used, is a bit of a best guess scenario.
from starability.
Related Issues (20)
- Rating starts with yellow stars instead of grey stars HOT 6
- Invisible input creates accessibility issue HOT 2
- Touch gesture support HOT 3
- Support for half stars HOT 6
- Star size HOT 3
- Focus ring is not demonstrated in example HTML HOT 1
- Better support for `disabled` attribute. HOT 3
- Stars invisible in high contrast mode HOT 5
- Regarding stability star 10 rating HOT 2
- On Mac voice over, it announces you are currently on radio button, X of 6. HOT 3
- Node throws SyntaxError: Unexpected token '.' for npm package css HOT 1
- Change size of stars? HOT 2
- It´s possible to select half stars? HOT 1
- Problem when decreasing the size HOT 1
- Spacing between the stars
- Dosn't work in 2021? HOT 3
- Can't print the stars in page HOT 1
- fixing required in starability-heartbeat.css
- Multiple ratings on same page HOT 1
- Responsive Star Size HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starability.