Module: Coco::AppHelper
- Included in:
- Coco::App::Blocks::NavBar, Coco::App::Blocks::NavDrawer, 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_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_picker_button(&block) ⇒ Object
- #coco_link(*args, **kwargs, &block) ⇒ Object
- #coco_menu_button(&block) ⇒ Object
- #coco_notice(&block) ⇒ Object
- #coco_seamless_textarea(&block) ⇒ Object
- #coco_snackbar(&block) ⇒ Object
- #coco_system_banner(&block) ⇒ Object
- #coco_toast(&block) ⇒ Object
- #coco_toolbar(&block) ⇒ Object
Instance Method Details
#coco_button(*args, **kwargs, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/coco/app_helper.rb', line 24 def (*args, **kwargs, &block) href, content = args[0..2].reverse! = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params) "ButtonTo" else "Button" end kwargs[:button_element] ||= {} if kwargs.key?(:modal) modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal] kwargs[:button_element][:data] = kwargs[:button_element].fetch(:data, {}).merge(coco_modal_data_attributes(modal_name)) kwargs.delete(:modal) end if kwargs.key?(:frame) turbo_data = {turbo: true, turbo_frame: kwargs[:frame]} kwargs[:button_element][:data] = kwargs[:button_element].fetch(:data, {}).merge(turbo_data) kwargs.delete(:frame) 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
77 78 79 |
# File 'app/helpers/coco/app_helper.rb', line 77 def (**, &block) render Coco::App::Elements::ButtonGroup.new(**), &block end |
#coco_color_picker_button(&block) ⇒ Object
61 62 63 |
# File 'app/helpers/coco/app_helper.rb', line 61 def (**, &block) render Coco::App::Elements::ColorPickerButton.new(**), &block end |
#coco_confirm_button(href = nil, &block) ⇒ Object
57 58 59 |
# File 'app/helpers/coco/app_helper.rb', line 57 def (href = nil, **, &block) render Coco::App::Elements::ConfirmButton.new(href: href, **), &block end |
#coco_dropdown_button(&block) ⇒ Object
73 74 75 |
# File 'app/helpers/coco/app_helper.rb', line 73 def (**, &block) render Coco::App::Elements::DropdownButton.new(**), &block end |
#coco_fields(&block) ⇒ Object
113 114 115 |
# File 'app/helpers/coco/app_helper.rb', line 113 def coco_fields(**, &block) fields(**, builder: Coco::AppFormBuilder, &block) end |
#coco_form_for(&block) ⇒ Object
109 110 111 |
# File 'app/helpers/coco/app_helper.rb', line 109 def coco_form_for(*, **, &block) form_for(*, **, builder: Coco::AppFormBuilder, &block) end |
#coco_form_with(&block) ⇒ Object
105 106 107 |
# File 'app/helpers/coco/app_helper.rb', line 105 def coco_form_with(**, &block) form_with(**, builder: Coco::AppFormBuilder, &block) end |
#coco_image_picker_button(&block) ⇒ Object
65 66 67 |
# File 'app/helpers/coco/app_helper.rb', line 65 def (**, &block) render Coco::App::Elements::ImagePickerButton.new(**), &block end |
#coco_layout_picker_button(&block) ⇒ Object
69 70 71 |
# File 'app/helpers/coco/app_helper.rb', line 69 def (**, &block) render Coco::App::Elements::LayoutPickerButton.new(**), &block end |
#coco_link(*args, **kwargs, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/coco/app_helper.rb', line 3 def coco_link(*args, **kwargs, &block) href, content = args[0..2].reverse! if kwargs.key?(:modal) modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal] kwargs[:data] = kwargs.fetch(:data, {}).merge(coco_modal_data_attributes(modal_name)) kwargs.delete(:modal) end if kwargs.key?(:frame) turbo_data = {turbo: true, turbo_frame: kwargs[:frame]} kwargs[:data] = kwargs.fetch(:data, {}).merge(turbo_data) kwargs.delete(:frame) end link = Coco::App::Elements::Link.new(href: href, **kwargs) link = link.with_content(content) if !block && content.present? render(link, &block) end |
#coco_menu_button(&block) ⇒ Object
53 54 55 |
# File 'app/helpers/coco/app_helper.rb', line 53 def (**, &block) render Coco::App::Elements::MenuButton.new(**), &block end |
#coco_notice(&block) ⇒ Object
93 94 95 |
# File 'app/helpers/coco/app_helper.rb', line 93 def coco_notice(**, &block) render Coco::App::Elements::Notice.new(**), &block end |
#coco_seamless_textarea(&block) ⇒ Object
85 86 87 |
# File 'app/helpers/coco/app_helper.rb', line 85 def coco_seamless_textarea(**, &block) render Coco::App::Elements::SeamlessTextarea.new(**), &block end |
#coco_snackbar(&block) ⇒ Object
89 90 91 |
# File 'app/helpers/coco/app_helper.rb', line 89 def (**, &block) render Coco::App::Elements::Snackbar.new(**), &block end |
#coco_system_banner(&block) ⇒ Object
101 102 103 |
# File 'app/helpers/coco/app_helper.rb', line 101 def (**, &block) render Coco::App::Elements::SystemBanner.new(**), &block end |