Class: Fluxbit::SpeedDialActionComponent

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

Overview

The ‘Fluxbit::SpeedDialActionComponent` is a component for rendering individual action items in a Speed Dial.

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) ⇒ Fluxbit::SpeedDialActionComponent

Initializes the SpeedDialAction component.

Parameters:

  • **props (Hash)

    The properties to customize the speed dial action.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :icon (String, Symbol) — default: nil

    The icon to display in the action button.

  • :text (String) — default: nil

    The text label for the action.

  • :tooltip (String) — default: nil

    The tooltip text (defaults to text if not provided).

  • :href (String) — default: nil

    The URL to link to (creates an anchor tag instead of button).

  • :text_outside (Boolean) — default: false

    Whether to display text outside the button.

  • :square (Boolean) — default: false

    Whether to use square shape instead of rounded.

  • :tooltip_placement (Symbol) — default: :left

    Tooltip placement.

  • :remove_class (String) — default: ''

    CSS classes to remove from the default class list.

  • **props (Hash)

    Remaining options declared as HTML attributes.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/fluxbit/speed_dial_action_component.rb', line 21

def initialize(**props)
  super(**props.slice(:tooltip_text, :tooltip_placement, :tooltip_trigger))
  @props = props

  @icon = @props.delete(:icon)
  @text = @props.delete(:text)
  @tooltip = @props.delete(:tooltip) || @text
  @href = @props.delete(:href)
  @text_outside = options @props.delete(:text_outside), default: false
  @square = options @props.delete(:square), default: false
  @tooltip_placement = options @props.delete(:tooltip_placement), default: :left
  @props[:id] ||= "speed-dial-action-#{random_id}"

  # Set tooltip via parent component if provided
  @tooltip_text = @tooltip if @tooltip.present?

  add class: [
    styles[:action][:base],
    @square ? styles[:action][:shapes][:square] : styles[:action][:shapes][:rounded]
  ], to: @props
  @props[:type] ||= "button" unless @href

  remove_class_from_props(@props)
end

Instance Method Details

#before_renderObject



46
47
48
# File 'app/components/fluxbit/speed_dial_action_component.rb', line 46

def before_render
  add_popover_or_tooltip
end