Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Sep 11, 2012
1 parent 7f6b87e commit fcf0ceb
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pkg
#
# For MacOS:
#
#.DS_Store
.DS_Store

# For TextMate
#*.tmproj
Expand Down
14 changes: 4 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "rspec", "~> 2.8.0"
gem "rdoc", "~> 3.12"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.8.4"
gem "rcov", ">= 0"
gem "rspec", ">= 2.8.0"
gem "rdoc", ">= 3.12"
gem "bundler","> 1.0.0"
gem "jeweler",">= 1.8.4"
end
31 changes: 31 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
git (1.2.5)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.7.5)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)

PLATFORMS
ruby

DEPENDENCIES
bundler (> 1.0.0)
jeweler (>= 1.8.4)
rdoc (>= 3.12)
rspec (>= 2.8.0)
10 changes: 9 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
= css-star-ratings

Description goes here.
== Assets

CSS assets

cool-stars
simple-stars
point-stars

See the spec dir for usage example of each type of CSS rating. Based on a CSS-tricks article ;)

== Contributing to css-star-ratings

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "css-star-ratings"
gem.homepage = "http://github.com/kristianmandrup/css-star-ratings"
gem.license = "MIT"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.summary = %Q{Simple CSS based Star rating implementations}
gem.description = %Q{Add CSS star ratings to your rails app}
gem.email = "kmandrup@gmail.com"
gem.authors = ["Kristian Mandrup"]
# dependencies defined in Gemfile
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0
0.1.0
6 changes: 6 additions & 0 deletions lib/css-star-ratings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module CssStarRatings
module Rails
class Engine < ::Rails::Engine
end
end
end
8 changes: 8 additions & 0 deletions spec/cool-stars.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<fieldset class="rating">
<legend>Please rate:</legend>
<input type="radio" id="star5" name="rating" value="5" /><label for="star5" title="Rocks!">5 stars</label>
<input type="radio" id="star4" name="rating" value="4" /><label for="star4" title="Pretty good">4 stars</label>
<input type="radio" id="star3" name="rating" value="3" /><label for="star3" title="Meh">3 stars</label>
<input type="radio" id="star2" name="rating" value="2" /><label for="star2" title="Kinda bad">2 stars</label>
<input type="radio" id="star1" name="rating" value="1" /><label for="star1" title="Sucks big time">1 star</label>
</fieldset>
7 changes: 0 additions & 7 deletions spec/css-star-ratings_spec.rb

This file was deleted.

7 changes: 7 additions & 0 deletions spec/point-stars.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="rating">
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
</div>
7 changes: 7 additions & 0 deletions spec/simple-stars.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="rating">
<input name="myrating" type="radio" value="5"><span></span>
<input name="myrating" type="radio" value="4"><span></span>
<input name="myrating" type="radio" value="3"><span></span>
<input name="myrating" type="radio" value="2"><span></span>
<input name="myrating" type="radio" value="1"><span></span>
</div>
9 changes: 1 addition & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'css-star-ratings'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|

RSpec.configure do |config|
end
55 changes: 55 additions & 0 deletions vendor/assets/cool-stars.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.rating {
float:left;
}

/* :not(:checked) is a filter, so that browsers that don’t support :checked don’t
follow these rules. Every browser that supports :checked also supports :not(), so
it doesn’t make the test unnecessarily selective */
.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:200%;
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;
}
39 changes: 39 additions & 0 deletions vendor/assets/point-stars.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
direction: rtl;
text-align: center;
}

.rating a {
display: inline-block;
position: relative;
font-size: 1.5em;
width: 1.1em;
text-decoration: none;
color: grey;
}
.rating a:hover,
.rating a:hover ~ a {
color: transparent;
}
.rating a:hover:before,
.rating a:hover ~ a:before {
content: "\2605";
font-size: 1.2em;
position: absolute;
left: 0;
margin-top: -25%;
margin-left: -10%;
color: gold;
}

.rating a:active:before,
.rating a:active ~ a:before {
color: red;
}


body { padding: 100px; }
38 changes: 38 additions & 0 deletions vendor/assets/simple-stars.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
}
.rating > span {
display: inline-block;
position: relative;
width: 1.1em;
}
.rating > *:hover,
.rating > *:hover ~ span,
.rating:not(:hover) > input:checked ~ span {
color: transparent;
}
.rating > *:hover:before,
.rating > *:hover ~ span:before,
.rating:not(:hover) > input:checked ~ span:before {
content: "\2605";
position: absolute;
left: 0;
color: gold;
}

.rating > input {
margin-left:-1.1em;
margin-right:0;
top:3px;
width:1.1em;
height:1.1em;
position:relative;
z-index:2;
opacity:0;
}

0 comments on commit fcf0ceb

Please sign in to comment.