Sha256: 2c63570d9a23dc894b0a28cafc593759dec6dddb729f23755695c8c0542146ba

Contents?: true

Size: 1.51 KB

Versions: 30

Compression:

Stored size: 1.51 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::Beta::BaseButton.new(**@system_arguments)) { "&hellip;".html_safe }
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
primer_view_components-0.0.116 app/components/primer/hellip_button.rb
primer_view_components-0.0.114 app/components/primer/hellip_button.rb
primer_view_components-0.0.113 app/components/primer/hellip_button.rb
primer_view_components-0.0.112 app/components/primer/hellip_button.rb
primer_view_components-0.0.111 app/components/primer/hellip_button.rb
primer_view_components-0.0.110 app/components/primer/hellip_button.rb
primer_view_components-0.0.109 app/components/primer/hellip_button.rb
primer_view_components-0.0.108 app/components/primer/hellip_button.rb
primer_view_components-0.0.107 app/components/primer/hellip_button.rb
primer_view_components-0.0.106 app/components/primer/hellip_button.rb
primer_view_components-0.0.105 app/components/primer/hellip_button.rb
primer_view_components-0.0.104 app/components/primer/hellip_button.rb
primer_view_components-0.0.103 app/components/primer/hellip_button.rb
primer_view_components-0.0.102 app/components/primer/hellip_button.rb
primer_view_components-0.0.101 app/components/primer/hellip_button.rb
primer_view_components-0.0.100 app/components/primer/hellip_button.rb
primer_view_components-0.0.99 app/components/primer/hellip_button.rb
primer_view_components-0.0.98 app/components/primer/hellip_button.rb
primer_view_components-0.0.97 app/components/primer/hellip_button.rb
primer_view_components-0.0.96 app/components/primer/hellip_button.rb