Browse Source

icon_helper

main
pvincent 6 months ago
parent
commit
552f776e35
  1. 10
      app/helpers/icon_helper.rb
  2. 10
      app/views/layouts/_navbar.html.erb

10
app/helpers/icon_helper.rb

@ -1,9 +1,9 @@
# Font Awesome Helper
module IconHelper
def icon(name = :home, classname = nil, options = {}, style: :regular)
clazz = "fa-#{style.to_s.dasherize} fa-#{name.to_s.dasherize}"
clazz += " #{options[:class]}" if options[:class]
clazz += " #{classname}" if classname
tag.i(class: clazz)
def fa_icon(name, extra_class = nil, style: :regular, 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)
end
end

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

@ -1,10 +1,12 @@
<nav>
<ul>
<li>
A<%=icon :user, 'text-6xl'%>
</li>
<li>
B<i class="fa-solid fa-magnifying-glass"></i>
A<%=fa_icon :magnifying_glass, style: :solid, size: '4x'%>
B<%=fa_icon :user, size: '4x'%>
<%=fa_icon :user, 'text-blue-400', style: :solid, size: '10x' %>
<%=fa_icon :user, style: :solid, size: '10x' %>
<%=fa_icon :user, size: '10x' %>
<%=fa_icon :user, size: '10x', style: :brands %>
</li>
<li>C<i class="fa-regular fa-user"></i></li>
<li>D<i class="fa-solid fa-user"></i></li>

Loading…
Cancel
Save