Module: Coco::Concerns::ActsAsButtonGroup

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#init_button_group ⇒ Object



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

def init_button_group
  with_item_noop
end

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



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

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



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

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

#with_button_html ⇒ Object



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

def with_button_html(...)
  with_item_html(...)
end

#with_color_picker_button ⇒ Object



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

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

#with_divider ⇒ Object



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

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

#with_image_picker_button ⇒ Object



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

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

#with_layout_picker_button ⇒ Object



65
66
67
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 65

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

#with_menu_button ⇒ Object



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

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