Sha256: 64537586f4da335ef68abea7e43e4c2943b9053e0ed50b7004b6301bb44f4000

Contents?: true

Size: 1.5 KB

Versions: 24

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module Primer
  # 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::HellipButton.new("aria-label": "Expand next part")`
  class HellipButton < Primer::Component
    # @example Default
    #   <%= render(Primer::HellipButton.new("aria-label": "No effect")) %>
    #
    # @example Inline
    #   <%= render(Primer::HellipButton.new(inline: true, "aria-label": "No effect")) %>
    #
    # @example Styling the button
    #   <%= render(Primer::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::BaseButton.new(**@system_arguments)) { "&hellip;".html_safe }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
primer_view_components-0.0.85 app/components/primer/hellip_button.rb
primer_view_components-0.0.84 app/components/primer/hellip_button.rb
primer_view_components-0.0.83 app/components/primer/hellip_button.rb
primer_view_components-0.0.82 app/components/primer/hellip_button.rb
primer_view_components-0.0.81 app/components/primer/hellip_button.rb
primer_view_components-0.0.80 app/components/primer/hellip_button.rb
primer_view_components-0.0.79 app/components/primer/hellip_button.rb
primer_view_components-0.0.78 app/components/primer/hellip_button.rb
primer_view_components-0.0.77 app/components/primer/hellip_button.rb
primer_view_components-0.0.76 app/components/primer/hellip_button.rb
primer_view_components-0.0.75 app/components/primer/hellip_button.rb
primer_view_components-0.0.74 app/components/primer/hellip_button.rb
primer_view_components-0.0.73 app/components/primer/hellip_button.rb
primer_view_components-0.0.72 app/components/primer/hellip_button.rb
primer_view_components-0.0.71 app/components/primer/hellip_button.rb
primer_view_components-0.0.70 app/components/primer/hellip_button.rb
primer_view_components-0.0.69 app/components/primer/hellip_button.rb
primer_view_components-0.0.68 app/components/primer/hellip_button.rb
primer_view_components-0.0.67 app/components/primer/hellip_button.rb
primer_view_components-0.0.66 app/components/primer/hellip_button.rb