Browse Source

fa_icon html_options

main
pvincent 6 months ago
parent
commit
e8d6b00575
  1. 14
      app/helpers/icon_helper.rb
  2. 5
      app/views/layouts/_navbar.html.erb
  3. 2
      app/views/scores/_score.html.erb

14
app/helpers/icon_helper.rb

@ -1,9 +1,13 @@
# Font Awesome Helper
module IconHelper
def fa_icon(name, extra_class = nil, style: :solid, size: nil)
content_class = "fa-#{style.to_s.dasherize} fa-#{name.to_s.dasherize}"
content_class << " fa-#{size.to_s.dasherize}" if size
content_class << " #{extra_class}" if extra_class
tag.i(class: content_class, 'aria-hidden': true)
def fa_icon(name, html_options = {})
html_options[:style] ||= :solid
html_options['aria-hidden'] ||= true
content_class = "fa-#{html_options[:style].to_s.dasherize} fa-#{name.to_s.dasherize}"
content_class << " fa-#{html_options[:size].to_s.dasherize}" if html_options.key? :size
content_class << " #{html_options[:class]}" if html_options.key? :class
tag.i(class: content_class, 'aria-hidden': html_options['aria-hidden'])
end
end

5
app/views/layouts/_navbar.html.erb

@ -1,9 +1,10 @@
<nav>
<ul>
<li>
A<%=fa_icon :magnifying_glass, size: '4x'%>
A<%=fa_icon :eye, size: '4x'%>
B<%=fa_icon :user, size: '4x'%>
<%=fa_icon :user, 'text-blue-400', style: :regular, size: '10x' %>
<%=fa_icon :user, class: 'text-blue-400', style: :regular, size: '10x' %>
<%=fa_icon :user, class: 'text-blue-400', size: '10x' %>
<%=fa_icon :user, size: '10x' %>
</li>
<li>C<i class="fa-regular fa-user"></i></li>

2
app/views/scores/_score.html.erb

@ -9,7 +9,7 @@
<td>
<% if action_name != "show" %>
<%= link_to "Show this score", score, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to score do %><%=fa_icon :eye, class: 'border rounded-2 mr-2' %>Show Score<% end %>
<%= link_to "Edit this score", edit_score_path(score), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to "Edit this score", edit_score_path(score), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
<%= button_to "Destroy this score", score_path(score), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>

Loading…
Cancel
Save