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_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
36 37 38 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 36 def with_item_noop end |
#instantiate_button(type, *args, **kwargs, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 25 def (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, **(kwargs, type)) component.with_content(content) if !block && content.present? component end |
#with_button ⇒ Object
44 45 46 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 44 def (...) (...) end |
#with_color_picker_button ⇒ Object
52 53 54 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 52 def (...) (...) end |
#with_divider ⇒ Object
40 41 42 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 40 def with_divider(...) with_item_divider(...) end |
#with_image_picker_button ⇒ Object
56 57 58 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 56 def (...) (...) end |
#with_layout_picker_button ⇒ Object
60 61 62 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 60 def (...) (...) end |
#with_menu_button ⇒ Object
48 49 50 |
# File 'app/components/coco/concerns/acts_as_button_group.rb', line 48 def (...) (...) end |