Module: Iron::IconsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/iron/icons_helper.rb
Constant Summary collapse
- SPRITE_PATH =
"iron/icons/sprite.svg"
Instance Method Summary collapse
-
#icon(name, **attributes) ⇒ Object
Examples icon “heart” # => 24 px outline heart icon “trash”, class: “text-red-600 hover:text-red-700”.
Instance Method Details
#icon(name, **attributes) ⇒ Object
Examples
icon "heart" # => 24 px outline heart
icon "trash", class: "text-red-600 hover:text-red-700"
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/iron/icons_helper.rb', line 9 def icon(name, **attributes) css_class = attributes.delete(:class) data_attrs = { slot: "icon" }.merge!(attributes.delete(:data) || {}) tag.svg **attributes.merge( class: tw( "stroke-current size-5 fill-none stroke-2 [stroke-linecap:round] [stroke-linejoin:round]", css_class ), data: data_attrs, viewBox: "0 0 24 24", aria_hidden: "true" ) do tag.use href: "#{sprite_image_path}##{name}" end end |