Class: Primer::OpenProject::PageHeader::Dialog

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/open_project/page_header/dialog.rb

Overview

A Helper class to create ActionMenus inside the PageHeader action slot Do not use standalone

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

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

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(dialog_arguments: {}, button_arguments: {}) ⇒ Dialog

Returns a new instance of Dialog.

Parameters:

  • dialog_arguments (Hash) (defaults to: {})

    The arguments accepted by <%= link_to_component(Primer::Alpha::Dialog) %>.

  • button_arguments (Hash) (defaults to: {})

    The arguments accepted by <%= link_to_component(Primer::Beta::Button) %> or <%= link_to_component(Primer::Beta::IconButton) %>, depending on the value of the ‘icon:` argument.



13
14
15
16
17
18
19
20
# File 'app/components/primer/open_project/page_header/dialog.rb', line 13

def initialize(dialog_arguments: {}, button_arguments: {})
  callback = button_arguments.delete(:button_block)

  @dialog = Primer::Alpha::Dialog.new(**dialog_arguments)
  @button = @dialog.with_show_button(**button_arguments) do |button|
    callback&.call(button)
  end
end

Instance Method Details

#before_renderObject



28
29
30
# File 'app/components/primer/open_project/page_header/dialog.rb', line 28

def before_render
  content
end

#callObject



32
33
34
# File 'app/components/primer/open_project/page_header/dialog.rb', line 32

def call
  render(@dialog)
end

#render_in(view_context, &block) ⇒ Object



22
23
24
25
26
# File 'app/components/primer/open_project/page_header/dialog.rb', line 22

def render_in(view_context, &block)
  super(view_context) do
    block&.call(@dialog, @button)
  end
end