Module: Coco::AppHelper

Instance Method Summary collapse

Instance Method Details

#coco_app_header(&block) ⇒ Object



121
122
123
# File 'app/helpers/coco/app_helper.rb', line 121

def coco_app_header(*, **, &block)
  render Coco::App::Blocks::Header.new(*, **), &block
end

#coco_color_picker_button(&block) ⇒ Object



24
25
26
# File 'app/helpers/coco/app_helper.rb', line 24

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

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



20
21
22
# File 'app/helpers/coco/app_helper.rb', line 20

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

#coco_contact_callout(&block) ⇒ Object



113
114
115
# File 'app/helpers/coco/app_helper.rb', line 113

def coco_contact_callout(**, &block)
  render Coco::App::Blocks::ContactCallout.new(**), &block
end

#coco_dropdown_button(&block) ⇒ Object



36
37
38
# File 'app/helpers/coco/app_helper.rb', line 36

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

#coco_faqs(&block) ⇒ Object



109
110
111
# File 'app/helpers/coco/app_helper.rb', line 109

def coco_faqs(**, &block)
  render Coco::App::Blocks::Faqs.new(**), &block
end

#coco_fields(&block) ⇒ Object



101
102
103
# File 'app/helpers/coco/app_helper.rb', line 101

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

#coco_form_for(&block) ⇒ Object



97
98
99
# File 'app/helpers/coco/app_helper.rb', line 97

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

#coco_form_with(&block) ⇒ Object



93
94
95
# File 'app/helpers/coco/app_helper.rb', line 93

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

#coco_image_picker_button(&block) ⇒ Object



28
29
30
# File 'app/helpers/coco/app_helper.rb', line 28

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

#coco_layout(name, &block) ⇒ Object



105
106
107
# File 'app/helpers/coco/app_helper.rb', line 105

def coco_layout(name, **, &block)
  render coco_component("app/layouts/#{name}", **), &block
end

#coco_layout_picker_button(&block) ⇒ Object



32
33
34
# File 'app/helpers/coco/app_helper.rb', line 32

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::Link.new(href: href, **)
  link = link.with_content(content) if !block && content.present?

  render(link, &block)
end

#coco_menu_button(&block) ⇒ Object



16
17
18
# File 'app/helpers/coco/app_helper.rb', line 16

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

#coco_menu_item(type, &block) ⇒ Object



133
134
135
# File 'app/helpers/coco/app_helper.rb', line 133

def coco_menu_item(type, **, &block)
  render coco_component("app/elements/menu_items/#{type}", **), &block
end

#coco_notice(&block) ⇒ Object



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

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

#coco_option_bar(&block) ⇒ Object



44
45
46
# File 'app/helpers/coco/app_helper.rb', line 44

def coco_option_bar(**, &block)
  render Coco::App::Elements::OptionBar.new(**), &block
end

#coco_page(id, &block) ⇒ Object



137
138
139
# File 'app/helpers/coco/app_helper.rb', line 137

def coco_page(id, **, &block)
  render coco_component("app/layouts/page", id: id, **), &block
end

#coco_panel(&block) ⇒ Object



89
90
91
# File 'app/helpers/coco/app_helper.rb', line 89

def coco_panel(**, &block)
  render Coco::Panel.new(**), &block
end

#coco_plan_card(&block) ⇒ Object



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

def coco_plan_card(**, &block)
  render Coco::App::Elements::PlanCard.new(**), &block
end

#coco_plan_picker(&block) ⇒ Object



117
118
119
# File 'app/helpers/coco/app_helper.rb', line 117

def coco_plan_picker(**, &block)
  render Coco::App::Blocks::PlanPicker.new(**), &block
end

#coco_seamless_textarea(&block) ⇒ Object



48
49
50
# File 'app/helpers/coco/app_helper.rb', line 48

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

#coco_sidebar_nav(&block) ⇒ Object



125
126
127
# File 'app/helpers/coco/app_helper.rb', line 125

def coco_sidebar_nav(*, **, &block)
  render Coco::App::Blocks::SidebarNav::Navbar.new(*, **), &block
end

#coco_sidebar_nav_menu(&block) ⇒ Object



129
130
131
# File 'app/helpers/coco/app_helper.rb', line 129

def coco_sidebar_nav_menu(*, **, &block)
  render Coco::App::Blocks::SidebarNav::Menu.new(*, **), &block
end

#coco_snackbar(&block) ⇒ Object



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

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

#coco_stamp(type = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/coco/app_helper.rb', line 52

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

#coco_system_banner(&block) ⇒ Object



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

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

#coco_toast(&block) ⇒ Object



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

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

#coco_toolbar(&block) ⇒ Object



40
41
42
# File 'app/helpers/coco/app_helper.rb', line 40

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