Class: Fluxbit::SpeedDialComponent

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

Overview

The ‘Fluxbit::SpeedDialComponent` is a component for rendering customizable Speed Dial floating action buttons.

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::SpeedDialComponent

Initializes the SpeedDial component with various customization options.

Parameters:

  • **props (Hash)

    The properties to customize the speed dial.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :position (Symbol) — default: :bottom_right

    The position of the speed dial (:top_left, :top_right, :bottom_left, :bottom_right).

  • :square (Boolean) — default: false

    Whether to use square shape instead of rounded.

  • :text_outside (Boolean) — default: false

    Whether to display text outside action buttons.

  • :trigger_icon (String, Symbol)

    The icon for the trigger button.

  • :remove_class (String) — default: ''

    CSS classes to remove from the default class list.

  • **props (Hash)

    Remaining options declared as HTML attributes.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/fluxbit/speed_dial_component.rb', line 27

def initialize(**props)
  super
  @props = props

  @position = options @props.delete(:position), collection: styles[:positions].keys, default: @@position
  @square = options @props.delete(:square), default: @@square
  @text_outside = options @props.delete(:text_outside), default: @@text_outside
  @trigger_icon = @props.delete(:trigger_icon)
  @props[:id] ||= "speed-dial-#{random_id}"

  add class: [
    styles[:base],
    styles[:positions][@position]
  ], to: @props

  remove_class_from_props(@props)
end