module Coco module AppHelper def coco_link(*args, **kwargs, &block) href, content = args[0..2].reverse! link = Coco::App::Elements::Link.new(href: href, **kwargs) link = link.with_content(content) unless block render(link, &block) end def coco_button(href = nil, **kwargs, &block) button = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params) "FormButton" else "Button" end component = "Coco::App::Elements::#{button}".constantize.new(href: href, **kwargs) render component, &block end def coco_form_button(**kwargs, &block) render Coco::App::Elements::FormButton.new(**kwargs), &block end def coco_menu_button(**kwargs, &block) render Coco::App::Elements::MenuButton.new(**kwargs), &block end def coco_confirm_button(href = nil, **kwargs, &block) render Coco::App::Elements::ConfirmButton.new(href: href, **kwargs), &block end def coco_color_picker_button(**kwargs, &block) render Coco::App::Elements::ColorPickerButton.new(**kwargs), &block end def coco_image_picker_button(**kwargs, &block) render Coco::App::Elements::ImagePickerButton.new(**kwargs), &block end def coco_dropdown_button(**kwargs, &block) render Coco::App::Elements::DropdownButton.new(**kwargs), &block end def coco_button_group(**kwargs, &block) render Coco::App::Elements::ButtonGroup.new(**kwargs), &block end def coco_toolbar(**kwargs, &block) render Coco::App::Elements::Toolbar.new(**kwargs), &block end def coco_seamless_textarea(**kwargs, &block) render Coco::App::Elements::SeamlessTextarea.new(**kwargs), &block end def coco_snackbar(**kwargs, &block) render Coco::App::Elements::Snackbar.new(**kwargs), &block end def coco_notice(**kwargs, &block) render Coco::App::Elements::Notice.new(**kwargs), &block end def coco_toast(**kwargs, &block) render Coco::App::Elements::Toast.new(**kwargs), &block end def coco_system_banner(**kwargs, &block) render Coco::App::Elements::SystemBanner.new(**kwargs), &block end def coco_form_with(**kwargs, &block) form_with(**kwargs, builder: Coco::AppFormBuilder, &block) end def coco_form_for(*args, **kwargs, &block) form_for(*args, **kwargs, builder: Coco::AppFormBuilder, &block) end def coco_fields(**kwargs, &block) fields(**kwargs, builder: Coco::AppFormBuilder, &block) end end end