Sha256: 9a65e6615851f2133bfed10d8fa5172135a26d50b912780fdf947da47ff912da

Contents?: true

Size: 1.95 KB

Versions: 57

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

module Primer
  module Alpha
    class Overlay
      # A `Overlay::Header` is a compositional component, used to render the
      # Header of an overlay. See <%= link_to_component(Primer::Alpha::Overlay) %>.
      class Header < Primer::Component
        DEFAULT_SIZE = :medium
        SIZE_MAPPINGS = {
          DEFAULT_SIZE => nil,
          :large => "Overlay-header--large"
        }.freeze
        SIZE_OPTIONS = SIZE_MAPPINGS.keys

        # @param title [String] Describes the content of the Overlay.
        # @param subtitle [String] Provides additional context for the Overlay, also setting the `aria-describedby` attribute.
        # @param overlay_id [String] Provides the id of the overlay element so the close button can close it
        # @param size [Symbol] The size of the Header. <%= one_of(Primer::Alpha::Overlay::Header::SIZE_OPTIONS) %>
        # @param divider [Boolean] Show a divider between the header and body.
        # @param visually_hide_title [Boolean] Visually hide the `title` while maintaining a label for assistive technologies.
        # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
        def initialize(
          id:,
          title:,
          overlay_id: nil,
          subtitle: nil,
          size: DEFAULT_SIZE,
          divider: false,
          visually_hide_title: false,
          **system_arguments
        )
          @overlay_id = overlay_id
          @id = id
          @title = title
          @subtitle = subtitle
          @visually_hide_title = visually_hide_title
          @system_arguments = deny_tag_argument(**system_arguments)
          @system_arguments[:tag] = :header
          @system_arguments[:classes] = class_names(
            "Overlay-header",
            { "Overlay-header--divided": divider },
            SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)],
            system_arguments[:classes]
          )
        end
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.25.1 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.21.1 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.25.0 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.24.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.21.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.20.1 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.20.0 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.23.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.19.0 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.22.2 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.18.2 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.22.1 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.18.1 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.22.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.18.0 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.21.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.17.0 app/components/primer/alpha/overlay/header.rb
openproject-primer_view_components-0.20.0 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.16.1 app/components/primer/alpha/overlay/header.rb
primer_view_components-0.16.0 app/components/primer/alpha/overlay/header.rb