Class: JetUi::Tabs::ItemComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/jet_ui/tabs/item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(label = nil, href:, icon: nil, active: false, **options) ⇒ ItemComponent

Returns a new instance of ItemComponent.



6
7
8
9
10
11
12
# File 'app/components/jet_ui/tabs/item_component.rb', line 6

def initialize(label = nil, href:, icon: nil, active: false, **options)
  @label   = label
  @href    = href
  @icon    = icon
  @active  = active
  @options = options
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
# File 'app/components/jet_ui/tabs/item_component.rb', line 14

def call
   :li, class: 'tabs__item' do
    link_to @href, class: link_classes, **@options do
      concat render(JetUi::Icon::Component.new(@icon, size: 4)) if @icon
      concat(@label.presence || content)
    end
  end
end