From 92f1c474f305de2383a4d2b3dffbcc20800cfb6f Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Mon, 3 Jul 2017 18:04:35 +0900 Subject: [PATCH] Add fa-fw class to user agent icon (#4047) --- app/helpers/application_helper.rb | 8 ++++++-- app/views/auth/registrations/_sessions.html.haml | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 36c37fae08f..9f50d8bdb32 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,7 +31,11 @@ module ApplicationHelper Rails.env.production? ? site_title : "#{site_title} (Dev)" end - def fa_icon(icon) - content_tag(:i, nil, class: 'fa ' + icon.split(' ').map { |cl| "fa-#{cl}" }.join(' ')) + def fa_icon(icon, attributes = {}) + class_names = attributes[:class]&.split(' ') || [] + class_names << 'fa' + class_names += icon.split(' ').map { |cl| "fa-#{cl}" } + + content_tag(:i, nil, attributes.merge(class: class_names.join(' '))) end end diff --git a/app/views/auth/registrations/_sessions.html.haml b/app/views/auth/registrations/_sessions.html.haml index 11c0d4e315f..4521aad0a2b 100644 --- a/app/views/auth/registrations/_sessions.html.haml +++ b/app/views/auth/registrations/_sessions.html.haml @@ -11,9 +11,10 @@ - @sessions.each do |session| %tr %td - %span{ title: session.user_agent }= fa_icon session_device_icon(session) - = ' ' - = t 'sessions.description', browser: t("sessions.browsers.#{session.browser}"), platform: t("sessions.platforms.#{session.platform}") + %span{ title: session.user_agent }< + = fa_icon "#{session_device_icon(session)} fw", 'aria-label' => session_device_icon(session) + = ' ' + = t 'sessions.description', browser: t("sessions.browsers.#{session.browser}"), platform: t("sessions.platforms.#{session.platform}") %td %samp= session.ip %td