Class: Fluxbit::BottomNavigationComponent::CTA

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

Overview

CTA component for app bar variant

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) ⇒ CTA

Initializes the CTA component.

Parameters:

  • **props (Hash)

    The properties to customize the CTA.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :href (String)

    The URL the CTA links to.

  • :icon (String)

    The icon to display.

  • :tooltip_text (String)

    Tooltip text to display on hover.

  • **props (Hash)

    Remaining options declared as HTML attributes.



228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'app/components/fluxbit/bottom_navigation_component.rb', line 228

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

  @href = @props.delete(:href) || "#"
  @icon = @props.delete(:icon)
  @tooltip_text = @props.delete(:tooltip_text)

  add(class: styles[:cta][:button], to: @props, first_element: true)

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

Instance Method Details

#callObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'app/components/fluxbit/bottom_navigation_component.rb', line 242

def call
  setup_data_attributes

  button_content = tag.button(type: "button", **@props) do
    safe_join([
      (@icon ? anyicon(@icon, class: styles[:cta][:icon]) : nil),
      tag.span(content, class: styles[:item][:sr_only])
    ].compact)
  end

  if @tooltip_text
    safe_join([button_content, render_tooltip])
  else
    button_content
  end
end