Class: Alchemy::Admin::Icon

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/alchemy/admin/icon.rb

Overview

Render a Remix icon

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(icon_name, options = {}) ⇒ Icon

Returns a new instance of Icon.

Parameters:

  • icon_name (String)

    icon name

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • - (Object)

    style: fill [String] icon style. line or fill. Pass false for no style.

  • - (Object)

    size: nil [String] icon size

  • - (Object)

    class: nil [String] css class



12
13
14
15
16
17
# File 'app/components/alchemy/admin/icon.rb', line 12

def initialize(icon_name, options = {})
  @icon_name = icon_name
  @style = options[:style].nil? ? "line" : options[:style]
  @size = options[:size]
  @css_class = options[:class]
end

Instance Attribute Details

#css_classObject (readonly)

Returns the value of attribute css_class.



6
7
8
# File 'app/components/alchemy/admin/icon.rb', line 6

def css_class
  @css_class
end

#icon_nameObject (readonly)

Returns the value of attribute icon_name.



6
7
8
# File 'app/components/alchemy/admin/icon.rb', line 6

def icon_name
  @icon_name
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'app/components/alchemy/admin/icon.rb', line 6

def size
  @size
end

#styleObject (readonly)

Returns the value of attribute style.



6
7
8
# File 'app/components/alchemy/admin/icon.rb', line 6

def style
  @style
end

Instance Method Details

#callObject



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

def call
  ("alchemy-icon", nil, name: ri_icon, size: size, "icon-style": ri_style, class: css_class)
end