Commit e3306d4a authored by Martin Wortschack's avatar Martin Wortschack Committed by Rémy Coutable

Remove deprecated icon helper in favor of sprite_icon

parent 708e5e6a
...@@ -8,22 +8,6 @@ module IconsHelper ...@@ -8,22 +8,6 @@ module IconsHelper
DEFAULT_ICON_SIZE = 16 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) def custom_icon(icon_name, size: DEFAULT_ICON_SIZE)
memoized_icon("#{icon_name}_#{size}") do memoized_icon("#{icon_name}_#{size}") do
# We can't simply do the below, because there are some .erb SVGs. # 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: '') ...@@ -48,8 +48,6 @@ sprite_icon(icon_name, size: nil, css_class: '')
</svg> </svg>
``` ```
**Please note:** The `icon(icon_name, options: {})` helper function is deprecated and should not be used anymore.
### Usage in Vue ### Usage in Vue
[GitLab UI](https://gitlab-org.gitlab.io/gitlab-ui/), our components library, provides a component to display sprite icons. [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' ...@@ -5,21 +5,6 @@ require 'spec_helper'
RSpec.describe IconsHelper do RSpec.describe IconsHelper do
let(:icons_path) { ActionController::Base.helpers.image_path("icons.svg") } 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 describe 'sprite_icon_path' do
it 'returns relative path' do it 'returns relative path' do
expect(sprite_icon_path).to eq(icons_path) 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