module Coco module AppHelper def coco_link(*args, **, &block) href, content = if block [args.first, nil] else (args.size == 1) ? [nil, args.first] : args[0..2].reverse! end link = Coco::App::Elements::Link.new(href: href, **) link = link.with_content(content) if !block && content.present? render(link, &block) end def coco_menu_button(**, &block) render Coco::App::Elements::MenuButton.new(**), &block end def coco_confirm_button(href = nil, **, &block) render Coco::App::Elements::ConfirmButton.new(href: href, **), &block end def coco_color_picker_button(**, &block) render Coco::App::Elements::ColorPickerButton.new(**), &block end def coco_image_picker_button(**, &block) render Coco::App::Elements::ImagePickerButton.new(**), &block end def coco_layout_picker_button(**, &block) render Coco::App::Elements::LayoutPickerButton.new(**), &block end def coco_dropdown_button(**, &block) render Coco::App::Elements::DropdownButton.new(**), &block end def coco_toolbar(**, &block) render Coco::App::Elements::Toolbar.new(**), &block end def coco_seamless_textarea(**, &block) render Coco::App::Elements::SeamlessTextarea.new(**), &block end def coco_stamp(type = nil, **) props = case type when :success, :positive {icon: :check_circle, theme: :positive} when :error, :negative {icon: :alert_circle, theme: :negative} when :warning {icon: :alert_triangle, theme: :warning} when :info {icon: :info, theme: :info} else {} end render Coco::App::Elements::Stamp.new(**props, **) end def coco_snackbar(**, &block) render Coco::App::Elements::Snackbar.new(**), &block end def coco_notice(**, &block) render Coco::App::Elements::Notice.new(**), &block end def coco_toast(**, &block) render Coco::App::Elements::Toast.new(**), &block end def coco_system_banner(**, &block) render Coco::App::Elements::SystemBanner.new(**), &block end def coco_panel(**, &block) render Coco::Panel.new(**), &block end def coco_form_with(**, &block) form_with(**, builder: Coco::AppFormBuilder, &block) end def coco_form_for(*, **, &block) form_for(*, **, builder: Coco::AppFormBuilder, &block) end def coco_fields(**, &block) fields(**, builder: Coco::AppFormBuilder, &block) end def coco_layout(name, **, &block) render coco_component("app/layouts/#{name}", **), &block end def coco_app_header(*, **, &block) render Coco::App::Blocks::Header.new(*, **), &block end def coco_sidebar_nav(*, **, &block) render Coco::App::Blocks::SidebarNav::Navbar.new(*, **), &block end def coco_sidebar_nav_menu(*, **, &block) render Coco::App::Blocks::SidebarNav::Menu.new(*, **), &block end def coco_menu_item(type, **, &block) render coco_component("app/elements/menu_items/#{type}", **), &block end def coco_page(id, **, &block) render coco_component("app/layouts/page", id: id, **), &block end end end