Sha256: 0dccbf0153a516cc4a9b3eea3835de0b433f3ee761edae1100621453273b48c3

Contents?: true

Size: 1.19 KB

Versions: 42

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Primer
  module OpenProject
    class PageHeader
      # A Helper class to create ActionMenus inside the PageHeader action slot
      # It should not be used standalone
      class Menu < Primer::Component
        status :open_project

        # @param menu_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionMenu) %>.
        # @param button_arguments [Hash] 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.
        def initialize(menu_arguments: {}, button_arguments: {})
          callback = button_arguments.delete(:button_block)

          @menu = Primer::Alpha::ActionMenu.new(**menu_arguments)
          @button = @menu.with_show_button(**button_arguments) do |button|
            callback&.call(button)
          end
        end

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

        def before_render
          content
        end

        def call
          render(@menu)
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.49.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.49.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.48.2 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.48.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.48.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.47.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.47.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.46.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.46.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.45.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.44.3 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.44.2 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.44.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.44.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.43.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.43.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.42.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.41.1 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.41.0 app/components/primer/open_project/page_header/menu.rb
openproject-primer_view_components-0.40.0 app/components/primer/open_project/page_header/menu.rb