Module: PolarisViewHelpers::Helper
- Defined in:
- lib/polaris_view_helpers/helper.rb
Instance Method Summary collapse
- #polaris_annotated_section(heading: '', description: '', &block) ⇒ Object
- #polaris_annotated_section_input(form, attribute, input, &block) ⇒ Object
- #polaris_annotated_section_select(form, attribute, select_options = [], element_type = :select, &block) ⇒ Object
- #polaris_annotated_section_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object
- #polaris_badge(content, status = nil) ⇒ Object
- #polaris_banner(options, &block) ⇒ Object
- #polaris_banner_actions(&block) ⇒ Object
- #polaris_button_link_to(name = nil, link_destination = nil, button_options = nil, &block) ⇒ Object
- #polaris_button_tag(name, button_options) ⇒ Object
- #polaris_card(heading = nil, footer: nil, &block) ⇒ Object
- #polaris_choice_list(form:, attribute:, title:, selected:, choices:) ⇒ Object
- #polaris_css(version = '5.12.0') ⇒ Object
- #polaris_description_list(&block) ⇒ Object
- #polaris_description_list_item(term, &block) ⇒ Object
- #polaris_footer_help(icon: 'next-help-circle', &block) ⇒ Object
- #polaris_form_layout(&block) ⇒ Object
- #polaris_form_layout_item(form, att, text = nil, &block) ⇒ Object
- #polaris_form_layout_item_select(form, att, text = nil, &block) ⇒ Object
- #polaris_heading(title) ⇒ Object
- #polaris_layout(&block) ⇒ Object
- #polaris_layout_section(secondary: false, &block) ⇒ Object
- #polaris_link_to(name = nil, link_destination = nil, button_options = nil, &block) ⇒ Object
- #polaris_model_errors(model) ⇒ Object
- #polaris_page(&block) ⇒ Object
- #polaris_page_actions(options) ⇒ Object
- #polaris_page_content(&block) ⇒ Object
- #polaris_page_header(title, &block) ⇒ Object
- #polaris_random_input_name ⇒ Object
- #polaris_resource_list(&block) ⇒ Object
- #polaris_resource_list_item(attributes) ⇒ Object
- #polaris_sub_heading(title) ⇒ Object
- #polaris_tab(text, link_path, active = nil) ⇒ Object
- #polaris_tabs(&block) ⇒ Object
- #polaris_text_area(form, attribute, options = {}, element_type = :text_area, &block) ⇒ Object
- #polaris_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object
- #polaris_thumbnail(attributes) ⇒ Object
Instance Method Details
#polaris_annotated_section(heading: '', description: '', &block) ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/polaris_view_helpers/helper.rb', line 192 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
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/polaris_view_helpers/helper.rb', line 282 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
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/polaris_view_helpers/helper.rb', line 265 def polaris_annotated_section_select(form, attribute, = [], 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: , block: block } ) end |
#polaris_annotated_section_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/polaris_view_helpers/helper.rb', line 248 def polaris_annotated_section_text_field(form, attribute, = {}, 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: , block: block } ) end |
#polaris_badge(content, status = nil) ⇒ Object
313 314 315 316 317 318 319 |
# File 'lib/polaris_view_helpers/helper.rb', line 313 def polaris_badge(content, status = nil) extra_class = status.present? ? "Polaris-Badge--status#{status.to_s.capitalize}" : "" render( partial: 'polaris/badge', locals: { content: content, status: status, extra_class: extra_class } ) end |
#polaris_banner(options, &block) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/polaris_view_helpers/helper.rb', line 103 def (, &block) render( partial: 'polaris/banner', locals: { options: , block: block } ) end |
#polaris_banner_actions(&block) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/polaris_view_helpers/helper.rb', line 110 def (&block) render( partial: 'polaris/banner_actions', locals: { block: block } ) end |
#polaris_button_link_to(name = nil, link_destination = nil, button_options = nil, &block) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/polaris_view_helpers/helper.rb', line 117 def (name = nil, link_destination = nil, = nil, &block) if block_given? , link_destination, name = link_destination, name, nil end ||= {} additional_classes = "" ([: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: [:method], remote: [:remote], confirm: [:confirm] } ) end |
#polaris_button_tag(name, button_options) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/polaris_view_helpers/helper.rb', line 178 def (name, ) additional_classes = "" ([:modifiers] || []).each do |modifier| additional_classes += "Polaris-Button--#{modifier} " end [:additional_classes] = additional_classes [:name] = name render( partial: 'polaris/button_tag', locals: ) end |
#polaris_card(heading = nil, footer: nil, &block) ⇒ Object
342 343 344 345 346 347 |
# File 'lib/polaris_view_helpers/helper.rb', line 342 def polaris_card(heading = nil, footer: nil, &block) render( partial: 'polaris/card', locals: { block: block, heading: heading, footer: } ) end |
#polaris_choice_list(form:, attribute:, title:, selected:, choices:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/polaris_view_helpers/helper.rb', line 12 def polaris_choice_list(form:, attribute:, title:, selected:, choices:) render( partial: 'polaris/choice_list', locals: { form: form, attribute: attribute, title: title, selected: selected, choices: choices } ) end |
#polaris_css(version = '5.12.0') ⇒ Object
4 5 6 |
# File 'lib/polaris_view_helpers/helper.rb', line 4 def polaris_css version = '5.12.0' %[<link rel="stylesheet" href="https://unpkg.com/@shopify/polaris@#{version}/dist/styles.css" />].html_safe end |
#polaris_description_list(&block) ⇒ Object
328 329 330 331 332 333 |
# File 'lib/polaris_view_helpers/helper.rb', line 328 def polaris_description_list(&block) render( partial: 'polaris/description_list', locals: { block: block } ) end |
#polaris_description_list_item(term, &block) ⇒ Object
335 336 337 338 339 340 |
# File 'lib/polaris_view_helpers/helper.rb', line 335 def polaris_description_list_item(term, &block) render( partial: 'polaris/description_list_item', locals: { block: block, term: term } ) end |
#polaris_footer_help(icon: 'next-help-circle', &block) ⇒ Object
349 350 351 352 353 354 |
# File 'lib/polaris_view_helpers/helper.rb', line 349 def (icon: 'next-help-circle', &block) render( partial: 'polaris/footer_help', locals: { block: block, icon: icon } ) end |
#polaris_form_layout(&block) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/polaris_view_helpers/helper.rb', line 75 def polaris_form_layout(&block) render( partial: 'polaris/form_layout', locals: { block: block } ) end |
#polaris_form_layout_item(form, att, text = nil, &block) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/polaris_view_helpers/helper.rb', line 203 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
215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/polaris_view_helpers/helper.rb', line 215 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
39 40 41 42 43 44 |
# File 'lib/polaris_view_helpers/helper.rb', line 39 def polaris_heading(title) render( partial: 'polaris/heading', locals: { title: title } ) end |
#polaris_layout(&block) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/polaris_view_helpers/helper.rb', line 60 def polaris_layout(&block) render( partial: 'polaris/layout', locals: { block: block } ) end |
#polaris_layout_section(secondary: false, &block) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/polaris_view_helpers/helper.rb', line 67 def polaris_layout_section(secondary: false, &block) extra_class = secondary ? "Polaris-Layout__Section--secondary" : "" render( partial: 'polaris/layout_section', locals: { block: block, extra_class: extra_class } ) end |
#polaris_link_to(name = nil, link_destination = nil, button_options = nil, &block) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/polaris_view_helpers/helper.rb', line 141 def polaris_link_to(name = nil, link_destination = nil, = nil, &block) if block_given? , link_destination, name = link_destination, name, nil end ||= {} additional_classes = "" ([:modifiers] || []).each do |modifier| additional_classes += "Polaris-Button--#{modifier} " end render( partial: 'polaris/link_to', locals: { name: name, block: block, additional_classes: additional_classes, link_destination: link_destination, method: [:method], confirm: [:confirm] } ) end |
#polaris_model_errors(model) ⇒ Object
164 165 166 167 168 169 |
# File 'lib/polaris_view_helpers/helper.rb', line 164 def polaris_model_errors model render( partial: 'polaris/model_errors', locals: { model: model } ) end |
#polaris_page(&block) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/polaris_view_helpers/helper.rb', line 25 def polaris_page(&block) render( partial: 'polaris/page', locals: { block: block } ) end |
#polaris_page_actions(options) ⇒ Object
171 172 173 174 175 176 |
# File 'lib/polaris_view_helpers/helper.rb', line 171 def polaris_page_actions() render( partial: 'polaris/page_actions', locals: ) end |
#polaris_page_content(&block) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/polaris_view_helpers/helper.rb', line 53 def polaris_page_content(&block) render( partial: 'polaris/page_content', locals: { block: block } ) end |
#polaris_page_header(title, &block) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/polaris_view_helpers/helper.rb', line 32 def polaris_page_header(title, &block) render( partial: 'polaris/page_header', locals: { title: title, block: block } ) end |
#polaris_random_input_name ⇒ Object
8 9 10 |
# File 'lib/polaris_view_helpers/helper.rb', line 8 def polaris_random_input_name "pri-#{SecureRandom.hex(8)}" end |
#polaris_resource_list(&block) ⇒ Object
298 299 300 301 302 303 |
# File 'lib/polaris_view_helpers/helper.rb', line 298 def polaris_resource_list(&block) render( partial: 'polaris/resource_list', locals: { block: block } ) end |
#polaris_resource_list_item(attributes) ⇒ Object
305 306 307 308 309 310 311 |
# File 'lib/polaris_view_helpers/helper.rb', line 305 def polaris_resource_list_item(attributes) extra_classes = attributes[:media].present? ? "Polaris-ResourceList__Item--mediaThumbnail Polaris-ResourceList__Item--sizeMedium" : "" render( partial: 'polaris/resource_list_item', locals: { attributes: attributes, extra_classes: extra_classes } ) end |
#polaris_sub_heading(title) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/polaris_view_helpers/helper.rb', line 46 def polaris_sub_heading(title) render( partial: 'polaris/sub_heading', locals: { title: title } ) end |
#polaris_tab(text, link_path, active = nil) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/polaris_view_helpers/helper.rb', line 89 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
82 83 84 85 86 87 |
# File 'lib/polaris_view_helpers/helper.rb', line 82 def polaris_tabs(&block) render( partial: 'polaris/tabs', locals: { block: block } ) end |
#polaris_text_area(form, attribute, options = {}, element_type = :text_area, &block) ⇒ Object
244 245 246 |
# File 'lib/polaris_view_helpers/helper.rb', line 244 def polaris_text_area(form, attribute, = {}, element_type = :text_area, &block) polaris_text_field(form, attribute, , element_type, &block) end |
#polaris_text_field(form, attribute, options = {}, element_type = :text_field, &block) ⇒ Object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/polaris_view_helpers/helper.rb', line 227 def polaris_text_field(form, attribute, = {}, 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: , block: block } ) end |
#polaris_thumbnail(attributes) ⇒ Object
321 322 323 324 325 326 |
# File 'lib/polaris_view_helpers/helper.rb', line 321 def polaris_thumbnail(attributes) render( partial: 'polaris/thumbnail', locals: { attributes: attributes } ) end |