Module: Coco::AppHelper

Instance Method Summary collapse

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 coco_button(*args, **kwargs, &block)
  href, content = if block
    [args.first, nil]
  else
    (args.size == 1) ? [nil, args.first] : args[0..2].reverse!
  end

  button = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params)
    "ButtonTo"
  else
    "Button"
  end

  component = "Coco::App::Elements::#{button}".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 coco_button_group(**, &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 coco_color_picker_button(**, &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 coco_confirm_button(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 coco_dropdown_button(**, &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 coco_image_picker_button(**, &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 coco_layout_picker_button(**, &block)
  render Coco::App::Elements::LayoutPickerButton.new(**), &block
end


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 coco_menu_button(**, &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 coco_menu_item(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 coco_sidebar_nav(*, **, &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 coco_sidebar_nav_menu(*, **, &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 coco_snackbar(**, &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 coco_system_banner(**, &block)
  render Coco::App::Elements::SystemBanner.new(**), &block
end

#coco_toast(&block) ⇒ Object



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

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

#coco_toolbar(&block) ⇒ Object



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

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