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_groupObject



33
34
35
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 33

def init_button_group
  with_item_noop
end

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



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

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

#with_buttonObject



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

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

#with_button_htmlObject



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

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

#with_color_picker_buttonObject



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

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

#with_dividerObject



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

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

#with_image_picker_buttonObject



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

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

#with_layout_picker_buttonObject



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

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

#with_menu_buttonObject



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

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