Sha256: 51171fc62310507c54974e14ffa0379bb1b3222419a7d997c857e12235a1dfc2

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

module Primer
  class DropdownMenuComponent < Primer::Component
    SCHEME_DEFAULT = :default
    SCHEME_MAPPINGS = {
      SCHEME_DEFAULT => "",
      :dark => "dropdown-menu-dark",
    }.freeze

    DIRECTION_DEFAULT = :se
    DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s]

    def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
      @header, @direction, @system_arguments = header, direction, system_arguments

      @system_arguments[:tag] = "details-menu"
      @system_arguments[:role] = "menu"

      @system_arguments[:classes] = class_names(
        @system_arguments[:classes],
        "dropdown-menu",
        "dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
        SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
primer_view_components-0.0.17 app/components/primer/dropdown_menu_component.rb
primer_view_components-0.0.16 app/components/primer/dropdown_menu_component.rb
primer_view_components-0.0.15 app/components/primer/dropdown_menu_component.rb
primer_view_components-0.0.14 app/components/primer/dropdown_menu_component.rb
primer_view_components-0.0.13 app/components/primer/dropdown_menu_component.rb