Class: Primer::OpenProject::PageHeader
- Defined in:
- app/components/primer/open_project/page_header.rb,
app/components/primer/open_project/page_header/menu.rb,
app/components/primer/open_project/page_header/title.rb,
app/components/primer/open_project/page_header/dialog.rb
Overview
A ViewComponent PageHeader inspired by the primer react variant
Defined Under Namespace
Constant Summary collapse
- DEFAULT_HEADER_VARIANT =
:medium
- HEADER_VARIANT_OPTIONS =
[ DEFAULT_HEADER_VARIANT, :large ].freeze
- DEFAULT_BACK_BUTTON_ICON =
"arrow-left"
- BACK_BUTTON_ICON_OPTIONS =
[ DEFAULT_BACK_BUTTON_ICON, "chevron-left", "triangle-left" ].freeze
- DEFAULT_ACTION_SCHEME =
:default
- MOBILE_ACTIONS_DISPLAY =
[:flex, :none].freeze
- DEFAULT_LEADING_ACTION_DISPLAY =
[:none, :flex].freeze
- DEFAULT_BREADCRUMBS_DISPLAY =
[:none, :flex].freeze
- DEFAULT_PARENT_LINK_DISPLAY =
[:block, :none].freeze
- STATE_DEFAULT =
:show
- STATE_EDIT =
:edit
- STATE_OPTIONS =
[STATE_DEFAULT, STATE_EDIT].freeze
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(mobile_menu_label: I18n.t("label_more"), state: STATE_DEFAULT, **system_arguments) ⇒ PageHeader
constructor
A new instance of PageHeader.
- #render? ⇒ Boolean
- #render_mobile_menu? ⇒ Boolean
- #show_state? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(mobile_menu_label: I18n.t("label_more"), state: STATE_DEFAULT, **system_arguments) ⇒ PageHeader
Returns a new instance of PageHeader.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'app/components/primer/open_project/page_header.rb', line 235 def initialize(mobile_menu_label: I18n.t("label_more"), state: STATE_DEFAULT, **system_arguments) @system_arguments = deny_tag_argument(**system_arguments) @mobile_menu_label = @system_arguments[:tag] = :"page-header" @system_arguments[:classes] = class_names( @system_arguments[:classes], "PageHeader" ) @state = fetch_or_fallback(STATE_OPTIONS, state, STATE_DEFAULT) @mobile_action_menu = Primer::Alpha::ActionMenu.new( display: MOBILE_ACTIONS_DISPLAY, anchor_align: :end ) end |
Instance Method Details
#render? ⇒ Boolean
254 255 256 257 258 259 |
# File 'app/components/primer/open_project/page_header.rb', line 254 def render? raise ArgumentError, "PageHeader needs a title and a breadcrumb. Please use the `with_title` and `with_breadcrumbs` slot" unless || Rails.env.production? raise ArgumentError, "PageHeader allows only a maximum of 5 actions" if actions.count > 5 title? && end |
#render_mobile_menu? ⇒ Boolean
261 262 263 |
# File 'app/components/primer/open_project/page_header.rb', line 261 def actions.count > 1 end |
#show_state? ⇒ Boolean
265 266 267 |
# File 'app/components/primer/open_project/page_header.rb', line 265 def show_state? @state == STATE_DEFAULT end |