You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. # frozen_string_literal: true
  2. module HomeHelper
  3. def default_props
  4. {
  5. locale: I18n.locale,
  6. }
  7. end
  8. def account_link_to(account, button = '')
  9. content_tag(:div, class: 'account') do
  10. content_tag(:div, class: 'account__wrapper') do
  11. section = if account.nil?
  12. content_tag(:div, class: 'account__display-name') do
  13. content_tag(:div, class: 'account__avatar-wrapper') do
  14. content_tag(:div, '', class: 'account__avatar', style: "background-image: url(#{full_asset_url('avatars/original/missing.png', skip_pipeline: true)})")
  15. end +
  16. content_tag(:span, class: 'display-name') do
  17. content_tag(:strong, t('about.contact_missing')) +
  18. content_tag(:span, t('about.contact_unavailable'), class: 'display-name__account')
  19. end
  20. end
  21. else
  22. link_to(TagManager.instance.url_for(account), class: 'account__display-name') do
  23. content_tag(:div, class: 'account__avatar-wrapper') do
  24. content_tag(:div, '', class: 'account__avatar', style: "background-image: url(#{account.avatar.url})")
  25. end +
  26. content_tag(:span, class: 'display-name') do
  27. content_tag(:bdi) do
  28. content_tag(:strong, display_name(account, custom_emojify: true), class: 'display-name__html emojify')
  29. end +
  30. content_tag(:span, "@#{account.acct}", class: 'display-name__account')
  31. end
  32. end
  33. end
  34. section + button
  35. end
  36. end
  37. end
  38. def obscured_counter(count)
  39. if count <= 0
  40. 0
  41. elsif count == 1
  42. 1
  43. else
  44. '1+'
  45. end
  46. end
  47. end