Commit d1d4769a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'mw-remove-icon-helper' into 'master'

Remove deprecated icon helper in favor of sprite_icon

See merge request gitlab-org/gitlab!49560
parents 4c371a17 e3306d4a
......@@ -8,22 +8,6 @@ module IconsHelper
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
# font-awesome-rails gem, but should we ever use a different icon pack in the
# future we won't have to change hundreds of method calls.
# @deprecated use sprite_icon to render a SVG icon
def icon(names, options = {})
if (options.keys & %w[aria-hidden aria-label data-hidden]).empty?
# Add 'aria-hidden' and 'data-hidden' if they are not set in options.
options['aria-hidden'] = true
options['data-hidden'] = true
end
options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options)
end
def custom_icon(icon_name, size: DEFAULT_ICON_SIZE)
memoized_icon("#{icon_name}_#{size}") do
# We can't simply do the below, because there are some .erb SVGs.
......
......@@ -48,8 +48,6 @@ sprite_icon(icon_name, size: nil, css_class: '')
</svg>
```
**Please note:** The `icon(icon_name, options: {})` helper function is deprecated and should not be used anymore.
### Usage in Vue
[GitLab UI](https://gitlab-org.gitlab.io/gitlab-ui/), our components library, provides a component to display sprite icons.
......
......@@ -5,21 +5,6 @@ require 'spec_helper'
RSpec.describe IconsHelper do
let(:icons_path) { ActionController::Base.helpers.image_path("icons.svg") }
describe 'icon' do
it 'returns aria-hidden by default' do
star = icon('star')
expect(star['aria-hidden']).to eq 'aria-hidden'
end
it 'does not return aria-hidden if aria-label is set' do
up = icon('up', 'aria-label' => 'up')
expect(up['aria-hidden']).to be_nil
expect(up['aria-label']).to eq 'aria-label'
end
end
describe 'sprite_icon_path' do
it 'returns relative path' do
expect(sprite_icon_path).to eq(icons_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment