module PolarisViewHelpers::Helper

Public Instance Methods

polaris_annotated_section(heading:'', description:'', &block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 193
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 283
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 266
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 249
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_badge(content, status = nil) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 314
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 103
def polaris_banner(options, &block)
  render(
    partial: 'polaris/banner',
    locals: { options: options, block: block }
  )
end
polaris_banner_actions(&block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 110
def polaris_banner_actions(&block)
  render(
    partial: 'polaris/banner_actions',
    locals: { block: block }
  )
end
polaris_button_tag(name, button_options) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 179
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_card(heading = nil, footer: nil, &block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 343
def polaris_card(heading = nil, footer: nil, &block)
  render(
    partial: 'polaris/card',
    locals: { block: block, heading: heading, footer: footer }
  )
end
polaris_choice_list(form:, attribute:, title:, selected:, choices:) click to toggle source
# 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') click to toggle source
# 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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 329
def polaris_description_list(&block)
  render(
    partial: 'polaris/description_list',
    locals: { block: block }
  )
end
polaris_description_list_item(term, &block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 336
def polaris_description_list_item(term, &block)
  render(
    partial: 'polaris/description_list_item',
    locals: { block: block, term: term }
  )
end
polaris_form_layout(&block) click to toggle source
# 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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 204
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 216
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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 39
def polaris_heading(title)
  render(
    partial: 'polaris/heading',
    locals: { title: title }
  )
end
polaris_layout(&block) click to toggle source
# 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) click to toggle source
# 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_model_errors(model) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 165
def polaris_model_errors model
  render(
    partial: 'polaris/model_errors',
    locals: { model: model }
  )
end
polaris_page(&block) click to toggle source
# 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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 172
def polaris_page_actions(options)
  render(
    partial: 'polaris/page_actions',
    locals: options
  )
end
polaris_page_content(&block) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 8
def polaris_random_input_name
  "pri-#{SecureRandom.hex(8)}"
end
polaris_resource_list(&block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 299
def polaris_resource_list(&block)
  render(
    partial: 'polaris/resource_list',
    locals: { block: block }
  )
end
polaris_resource_list_item(attributes) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 306
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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 245
def polaris_text_area(form, attribute, options = {}, element_type = :text_area, &block)
  polaris_text_field(form, attribute, options, element_type, &block)
end
polaris_text_field(form, attribute, options = {}, element_type = :text_field, &block) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 228
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
polaris_thumbnail(attributes) click to toggle source
# File lib/polaris_view_helpers/helper.rb, line 322
def polaris_thumbnail(attributes)
  render(
    partial: 'polaris/thumbnail',
    locals: { attributes: attributes }
  )
end