Skip to content

Commit

Permalink
Replace more font-awesome icons in app/helpers (mastodon#30962)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Aug 7, 2024
1 parent e4092cc commit 52a626f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
16 changes: 8 additions & 8 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def fa_icon(icon, attributes = {})
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
Expand All @@ -127,23 +127,23 @@ def check_icon

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

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/statuses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def stream_link_target
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

Expand Down
1 change: 1 addition & 0 deletions app/javascript/material-icons/400-24px/arrow_left_alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/javascript/material-icons/400-24px/sync_alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def current_theme = 'default'

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
Expand All @@ -233,7 +233,7 @@ def current_theme = 'default'

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

Expand Down
8 changes: 4 additions & 4 deletions spec/helpers/statuses_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def status_text_summary(status)
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

Expand All @@ -46,7 +46,7 @@ def status_text_summary(status)
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

Expand All @@ -56,7 +56,7 @@ def status_text_summary(status)
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

Expand All @@ -66,7 +66,7 @@ def status_text_summary(status)
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
Expand Down

0 comments on commit 52a626f

Please sign in to comment.