From 52a626f39b1daab1b8573eaa0613ee5b70afc79f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 7 Aug 2024 18:53:15 -0400 Subject: [PATCH] Replace more `font-awesome` icons in `app/helpers` (#30962) --- app/helpers/application_helper.rb | 16 ++++++++-------- app/helpers/statuses_helper.rb | 8 ++++---- .../material-icons/400-24px/arrow_left_alt.svg | 1 + .../material-icons/400-24px/sync_alt.svg | 1 + spec/helpers/application_helper_spec.rb | 4 ++-- spec/helpers/statuses_helper_spec.rb | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 app/javascript/material-icons/400-24px/arrow_left_alt.svg create mode 100644 app/javascript/material-icons/400-24px/sync_alt.svg diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7e9cfee3f6..a6ab4044bc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -116,7 +116,7 @@ module ApplicationHelper def material_symbol(icon, attributes = {}) inline_svg_tag( "400-24px/#{icon}.svg", - class: %w(icon).concat(attributes[:class].to_s.split), + class: ['icon', "material-#{icon}"].concat(attributes[:class].to_s.split), role: :img ) end @@ -127,23 +127,23 @@ module ApplicationHelper def visibility_icon(status) if status.public_visibility? - fa_icon('globe', title: I18n.t('statuses.visibilities.public')) + material_symbol('globe', title: I18n.t('statuses.visibilities.public')) elsif status.unlisted_visibility? - fa_icon('unlock', title: I18n.t('statuses.visibilities.unlisted')) + material_symbol('lock_open', title: I18n.t('statuses.visibilities.unlisted')) elsif status.private_visibility? || status.limited_visibility? - fa_icon('lock', title: I18n.t('statuses.visibilities.private')) + material_symbol('lock', title: I18n.t('statuses.visibilities.private')) elsif status.direct_visibility? - fa_icon('at', title: I18n.t('statuses.visibilities.direct')) + material_symbol('alternate_email', title: I18n.t('statuses.visibilities.direct')) end end def interrelationships_icon(relationships, account_id) if relationships.following[account_id] && relationships.followed_by[account_id] - fa_icon('exchange', title: I18n.t('relationships.mutual'), class: 'fa-fw active passive') + material_symbol('sync_alt', title: I18n.t('relationships.mutual'), class: 'active passive') elsif relationships.following[account_id] - fa_icon(locale_direction == 'ltr' ? 'arrow-right' : 'arrow-left', title: I18n.t('relationships.following'), class: 'fa-fw active') + material_symbol(locale_direction == 'ltr' ? 'arrow_right_alt' : 'arrow_left_alt', title: I18n.t('relationships.following'), class: 'active') elsif relationships.followed_by[account_id] - fa_icon(locale_direction == 'ltr' ? 'arrow-left' : 'arrow-right', title: I18n.t('relationships.followers'), class: 'fa-fw passive') + material_symbol(locale_direction == 'ltr' ? 'arrow_left_alt' : 'arrow_right_alt', title: I18n.t('relationships.followers'), class: 'passive') end end diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb index ca693a8a78..d956e4fcd8 100644 --- a/app/helpers/statuses_helper.rb +++ b/app/helpers/statuses_helper.rb @@ -60,13 +60,13 @@ module StatusesHelper def fa_visibility_icon(status) case status.visibility when 'public' - fa_icon 'globe fw' + material_symbol 'globe' when 'unlisted' - fa_icon 'unlock fw' + material_symbol 'lock_open' when 'private' - fa_icon 'lock fw' + material_symbol 'lock' when 'direct' - fa_icon 'at fw' + material_symbol 'alternate_email' end end diff --git a/app/javascript/material-icons/400-24px/arrow_left_alt.svg b/app/javascript/material-icons/400-24px/arrow_left_alt.svg new file mode 100644 index 0000000000..a2b57a7f3c --- /dev/null +++ b/app/javascript/material-icons/400-24px/arrow_left_alt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/javascript/material-icons/400-24px/sync_alt.svg b/app/javascript/material-icons/400-24px/sync_alt.svg new file mode 100644 index 0000000000..a3bbb26a7a --- /dev/null +++ b/app/javascript/material-icons/400-24px/sync_alt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 56974513be..463a90b698 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -223,7 +223,7 @@ describe ApplicationHelper do it 'returns an unlock icon for a unlisted visible status' do result = helper.visibility_icon Status.new(visibility: 'unlisted') - expect(result).to match(/unlock/) + expect(result).to match(/lock_open/) end it 'returns a lock icon for a private visible status' do @@ -233,7 +233,7 @@ describe ApplicationHelper do it 'returns an at icon for a direct visible status' do result = helper.visibility_icon Status.new(visibility: 'direct') - expect(result).to match(/at/) + expect(result).to match(/alternate_email/) end end diff --git a/spec/helpers/statuses_helper_spec.rb b/spec/helpers/statuses_helper_spec.rb index 73d7d80e46..ba6fe361d9 100644 --- a/spec/helpers/statuses_helper_spec.rb +++ b/spec/helpers/statuses_helper_spec.rb @@ -36,7 +36,7 @@ describe StatusesHelper do it 'returns the correct fa icon' do result = helper.fa_visibility_icon(status) - expect(result).to match('fa-globe') + expect(result).to match('material-globe') end end @@ -46,7 +46,7 @@ describe StatusesHelper do it 'returns the correct fa icon' do result = helper.fa_visibility_icon(status) - expect(result).to match('fa-unlock') + expect(result).to match('material-lock_open') end end @@ -56,7 +56,7 @@ describe StatusesHelper do it 'returns the correct fa icon' do result = helper.fa_visibility_icon(status) - expect(result).to match('fa-lock') + expect(result).to match('material-lock') end end @@ -66,7 +66,7 @@ describe StatusesHelper do it 'returns the correct fa icon' do result = helper.fa_visibility_icon(status) - expect(result).to match('fa-at') + expect(result).to match('material-alternate_email') end end end