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
- #init_button_group ⇒ Object
- #instantiate_button(type, *args, **kwargs, &block) ⇒ Object
- #with_button ⇒ Object
- #with_button_html ⇒ Object
- #with_color_picker_button ⇒ Object
- #with_divider ⇒ Object
- #with_image_picker_button ⇒ Object
- #with_layout_picker_button ⇒ Object
- #with_menu_button ⇒ Object
Instance Method Details
#init_button_group ⇒ Object
33 34 35 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 33 def 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 (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, **(kwargs, type)) component.with_text(content) if content.present? component end |
#with_button ⇒ Object
41 42 43 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 41 def (...) (...) end |
#with_button_html ⇒ Object
45 46 47 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 45 def (...) with_item_html(...) end |
#with_color_picker_button ⇒ Object
53 54 55 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 53 def (...) (...) end |
#with_divider ⇒ Object
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_button ⇒ Object
57 58 59 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 57 def (...) (...) end |
#with_layout_picker_button ⇒ Object
61 62 63 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 61 def (...) (...) end |
#with_menu_button ⇒ Object
49 50 51 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 49 def (...) (...) end |