Commit a5164ea2ed4e809cb4af7a070652ef2a6b19fbf3
1 parent
5ca31aa2
Exists in
master
and in
4 other branches
Show votes as a bar
Showing
5 changed files
with
70 additions
and
27 deletions
Show diff stats
app/assets/stylesheets/common.scss
... | ... | @@ -407,21 +407,46 @@ p.time { |
407 | 407 | } |
408 | 408 | |
409 | 409 | .votes { |
410 | - font-size: 14px; | |
411 | - font-weight: bold; | |
412 | - padding: 4px 0; | |
413 | - margin: 2px 0; | |
410 | + font-size: 13px; | |
411 | + line-height: 15px; | |
412 | + .progress { | |
413 | + height: 4px; | |
414 | + margin: 0; | |
415 | + .bar { | |
416 | + float: left; | |
417 | + height: 100%; | |
418 | + } | |
419 | + .bar-success { | |
420 | + background-color: #468847; | |
421 | + @include bg-gradient(#62C462, #51A351); | |
422 | + } | |
423 | + .bar-danger { | |
424 | + background-color: #B94A48; | |
425 | + @include bg-gradient(#EE5F5B, #BD362F); | |
426 | + } | |
427 | + } | |
414 | 428 | .upvotes { |
415 | 429 | display: inline-block; |
416 | 430 | color: #468847; |
417 | - padding: 0 4px; | |
418 | - margin: 0 2px; | |
419 | 431 | } |
420 | 432 | .downvotes { |
421 | 433 | display: inline-block; |
422 | 434 | color: #B94A48; |
423 | - padding: 0 4px; | |
424 | - margin: 0 2px; | |
435 | + } | |
436 | +} | |
437 | +.votes-block { | |
438 | + margin: 14px 6px 6px 0; | |
439 | + .downvotes { | |
440 | + float: right; | |
441 | + } | |
442 | +} | |
443 | +.votes-inline { | |
444 | + display: inline-block; | |
445 | + margin: 0 8px; | |
446 | + .progress { | |
447 | + display: inline-block; | |
448 | + padding: 0 0 2px; | |
449 | + width: 45px; | |
425 | 450 | } |
426 | 451 | } |
427 | 452 | ... | ... |
app/views/issues/_show.html.haml
... | ... | @@ -34,7 +34,12 @@ |
34 | 34 | - else |
35 | 35 | |
36 | 36 | |
37 | - - if issue.upvotes > 0 | |
38 | - %span.badge.badge-success= "+#{issue.upvotes}" | |
39 | - - if issue.downvotes > 0 | |
40 | - %span.badge.badge-important= "-#{issue.downvotes}" | |
37 | + - if issue.votes_count > 0 | |
38 | + .votes.votes-inline | |
39 | + .upvotes= issue.upvotes | |
40 | + .progress | |
41 | + - up_percent = 100.0/issue.votes_count*issue.upvotes | |
42 | + - down_percent = 100.0-up_percent | |
43 | + .bar.bar-success{style: "width: #{up_percent}%;"} | |
44 | + .bar.bar-danger{style: "width: #{down_percent}%;"} | |
45 | + .downvotes= issue.downvotes | ... | ... |
app/views/issues/show.html.haml
... | ... | @@ -16,16 +16,21 @@ |
16 | 16 | %i.icon-edit |
17 | 17 | Edit |
18 | 18 | |
19 | - %br | |
20 | - .votes#votes | |
21 | - Votes: | |
22 | - .upvotes#upvotes= "#{@issue.upvotes} up" | |
23 | - .downvotes#downvotes= "#{@issue.downvotes} down" | |
19 | +.right | |
20 | + .span3.votes.votes-block#votes | |
21 | + .progress | |
22 | + - up_percent = 100.0/@issue.votes_count*@issue.upvotes | |
23 | + - down_percent = 100.0-up_percent | |
24 | + .bar.bar-success{style: "width: #{up_percent}%;"} | |
25 | + .bar.bar-danger{style: "width: #{down_percent}%;"} | |
26 | + .upvotes= "#{@issue.upvotes} up" | |
27 | + .downvotes= "#{@issue.downvotes} down" | |
24 | 28 | |
25 | 29 | .back_link |
26 | 30 | = link_to project_issues_path(@project) do |
27 | 31 | ← To issues list |
28 | 32 | |
33 | + | |
29 | 34 | .main_box |
30 | 35 | .top_box_content |
31 | 36 | %h4 | ... | ... |
app/views/merge_requests/_merge_request.html.haml
... | ... | @@ -23,7 +23,12 @@ |
23 | 23 | authored by #{merge_request.author_name} |
24 | 24 | = time_ago_in_words(merge_request.created_at) |
25 | 25 | ago |
26 | - - if merge_request.upvotes > 0 | |
27 | - %span.badge.badge-success= "+#{merge_request.upvotes}" | |
28 | - - if merge_request.downvotes > 0 | |
29 | - %span.badge.badge-important= "-#{merge_request.downvotes}" | |
26 | + - if merge_request.votes_count > 0 | |
27 | + .votes.votes-inline | |
28 | + .upvotes= merge_request.upvotes | |
29 | + .progress | |
30 | + - up_percent = 100.0/merge_request.votes_count*merge_request.upvotes | |
31 | + - down_percent = 100.0-up_percent | |
32 | + .bar.bar-success{style: "width: #{up_percent}%;"} | |
33 | + .bar.bar-danger{style: "width: #{down_percent}%;"} | |
34 | + .downvotes= merge_request.downvotes | ... | ... |
app/views/merge_requests/show/_mr_title.html.haml
... | ... | @@ -23,12 +23,15 @@ |
23 | 23 | %i.icon-edit |
24 | 24 | Edit |
25 | 25 | |
26 | - %br | |
27 | - .votes#votes | |
28 | - Votes: | |
29 | - .upvotes#upvotes= "#{@merge_request.upvotes} up" | |
30 | - .downvotes#downvotes= "#{@merge_request.downvotes} down" | |
31 | - | |
26 | +.right | |
27 | + .span3.votes.votes-block#votes | |
28 | + .progress | |
29 | + - up_percent = 100.0/@merge_request.votes_count*@merge_request.upvotes | |
30 | + - down_percent = 100.0-up_percent | |
31 | + .bar.bar-success{style: "width: #{up_percent}%;"} | |
32 | + .bar.bar-danger{style: "width: #{down_percent}%;"} | |
33 | + .upvotes= "#{@merge_request.upvotes} up" | |
34 | + .downvotes= "#{@merge_request.downvotes} down" | |
32 | 35 | |
33 | 36 | .back_link |
34 | 37 | = link_to project_merge_requests_path(@project) do | ... | ... |