Commit 2247304b715bf57e8f0bfc69b1d79c4f90ca2605
1 parent
53e85962
Exists in
master
and in
27 other branches
community_track: add color to track name
Showing
3 changed files
with
12 additions
and
1 deletions
Show diff stats
plugins/community_track/lib/community_track_plugin/track_helper.rb
... | ... | @@ -15,4 +15,9 @@ module CommunityTrackPlugin::TrackHelper |
15 | 15 | category_color_style(track.categories.first.with_color) if !track.categories.empty? |
16 | 16 | end |
17 | 17 | |
18 | + def track_name_color_style(track) | |
19 | + category = track.categories.empty? ? nil : track.categories.first.with_color | |
20 | + category ? "color: ##{category.display_color};" : '' | |
21 | + end | |
22 | + | |
18 | 23 | end | ... | ... |
plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb
... | ... | @@ -58,4 +58,10 @@ class TrackHelperTest < ActiveSupport::TestCase |
58 | 58 | assert_equal 'background-color: #fbfbfb;', track_color_style(@track) |
59 | 59 | end |
60 | 60 | |
61 | + should 'return category color for track name' do | |
62 | + category1 = fast_create(Category, :name => 'education', :display_color => 'fbfbfb') | |
63 | + @track.categories << category1 | |
64 | + assert_equal 'color: #fbfbfb;', track_name_color_style(@track) | |
65 | + end | |
66 | + | |
61 | 67 | end | ... | ... |
plugins/community_track/views/blocks/_track_card.html.erb
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <div class="image"> |
9 | 9 | <%= image_tag track_card.image.public_filename if track_card.image %> |
10 | 10 | </div> |
11 | - <div class="name"> | |
11 | + <div class="name" style="<%= track_name_color_style(track_card) %>"> | |
12 | 12 | <%= track_card.name %> |
13 | 13 | </div> |
14 | 14 | <div class="lead"> | ... | ... |