diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 03:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 03:09:43 +0300 |
commit | 46c2316f9226d9701437bd535880651e59bebdc6 (patch) | |
tree | 3ed11dfc5a00cf9883f4f74f4ff677be33a0c1bd /app/helpers/icons_helper.rb | |
parent | f05ceb978a12b289fe4e3575420b8c9316041e3a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/icons_helper.rb')
-rw-r--r-- | app/helpers/icons_helper.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index add15cc0d12..d5467ffb452 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -6,6 +6,8 @@ module IconsHelper extend self include FontAwesome::Rails::IconHelper + DEFAULT_ICON_SIZE = 16 + # Creates an icon tag given icon name(s) and possible icon modifiers. # # Right now this method simply delegates directly to `fa_icon` from the @@ -21,7 +23,7 @@ module IconsHelper options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options) end - def custom_icon(icon_name, size: 16) + def custom_icon(icon_name, size: DEFAULT_ICON_SIZE) # 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 @@ -52,7 +54,13 @@ module IconsHelper css_classes = [] css_classes << "s#{size}" if size css_classes << "#{css_class}" unless css_class.blank? - content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes.join(' ')) + + content_tag( + :svg, + content_tag(:use, '', { 'xlink:href' => "#{sprite_icon_path}##{icon_name}" } ), + class: css_classes.empty? ? nil : css_classes.join(' '), + data: { testid: "#{icon_name}-icon" } + ) end def loading_icon(container: false, color: 'orange', size: 'sm', css_class: nil) @@ -98,7 +106,7 @@ module IconsHelper end end - def visibility_level_icon(level, fw: true, options: {}) + def visibility_level_icon(level, options: {}) name = case level when Gitlab::VisibilityLevel::PRIVATE @@ -106,13 +114,10 @@ module IconsHelper when Gitlab::VisibilityLevel::INTERNAL 'shield' else # Gitlab::VisibilityLevel::PUBLIC - 'globe' + 'earth' end - name = [name] - name << "fw" if fw - - icon(name.join(' '), options) + sprite_icon(name, size: DEFAULT_ICON_SIZE, css_class: 'gl-vertical-align-text-bottom') end def file_type_icon_class(type, mode, name) |