Class: NitroKit::Icon

Inherits:
Component
  • Object
show all
Includes:
LucideRails::RailsHelper, Phlex::Rails::Helpers::ContentTag
Defined in:
app/components/nitro_kit/icon.rb

Constant Summary collapse

SIZE =
{
  sm: "size-4",
  base: "size-5"
}

Instance Attribute Summary collapse

Attributes inherited from Component

#attrs

Instance Method Summary collapse

Methods inherited from Component

#data_merge, merge, #merge

Constructor Details

#initialize(name:, size: :base, **attrs) ⇒ Icon

Returns a new instance of Icon.



11
12
13
14
15
# File 'app/components/nitro_kit/icon.rb', line 11

def initialize(name:, size: :base, **attrs)
  @name = name
  @size = size
  @attrs = attrs
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'app/components/nitro_kit/icon.rb', line 17

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



17
18
19
# File 'app/components/nitro_kit/icon.rb', line 17

def size
  @size
end

Instance Method Details

#view_templateObject



19
20
21
# File 'app/components/nitro_kit/icon.rb', line 19

def view_template
  lucide_icon(name, **attrs, class: merge([SIZE[size], attrs[:class]]))
end