From b1d41de9fb4c9f7ca0e490ad87eb7f783c150756 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 8 Jul 2024 16:16:21 -0400 Subject: [PATCH 1/2] Replace more fa icons in helpers --- app/helpers/application_helper.rb | 14 +++++++------- app/helpers/statuses_helper.rb | 8 ++++---- .../material-icons/400-24px/arrow_left_alt.svg | 1 + .../material-icons/400-24px/sync_alt.svg | 1 + 4 files changed, 13 insertions(+), 11 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 7e9cfee3f68..1028b03a7cb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 ca693a8a78a..d956e4fcd8f 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 00000000000..a2b57a7f3c1 --- /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 00000000000..a3bbb26a7a3 --- /dev/null +++ b/app/javascript/material-icons/400-24px/sync_alt.svg @@ -0,0 +1 @@ + \ No newline at end of file From f633cc99601ab65a7cc88304a9785c06344c5c77 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 8 Jul 2024 16:48:09 -0400 Subject: [PATCH 2/2] Spec cleanup --- app/helpers/application_helper.rb | 2 +- spec/helpers/application_helper_spec.rb | 4 ++-- spec/helpers/statuses_helper_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1028b03a7cb..a6ab4044bcb 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 diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 56974513bef..463a90b6986 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 73d7d80e460..ba6fe361d96 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