Sha256: e8919ce31c1679b70ef931b6d8b09d2ae7c90864425406f5ec8e31fc45cfc01e

Contents?: true

Size: 1.56 KB

Versions: 120

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Primer
  module Beta
    # Use `CloseButton` to render an `×` without default button styles.
    #
    # @accessibility
    #   `CloseButton` has a default `aria-label` of "Close" to provides assistive technologies with an accessible label.
    #   You may choose to override this label with something more descriptive via [system_arguments][0].
    # [0]: https://primer.style/view-components/system-arguments#html-attributes
    class CloseButton < Primer::Component
      status :beta

      DEFAULT_TYPE = :button
      TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze

      # @param type [Symbol] <%= one_of(Primer::Beta::CloseButton::TYPE_OPTIONS) %>
      # @param disabled [Boolean] Whether or not the button is disabled.
      # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
      def initialize(type: DEFAULT_TYPE, disabled: false, **system_arguments)
        @system_arguments = deny_tag_argument(**system_arguments)
        @system_arguments[:tag] = :button
        @system_arguments[:block] = false
        @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
        @system_arguments[:classes] = class_names(
          "close-button",
          system_arguments[:classes]
        )
        @system_arguments[:"aria-label"] = aria("label", system_arguments) || "Close"
        @system_arguments[:disabled] = disabled
      end

      def call
        render(Primer::Beta::BaseButton.new(**@system_arguments)) do
          render(Primer::Beta::Octicon.new("x"))
        end
      end
    end
  end
end

Version data entries

120 entries across 120 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.33.0 app/components/primer/beta/close_button.rb
primer_view_components-0.25.1 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.32.1 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.32.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.29.1 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.29.0 app/components/primer/beta/close_button.rb
primer_view_components-0.23.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.28.1 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.28.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.27.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.26.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.25.1 app/components/primer/beta/close_button.rb
primer_view_components-0.22.0 app/components/primer/beta/close_button.rb
primer_view_components-0.21.1 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.25.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.24.0 app/components/primer/beta/close_button.rb
primer_view_components-0.21.0 app/components/primer/beta/close_button.rb
primer_view_components-0.20.1 app/components/primer/beta/close_button.rb
primer_view_components-0.20.0 app/components/primer/beta/close_button.rb
openproject-primer_view_components-0.23.0 app/components/primer/beta/close_button.rb