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_app_header, #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, #coco_layout_picker_button, #coco_link, #coco_menu_button, #coco_menu_item, #coco_notice, #coco_page, #coco_seamless_textarea, #coco_sidebar_nav, #coco_sidebar_nav_menu, #coco_snackbar, #coco_system_banner, #coco_toast, #coco_toolbar

Instance Method Details

#init_button_groupObject



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

def init_button_group
  with_item_noop
end

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



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

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_buttonObject



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

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

#with_color_picker_buttonObject



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

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

#with_dividerObject



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

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

#with_dropdown_buttonObject



67
68
69
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 67

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

#with_image_picker_buttonObject



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

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

#with_layout_picker_buttonObject



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

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

#with_menu_buttonObject



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

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