Skip to content

Commit

Permalink
make starred and non-starred easy to see
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Apr 11, 2017
1 parent 9a66572 commit 40a8334
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/assets/javascripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ $(function() {
// switch icons when user stars or unstars a project.
// keep in sync with app/helpers/projects_helper.rb
$('.star a').bind('ajax:success', function() {
$(this).toggleClass('glyphicon-star-empty');
$(this).toggleClass('glyphicon-star');
$(this).toggleClass('starred');
});

$('#project_deploy_with_docker').change(function(){
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/projects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ pre.pre-inline {
color: #333;
text-decoration: none;
font-size: 18px;
&.starred {
color: gold;
text-shadow: 0 0 1px gray;
}
}


Expand Down
5 changes: 3 additions & 2 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true
module ProjectsHelper
# keep in sync with app/assets/javascripts/projects.js
# keep star classes in sync with app/assets/javascripts/projects.js
# and projects#index
def star_for_project(project)
starred = current_user.starred_project?(project)

content_tag :span, class: 'star' do
link_to(
'', project_stars_path(project),
class: "glyphicon #{starred ? "glyphicon-star-empty" : "glyphicon-star"}",
class: "glyphicon glyphicon-star #{"starred" if starred}",
data: {method: :post, remote: true},
title: "#{starred ? "Unstar" : "Star"} this project"
)
Expand Down

0 comments on commit 40a8334

Please sign in to comment.