Module: Coco::Concerns::ActsAsButtonGroup

Extended by:
ActiveSupport::Concern
Includes:
AppHelper
Included in:
App::Elements::ButtonGroup, App::Elements::Menu
Defined in:
app/components/coco/concerns/acts_as_button_group.rb

Constant Summary collapse

BUTTON_TYPES =
{
  menu: "Coco::App::Elements::MenuButton",
  color_picker: "Coco::App::Elements::ColorPickerButton",
  layout_picker: "Coco::App::Elements::LayoutPickerButton",
  image_picker: "Coco::App::Elements::ImagePickerButton",
  dropdown: "Coco::App::Elements::DropdownButton"
}

Instance Method Summary collapse

Methods included from AppHelper

#coco_button, #coco_button_group, #coco_color_picker_button, #coco_confirm_button, #coco_dropdown_button, #coco_fields, #coco_form_for, #coco_form_with, #coco_image_picker_button, #coco_layout_picker_button, #coco_link, #coco_menu_button, #coco_notice, #coco_seamless_textarea, #coco_snackbar, #coco_system_banner, #coco_toast, #coco_toolbar

Instance Method Details

#instantiate_button(type, *args, **kwargs, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 27

def instantiate_button(type, *args, **kwargs, &block)
  href, content = if block
    [args.first, nil]
  else
    (args.size == 1) ? [nil, args.first] : args[0..2].reverse!
  end
  component = BUTTON_TYPES[type].constantize.new(href: href, **button_kwargs(kwargs, type))
  component.with_content(content) if !block && content.present?
  component
end

#with_button ⇒ Object



42
43
44
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 42

def with_button(...)
  with_item_button(...)
end

#with_color_picker_button ⇒ Object



50
51
52
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 50

def with_color_picker_button(...)
  with_item_color_picker_button(...)
end

#with_divider ⇒ Object



38
39
40
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 38

def with_divider(...)
  with_item_divider(...)
end

#with_dropdown_button ⇒ Object



62
63
64
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 62

def with_dropdown_button(...)
  with_item_dropdown_button(...)
end

#with_image_picker_button ⇒ Object



54
55
56
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 54

def with_image_picker_button(...)
  with_item_image_picker_button(...)
end

#with_layout_picker_button ⇒ Object



58
59
60
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 58

def with_layout_picker_button(...)
  with_item_layout_picker_button(...)
end

#with_menu_button ⇒ Object



46
47
48
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 46

def with_menu_button(...)
  with_item_menu_button(...)
end