Class: Fluxbit::BottomNavigationComponent::ButtonGroup::Button

Inherits:
Component
  • Object
show all
Includes:
Config::BottomNavigationComponent
Defined in:
app/components/fluxbit/bottom_navigation_component.rb

Overview

Button component for button group

Constant Summary

Constants inherited from Component

Component::ComponentObj

Instance Method Summary collapse

Methods inherited from Component

#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?

Methods included from IconHelpers

#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon

Constructor Details

#initialize(**props, &block) ⇒ Button

Initializes the button component.

Parameters:

  • **props (Hash)

    The properties to customize the button.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :href (String)

    The URL the button links to.

  • :active (Boolean) — default: false

    Whether the button is currently active.

  • **props (Hash)

    Remaining options declared as HTML attributes.



412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'app/components/fluxbit/bottom_navigation_component.rb', line 412

def initialize(**props, &block)
  super(**props, &block)
  @props = props
  @parent_config = @props.delete(:parent_config)

  @href = @props.delete(:href) || "#"
  @active = options(@props.delete(:active), default: false)

  add(class: styles[:button_group][:button], to: @props, first_element: true)
  add(class: styles[:button_group][:button_active], to: @props) if @active
  add(class: styles[:button_group][:button_inactive], to: @props) unless @active

  @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class])
end

Instance Method Details

#callObject



427
428
429
430
431
432
433
434
# File 'app/components/fluxbit/bottom_navigation_component.rb', line 427

def call
  @props[:data] ||= {}
  @props[:data][:href] = @href

  tag.button(type: "button", **@props) do
    content
  end
end