Module: Coco::AppHelper

Instance Method Summary collapse

Instance Method Details

#coco_button(href = nil, **kwargs, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/coco/app_helper.rb', line 11

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

#coco_button_group(**kwargs, &block) ⇒ Object



50
51
52
# File 'app/helpers/coco/app_helper.rb', line 50

def coco_button_group(**kwargs, &block)
  render Coco::App::Elements::ButtonGroup.new(**kwargs), &block
end

#coco_color_picker_button(**kwargs, &block) ⇒ Object



34
35
36
# File 'app/helpers/coco/app_helper.rb', line 34

def coco_color_picker_button(**kwargs, &block)
  render Coco::App::Elements::ColorPickerButton.new(**kwargs), &block
end

#coco_confirm_button(href = nil, **kwargs, &block) ⇒ Object



30
31
32
# File 'app/helpers/coco/app_helper.rb', line 30

def coco_confirm_button(href = nil, **kwargs, &block)
  render Coco::App::Elements::ConfirmButton.new(href: href, **kwargs), &block
end

#coco_dropdown_button(**kwargs, &block) ⇒ Object



46
47
48
# File 'app/helpers/coco/app_helper.rb', line 46

def coco_dropdown_button(**kwargs, &block)
  render Coco::App::Elements::DropdownButton.new(**kwargs), &block
end

#coco_fields(**kwargs, &block) ⇒ Object



86
87
88
# File 'app/helpers/coco/app_helper.rb', line 86

def coco_fields(**kwargs, &block)
  fields(**kwargs, builder: Coco::AppFormBuilder, &block)
end

#coco_form_button(**kwargs, &block) ⇒ Object



22
23
24
# File 'app/helpers/coco/app_helper.rb', line 22

def coco_form_button(**kwargs, &block)
  render Coco::App::Elements::FormButton.new(**kwargs), &block
end

#coco_form_for(*args, **kwargs, &block) ⇒ Object



82
83
84
# File 'app/helpers/coco/app_helper.rb', line 82

def coco_form_for(*args, **kwargs, &block)
  form_for(*args, **kwargs, builder: Coco::AppFormBuilder, &block)
end

#coco_form_with(**kwargs, &block) ⇒ Object



78
79
80
# File 'app/helpers/coco/app_helper.rb', line 78

def coco_form_with(**kwargs, &block)
  form_with(**kwargs, builder: Coco::AppFormBuilder, &block)
end

#coco_image_picker_button(**kwargs, &block) ⇒ Object



38
39
40
# File 'app/helpers/coco/app_helper.rb', line 38

def coco_image_picker_button(**kwargs, &block)
  render Coco::App::Elements::ImagePickerButton.new(**kwargs), &block
end

#coco_layout_picker_button(**kwargs, &block) ⇒ Object



42
43
44
# File 'app/helpers/coco/app_helper.rb', line 42

def coco_layout_picker_button(**kwargs, &block)
  render Coco::App::Elements::LayoutPickerButton.new(**kwargs), &block
end


3
4
5
6
7
8
9
# File 'app/helpers/coco/app_helper.rb', line 3

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

#coco_menu_button(**kwargs, &block) ⇒ Object



26
27
28
# File 'app/helpers/coco/app_helper.rb', line 26

def coco_menu_button(**kwargs, &block)
  render Coco::App::Elements::MenuButton.new(**kwargs), &block
end

#coco_notice(**kwargs, &block) ⇒ Object



66
67
68
# File 'app/helpers/coco/app_helper.rb', line 66

def coco_notice(**kwargs, &block)
  render Coco::App::Elements::Notice.new(**kwargs), &block
end

#coco_seamless_textarea(**kwargs, &block) ⇒ Object



58
59
60
# File 'app/helpers/coco/app_helper.rb', line 58

def coco_seamless_textarea(**kwargs, &block)
  render Coco::App::Elements::SeamlessTextarea.new(**kwargs), &block
end

#coco_snackbar(**kwargs, &block) ⇒ Object



62
63
64
# File 'app/helpers/coco/app_helper.rb', line 62

def coco_snackbar(**kwargs, &block)
  render Coco::App::Elements::Snackbar.new(**kwargs), &block
end

#coco_system_banner(**kwargs, &block) ⇒ Object



74
75
76
# File 'app/helpers/coco/app_helper.rb', line 74

def coco_system_banner(**kwargs, &block)
  render Coco::App::Elements::SystemBanner.new(**kwargs), &block
end

#coco_toast(**kwargs, &block) ⇒ Object



70
71
72
# File 'app/helpers/coco/app_helper.rb', line 70

def coco_toast(**kwargs, &block)
  render Coco::App::Elements::Toast.new(**kwargs), &block
end

#coco_toolbar(**kwargs, &block) ⇒ Object



54
55
56
# File 'app/helpers/coco/app_helper.rb', line 54

def coco_toolbar(**kwargs, &block)
  render Coco::App::Elements::Toolbar.new(**kwargs), &block
end