Class: Polaris::PageComponent
- Defined in:
- app/components/polaris/page_component.rb
Defined Under Namespace
Classes: ActionGroupComponent
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #content_arguments ⇒ Object
- #has_pagination? ⇒ Boolean
- #header_arguments ⇒ Object
-
#initialize(title: nil, subtitle: nil, compact_title: false, back_url: nil, prev_url: nil, next_url: nil, narrow_width: false, full_width: false, divider: false, secondary_actions: [], **system_arguments) ⇒ PageComponent
constructor
A new instance of PageComponent.
- #render_header? ⇒ Boolean
- #render_primary_action? ⇒ Boolean
- #subtitle_arguments ⇒ Object
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_icon_source, #polaris_inversed_colors
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Methods included from ClassNameHelper
Constructor Details
#initialize(title: nil, subtitle: nil, compact_title: false, back_url: nil, prev_url: nil, next_url: nil, narrow_width: false, full_width: false, divider: false, secondary_actions: [], **system_arguments) ⇒ PageComponent
Returns a new instance of PageComponent.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/polaris/page_component.rb', line 13 def initialize( title: nil, subtitle: nil, compact_title: false, back_url: nil, prev_url: nil, next_url: nil, narrow_width: false, full_width: false, divider: false, secondary_actions: [], **system_arguments ) @title = title @subtitle = subtitle @compact_title = compact_title @back_url = back_url @prev_url = prev_url @next_url = next_url @narrow_width = narrow_width @full_width = full_width @divider = divider @secondary_actions = secondary_actions @system_arguments = system_arguments end |
Instance Method Details
#content_arguments ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'app/components/polaris/page_component.rb', line 62 def content_arguments { tag: "div", classes: class_names( "Polaris-Page__Content", "Polaris-Page--divider": @divider ) } end |
#has_pagination? ⇒ Boolean
92 93 94 |
# File 'app/components/polaris/page_component.rb', line 92 def has_pagination? @next_url.present? || @prev_url.present? end |
#header_arguments ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/polaris/page_component.rb', line 39 def header_arguments { tag: "div", classes: class_names( "Polaris-Page-Header", "Polaris-Page-Header--mobileView", "Polaris-Page-Header--mediumTitle", "Polaris-Page-Header--hasNavigation": @back_url.present?, "Polaris-Page-Header--noBreadcrumbs": @back_url.blank? ) } end |
#render_header? ⇒ Boolean
84 85 86 |
# File 'app/components/polaris/page_component.rb', line 84 def render_header? @title.present? || @subtitle.present? || @back_url.present? || render_primary_action? end |
#render_primary_action? ⇒ Boolean
88 89 90 |
# File 'app/components/polaris/page_component.rb', line 88 def render_primary_action? primary_action.present? || custom_primary_action.present? end |
#subtitle_arguments ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/components/polaris/page_component.rb', line 52 def subtitle_arguments { tag: "div", classes: class_names( "Polaris-Header-Title__SubTitle", "Polaris-Header-Title__SubtitleCompact": @compact_title ) } end |
#system_arguments ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/components/polaris/page_component.rb', line 72 def system_arguments @system_arguments.tap do |opts| opts[:tag] = "div" opts[:classes] = class_names( opts[:classes], "Polaris-Page", "Polaris-Page--narrowWidth": @narrow_width, "Polaris-Page--fullWidth": @full_width ) end end |