Module: Coco::AppHelper
- Included in:
- Coco::App::Blocks::SlideEditor, Coco::App::Elements::ColorPicker, Coco::App::Elements::ColorPickerButton, Coco::App::Elements::ImagePicker, Coco::App::Elements::ImagePickerButton, Coco::App::Elements::LayoutPickerButton, Coco::App::Elements::MenuButton, Coco::App::Elements::Toolbar, Coco::App::Fields::ButtonComponent, ComponentHelper, Concerns::ActsAsButtonGroup, Concerns::ActsAsFieldWithOptions
- Defined in:
- app/helpers/coco/app_helper.rb
Instance Method Summary collapse
- #coco_app_header(&block) ⇒ Object
- #coco_button(*args, **kwargs, &block) ⇒ Object
- #coco_button_group(&block) ⇒ Object
- #coco_color_picker_button(&block) ⇒ Object
- #coco_confirm_button(href = nil, &block) ⇒ Object
- #coco_dropdown_button(&block) ⇒ Object
- #coco_fields(&block) ⇒ Object
- #coco_form_for(&block) ⇒ Object
- #coco_form_with(&block) ⇒ Object
- #coco_image_picker_button(&block) ⇒ Object
- #coco_layout(name, &block) ⇒ Object
- #coco_layout_picker_button(&block) ⇒ Object
- #coco_link(*args, &block) ⇒ Object
- #coco_menu_button(&block) ⇒ Object
- #coco_menu_item(type, &block) ⇒ Object
- #coco_notice(&block) ⇒ Object
- #coco_page(id, &block) ⇒ Object
- #coco_seamless_textarea(&block) ⇒ Object
- #coco_sidebar_nav(&block) ⇒ Object
- #coco_sidebar_nav_menu(&block) ⇒ Object
- #coco_snackbar(&block) ⇒ Object
- #coco_system_banner(&block) ⇒ Object
- #coco_toast(&block) ⇒ Object
- #coco_toolbar(&block) ⇒ Object
Instance Method Details
#coco_app_header(&block) ⇒ Object
103 104 105 |
# File 'app/helpers/coco/app_helper.rb', line 103 def coco_app_header(*, **, &block) render Coco::App::Blocks::Header.new(*, **), &block end |
#coco_button(*args, **kwargs, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/coco/app_helper.rb', line 16 def (*args, **kwargs, &block) href, content = if block [args.first, nil] else (args.size == 1) ? [nil, args.first] : args[0..2].reverse! end = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params) "ButtonTo" else "Button" end component = "Coco::App::Elements::#{}".constantize.new(href: href, **kwargs) component = component.with_content(content) if !block && content.present? render(component, &block) end |
#coco_button_group(&block) ⇒ Object
59 60 61 |
# File 'app/helpers/coco/app_helper.rb', line 59 def (**, &block) render Coco::App::Elements::ButtonGroup.new(**), &block end |
#coco_color_picker_button(&block) ⇒ Object
43 44 45 |
# File 'app/helpers/coco/app_helper.rb', line 43 def (**, &block) render Coco::App::Elements::ColorPickerButton.new(**), &block end |
#coco_confirm_button(href = nil, &block) ⇒ Object
39 40 41 |
# File 'app/helpers/coco/app_helper.rb', line 39 def (href = nil, **, &block) render Coco::App::Elements::ConfirmButton.new(href: href, **), &block end |
#coco_dropdown_button(&block) ⇒ Object
55 56 57 |
# File 'app/helpers/coco/app_helper.rb', line 55 def (**, &block) render Coco::App::Elements::DropdownButton.new(**), &block end |
#coco_fields(&block) ⇒ Object
95 96 97 |
# File 'app/helpers/coco/app_helper.rb', line 95 def coco_fields(**, &block) fields(**, builder: Coco::AppFormBuilder, &block) end |
#coco_form_for(&block) ⇒ Object
91 92 93 |
# File 'app/helpers/coco/app_helper.rb', line 91 def coco_form_for(*, **, &block) form_for(*, **, builder: Coco::AppFormBuilder, &block) end |
#coco_form_with(&block) ⇒ Object
87 88 89 |
# File 'app/helpers/coco/app_helper.rb', line 87 def coco_form_with(**, &block) form_with(**, builder: Coco::AppFormBuilder, &block) end |
#coco_image_picker_button(&block) ⇒ Object
47 48 49 |
# File 'app/helpers/coco/app_helper.rb', line 47 def (**, &block) render Coco::App::Elements::ImagePickerButton.new(**), &block end |
#coco_layout(name, &block) ⇒ Object
99 100 101 |
# File 'app/helpers/coco/app_helper.rb', line 99 def coco_layout(name, **, &block) render coco_component("app/layouts/#{name}", **), &block end |
#coco_layout_picker_button(&block) ⇒ Object
51 52 53 |
# File 'app/helpers/coco/app_helper.rb', line 51 def (**, &block) render Coco::App::Elements::LayoutPickerButton.new(**), &block end |
#coco_link(*args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/coco/app_helper.rb', line 3 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 |
#coco_menu_button(&block) ⇒ Object
35 36 37 |
# File 'app/helpers/coco/app_helper.rb', line 35 def (**, &block) render Coco::App::Elements::MenuButton.new(**), &block end |
#coco_menu_item(type, &block) ⇒ Object
115 116 117 |
# File 'app/helpers/coco/app_helper.rb', line 115 def (type, **, &block) render coco_component("app/elements/menu_items/#{type}", **), &block end |
#coco_notice(&block) ⇒ Object
75 76 77 |
# File 'app/helpers/coco/app_helper.rb', line 75 def coco_notice(**, &block) render Coco::App::Elements::Notice.new(**), &block end |
#coco_page(id, &block) ⇒ Object
119 120 121 |
# File 'app/helpers/coco/app_helper.rb', line 119 def coco_page(id, **, &block) render coco_component("app/layouts/page", id: id, **), &block end |
#coco_seamless_textarea(&block) ⇒ Object
67 68 69 |
# File 'app/helpers/coco/app_helper.rb', line 67 def coco_seamless_textarea(**, &block) render Coco::App::Elements::SeamlessTextarea.new(**), &block end |
#coco_sidebar_nav(&block) ⇒ Object
107 108 109 |
# File 'app/helpers/coco/app_helper.rb', line 107 def (*, **, &block) render Coco::App::Blocks::SidebarNav::Navbar.new(*, **), &block end |
#coco_sidebar_nav_menu(&block) ⇒ Object
111 112 113 |
# File 'app/helpers/coco/app_helper.rb', line 111 def (*, **, &block) render Coco::App::Blocks::SidebarNav::Menu.new(*, **), &block end |
#coco_snackbar(&block) ⇒ Object
71 72 73 |
# File 'app/helpers/coco/app_helper.rb', line 71 def (**, &block) render Coco::App::Elements::Snackbar.new(**), &block end |
#coco_system_banner(&block) ⇒ Object
83 84 85 |
# File 'app/helpers/coco/app_helper.rb', line 83 def (**, &block) render Coco::App::Elements::SystemBanner.new(**), &block end |