Sha256: ee3c725ad5dff36aa0910abf394493729653a81ee442c0ae3a8ed330f4498bad

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Primer
  module Alpha
    # Use `HellipButton` to render a button with a hellip. Often used for hidden text expanders.
    # @accessibility
    #   Always set an accessible label to help the user interact with the component.
    #
    #   * This button is displaying a hellip as its content (The three dots character). Therefore a label is needed for screen readers.
    #   * Set the attribute `aria-label` on the system arguments. E.g. `Primer::Alpha::HellipButton.new("aria-label": "Expand next part")`
    class HellipButton < Primer::Component
      # @example Default
      #   <%= render(Primer::Alpha::HellipButton.new("aria-label": "No effect")) %>
      #
      # @example Inline
      #   <%= render(Primer::Alpha::HellipButton.new(inline: true, "aria-label": "No effect")) %>
      #
      # @example Styling the button
      #   <%= render(Primer::Alpha::HellipButton.new(p: 1, classes: "custom-class", "aria-label": "No effect")) %>
      #
      # @param inline [Boolean] Whether or not the button is inline.
      # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
      def initialize(inline: false, **system_arguments)
        @system_arguments = deny_tag_argument(**system_arguments)

        validate_aria_label

        @system_arguments[:tag] = :button
        @system_arguments[:"aria-expanded"] = false
        @system_arguments[:classes] = class_names(
          @system_arguments[:classes],
          "inline" => inline
        )
      end

      def call
        render(Primer::Beta::BaseButton.new(**@system_arguments)) { "&hellip;".html_safe }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
primer_view_components-0.1.9 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.8 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.7 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.6 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.5 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.4 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.3 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.2 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.1 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.1.0 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.123 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.122 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.121 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.120 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.119 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.118 app/components/primer/alpha/hellip_button.rb
primer_view_components-0.0.117 app/components/primer/alpha/hellip_button.rb