Class: Panda::Core::Admin::DropdownButtonComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/dropdown_button_component.rb

Overview

A button-styled dropdown menu. Combines ButtonComponent styling with DropdownComponent behaviour (Stimulus dropdown controller).

Examples:

In a heading slot

heading.with_dropdown_button(text: "View Board") do |db|
  db.with_item(label: "Fundraising", href: "/boards/1")
  db.with_item(label: "Events",      href: "/boards/2")
end

Defined Under Namespace

Classes: ItemComponent

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text: "Options", action: :secondary, icon: nil, size: :regular, **attrs) {|_self| ... } ⇒ DropdownButtonComponent

Returns a new instance of DropdownButtonComponent.

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
24
25
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 18

def initialize(text: "Options", action: :secondary, icon: nil, size: :regular, **attrs)
  @text = text
  @action = action
  @icon = icon
  @size = size
  super(**attrs)
  yield self if block_given?
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



27
28
29
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 27

def action
  @action
end

#iconObject (readonly)

Returns the value of attribute icon.



27
28
29
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 27

def icon
  @icon
end

#sizeObject (readonly)

Returns the value of attribute size.



27
28
29
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 27

def size
  @size
end

#textObject (readonly)

Returns the value of attribute text.



27
28
29
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 27

def text
  @text
end