Skip to content

Commit

Permalink
introduce tabler-icons for redmine 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cat-in-136 committed Nov 28, 2024
1 parent ee0c93c commit a14e0a6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
17 changes: 16 additions & 1 deletion app/helpers/hearts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def heart_link_with_counter_manual(objects, heart_bool, hearted_users_count, use
objects = Array.wrap(objects)

css = heart_bool ? 'icon icon-heart' : 'icon icon-heart-off'
text = content_tag :span, l(:hearts_link_label), :class => 'heart-link-label'
if defined? hearts_icon_with_label # redmine >= 6.0
text = hearts_icon_with_label('heart', l(:hearts_link_label), css_class: 'heart-link-label')
else
text = content_tag :span, l(:hearts_link_label), :class => 'heart-link-label'
end
object_type = objects.first.class.to_s.underscore
object_id = (objects.size == 1) ? objects.first.id : objects.map(&:id).sort

Expand Down Expand Up @@ -127,4 +131,15 @@ def render_api_heartable_include(heartable, api)
end
end
end

if defined? IconsHelper # redmine >= 6.0
include IconsHelper
def hearts_icon_with_label(icon_name, label_text, icon_only: false, size: 18, css_class: nil)
label_classes = ["icon-label"]
label_classes << "hidden" if icon_only
plugin = 'redmine_hearts'
sprite_icon(icon_name, size: size, css_class: css_class, plugin: plugin) + content_tag(:span, label_text, class: label_classes.join(' '))
end
end

end
8 changes: 8 additions & 0 deletions assets/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.icon-heart { background-image: url(../images/heart.png); }
.icon-heart-off { background-image: url(../images/heart_off.png); }

.heart-link-with-count { display: inline-block; }
.heart-count-number { padding-left: 1ex; }
.heart-count-number { padding-left: 0.75ex; }

/* redmine >= 6.0 */
:is(.icon-heart, .icon-heart-off):has(svg.icon-svg) { background-image: none; }
.icon-heart .icon-svg { fill: #fb8098; stroke: none; }
.heart-link-with-count:has(svg.icon-svg) {
display: inline-flex;
align-items: center;
vertical-align: middle;
}


@media screen and (max-width: 899px) {
.heart-link-with-count > *:nth-child(1) {
Expand Down
2 changes: 2 additions & 0 deletions config/icon_source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: heart
svg: heart

0 comments on commit a14e0a6

Please sign in to comment.