summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-09-22 08:39:47 +0000
committerPhil Hughes <me@iamphill.com>2017-09-22 08:39:47 +0000
commit55f772bb98a67ad346442a2cacb5646f6719b987 (patch)
treefdcda42d5ee9c746b5654a50fa88a0fd1464d3a8 /app/helpers
parentd103e95513704314a38ab8ae441851524031c4a1 (diff)
downloadgitlab-ce-55f772bb98a67ad346442a2cacb5646f6719b987.tar.gz
Resolve "Better SVG Usage in the Frontend"
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/appearances_helper.rb6
-rw-r--r--app/helpers/icons_helper.rb12
-rw-r--r--app/helpers/system_note_helper.rb42
3 files changed, 33 insertions, 27 deletions
diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb
index cdf5fa5d4b7..8ad94d3f723 100644
--- a/app/helpers/appearances_helper.rb
+++ b/app/helpers/appearances_helper.rb
@@ -30,10 +30,4 @@ module AppearancesHelper
render 'shared/logo.svg'
end
end
-
- def custom_icon(icon_name, size: 16)
- # We can't simply do the below, because there are some .erb SVGs.
- # File.read(Rails.root.join("app/views/shared/icons/_#{icon_name}.svg")).html_safe
- render "shared/icons/#{icon_name}.svg", size: size
- end
end
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
index 9a404832423..08e6443bd0f 100644
--- a/app/helpers/icons_helper.rb
+++ b/app/helpers/icons_helper.rb
@@ -17,6 +17,18 @@ module IconsHelper
options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options)
end
+ def custom_icon(icon_name, size: 16)
+ # We can't simply do the below, because there are some .erb SVGs.
+ # File.read(Rails.root.join("app/views/shared/icons/_#{icon_name}.svg")).html_safe
+ render "shared/icons/#{icon_name}.svg", size: size
+ end
+
+ def sprite_icon(icon_name, size: nil, css_class: nil)
+ css_classes = size ? "s#{size}" : nil
+ css_classes << " #{css_class}" unless css_class.blank?
+ content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{image_path('icons.svg')}##{icon_name}" } ), class: css_classes)
+ end
+
def audit_icon(names, options = {})
case names
when "standard"
diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb
index c98f65c7644..d7eaf6ce24d 100644
--- a/app/helpers/system_note_helper.rb
+++ b/app/helpers/system_note_helper.rb
@@ -1,25 +1,25 @@
module SystemNoteHelper
ICON_NAMES_BY_ACTION = {
- 'commit' => 'icon_commit',
- 'description' => 'icon_edit',
- 'merge' => 'icon_merge',
- 'merged' => 'icon_merged',
- 'opened' => 'icon_status_open',
- 'closed' => 'icon_status_closed',
- 'time_tracking' => 'icon_stopwatch',
- 'assignee' => 'icon_user',
- 'title' => 'icon_edit',
- 'task' => 'icon_check_square_o',
- 'label' => 'icon_tags',
- 'cross_reference' => 'icon_random',
- 'branch' => 'icon_code_fork',
- 'confidential' => 'icon_eye_slash',
- 'visible' => 'icon_eye',
- 'milestone' => 'icon_clock_o',
- 'discussion' => 'icon_comment_o',
- 'moved' => 'icon_arrow_circle_o_right',
- 'outdated' => 'icon_edit',
- 'duplicate' => 'icon_clone'
+ 'commit' => 'commit',
+ 'description' => 'pencil',
+ 'merge' => 'git-merge',
+ 'merged' => 'git-merge',
+ 'opened' => 'issue-open',
+ 'closed' => 'issue-close',
+ 'time_tracking' => 'timer',
+ 'assignee' => 'user',
+ 'title' => 'pencil',
+ 'task' => 'task-done',
+ 'label' => 'label',
+ 'cross_reference' => 'comment-dots',
+ 'branch' => 'fork',
+ 'confidential' => 'eye-slash',
+ 'visible' => 'eye',
+ 'milestone' => 'clock',
+ 'discussion' => 'comment',
+ 'moved' => 'arrow-right',
+ 'outdated' => 'pencil',
+ 'duplicate' => 'issue-duplicate'
}.freeze
def system_note_icon_name(note)
@@ -28,7 +28,7 @@ module SystemNoteHelper
def icon_for_system_note(note)
icon_name = system_note_icon_name(note)
- custom_icon(icon_name) if icon_name
+ sprite_icon(icon_name) if icon_name
end
extend self