Module: PolarisViewHelpers::Helper

Defined in:
lib/polaris_view_helpers/helper.rb

Instance Method Summary collapse

Instance Method Details

#polaris_annotated_section(heading: '', description: '', &block) ⇒ Object



135
136
137
138
139
140
141
142
143
144
# File 'lib/polaris_view_helpers/helper.rb', line 135

def polaris_annotated_section(heading:'', description:'', &block)
  render(
    partial: 'polaris/annotated_section',
    locals: {
      heading: heading,
      description: description,
      block: block
    }
  )
end

#polaris_annotated_section_input(form, attribute, input, &block) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/polaris_view_helpers/helper.rb', line 221

def polaris_annotated_section_input(form, attribute, input, &block)
  unless attribute.is_a? Array
    attribute = [attribute]
  end

  render(
    partial: 'polaris/annotated_section_input',
    locals: {
      form: form,
      attribute: attribute,
      input: input,
      block: block
    }
  )
end

#polaris_annotated_section_select(form, attribute, select_options = [], element_type = :select, &block) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/polaris_view_helpers/helper.rb', line 204

def polaris_annotated_section_select(form, attribute, select_options = [], element_type = :select, &block)
  unless attribute.is_a? Array
    attribute = [attribute]
  end

  render(
    partial: 'polaris/annotated_section_select',
    locals: {
      form: form,
      attribute: attribute,
      element_type: element_type,
      select_options: select_options,
      block: block
    }
  )
end

#polaris_annotated_section_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/polaris_view_helpers/helper.rb', line 187

def polaris_annotated_section_text_field(form, attribute, options = {}, element_type = :text_field, &block)
  unless attribute.is_a? Array
    attribute = [attribute]
  end

  render(
    partial: 'polaris/annotated_section_text_field',
    locals: {
      form: form,
      attribute: attribute,
      element_type: element_type,
      options: options,
      block: block
    }
  )
end

#polaris_banner(options, &block) ⇒ Object



71
72
73
74
75
76
# File 'lib/polaris_view_helpers/helper.rb', line 71

def polaris_banner(options, &block)
  render(
    partial: 'polaris/banner',
    locals: { options: options, block: block }
  )
end

#polaris_banner_actions(&block) ⇒ Object



78
79
80
81
82
83
# File 'lib/polaris_view_helpers/helper.rb', line 78

def polaris_banner_actions(&block)
  render(
    partial: 'polaris/banner_actions',
    locals: { block: block }
  )
end


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/polaris_view_helpers/helper.rb', line 85

def polaris_button_link_to(name = nil, link_destination = nil, button_options = nil, &block)
  if block_given?
    button_options, link_destination, name = link_destination, name, nil
  end
  button_options ||= {}

  additional_classes = ""
  (button_options[:modifiers] || []).each do |modifier|
    additional_classes += "Polaris-Button--#{modifier} "
  end
  render(
    partial: 'polaris/button_link_to',
    locals: {
      name: name,
      block: block,
      additional_classes: additional_classes,
      link_destination: link_destination,
      method: button_options[:method]
    }
  )
end

#polaris_button_tag(name, button_options) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/polaris_view_helpers/helper.rb', line 121

def polaris_button_tag(name, button_options)
  additional_classes = ""
  (button_options[:modifiers] || []).each do |modifier|
    additional_classes += "Polaris-Button--#{modifier} "
  end

  button_options[:additional_classes] = additional_classes
  button_options[:name] = name
  render(
    partial: 'polaris/button_tag',
    locals: button_options
  )
end

#polaris_css(version = '1.6.0') ⇒ Object



4
5
6
# File 'lib/polaris_view_helpers/helper.rb', line 4

def polaris_css version = '1.6.0'
  %[<link rel="stylesheet" href="https://sdks.shopifycdn.com/polaris/#{version}/polaris.min.css" />].html_safe
end

#polaris_form_layout(&block) ⇒ Object



43
44
45
46
47
48
# File 'lib/polaris_view_helpers/helper.rb', line 43

def polaris_form_layout(&block)
  render(
    partial: 'polaris/form_layout',
    locals: { block: block }
  )
end

#polaris_form_layout_item(form, att, text = nil, &block) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/polaris_view_helpers/helper.rb', line 146

def polaris_form_layout_item(form, att, text = nil, &block)
  render(
    partial: 'polaris/form_layout_item',
    locals: {
      form: form,
      att: att,
      text: text,
      block: block
    }
  )
end

#polaris_form_layout_item_select(form, att, text = nil, &block) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/polaris_view_helpers/helper.rb', line 158

def polaris_form_layout_item_select(form, att, text = nil, &block)
  render(
    partial: 'polaris/form_layout_item_select',
    locals: {
      form: form,
      att: att,
      text: text,
      block: block
    }
  )
end

#polaris_heading(title) ⇒ Object



22
23
24
25
26
27
# File 'lib/polaris_view_helpers/helper.rb', line 22

def polaris_heading(title)
  render(
    partial: 'polaris/heading',
    locals: { title: title }
  )
end

#polaris_layout(&block) ⇒ Object



36
37
38
39
40
41
# File 'lib/polaris_view_helpers/helper.rb', line 36

def polaris_layout(&block)
  render(
    partial: 'polaris/layout',
    locals: { block: block }
  )
end

#polaris_model_errors(model) ⇒ Object



107
108
109
110
111
112
# File 'lib/polaris_view_helpers/helper.rb', line 107

def polaris_model_errors model
  render(
    partial: 'polaris/model_errors',
    locals: { model: model }
  )
end

#polaris_page(&block) ⇒ Object



8
9
10
11
12
13
# File 'lib/polaris_view_helpers/helper.rb', line 8

def polaris_page(&block)
  render(
    partial: 'polaris/page',
    locals: { block: block }
  )
end

#polaris_page_actions(options) ⇒ Object



114
115
116
117
118
119
# File 'lib/polaris_view_helpers/helper.rb', line 114

def polaris_page_actions(options)
  render(
    partial: 'polaris/page_actions',
    locals: options
  )
end

#polaris_page_content(&block) ⇒ Object



29
30
31
32
33
34
# File 'lib/polaris_view_helpers/helper.rb', line 29

def polaris_page_content(&block)
  render(
    partial: 'polaris/page_content',
    locals: { block: block }
  )
end

#polaris_page_header(title, &block) ⇒ Object



15
16
17
18
19
20
# File 'lib/polaris_view_helpers/helper.rb', line 15

def polaris_page_header(title, &block)
  render(
    partial: 'polaris/page_header',
    locals: { title: title, block: block }
  )
end

#polaris_tab(text, link_path, active = nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/polaris_view_helpers/helper.rb', line 57

def polaris_tab(text, link_path, active = nil)
  unless active.present?
    active = link_path == request.original_fullpath
  end
  render(
    partial: 'polaris/tab',
    locals: {
      text: text,
      link_path: link_path,
      active: active
    }
  )
end

#polaris_tabs(&block) ⇒ Object



50
51
52
53
54
55
# File 'lib/polaris_view_helpers/helper.rb', line 50

def polaris_tabs(&block)
  render(
    partial: 'polaris/tabs',
    locals: { block: block }
  )
end

#polaris_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/polaris_view_helpers/helper.rb', line 170

def polaris_text_field(form, attribute, options = {}, element_type = :text_field, &block)
  unless attribute.is_a? Array
    attribute = [attribute]
  end

  render(
    partial: 'polaris/text_field',
    locals: {
      form: form,
      attribute: attribute,
      element_type: element_type,
      options: options,
      block: block
    }
  )
end