Sha256: f5c7265c811c5dfa74f35c4c9a2046a99e79a8be339c68617a8b442eb05164c9

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Primer
  # Use `ClipboardCopy` to copy element text content or input values to the clipboard.
  class ClipboardCopy < Primer::Component
    status :alpha

    # @example Default
    #   <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) %>
    #
    # @example With text instead of icons
    #   <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) do %>
    #     Click to copy!
    #   <% end %>
    #
    # @param label [String] String that will be read to screenreaders when the component is focused
    # @param value [String] Text to copy into the users clipboard when they click the component
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    def initialize(label:, value:, **system_arguments)
      @system_arguments = system_arguments
      @system_arguments[:tag] = "clipboard-copy"
      @system_arguments[:value] = value
      @system_arguments[:"aria-label"] = label
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
primer_view_components-0.0.44 app/components/primer/clipboard_copy.rb
primer_view_components-0.0.43 app/components/primer/clipboard_copy.rb
primer_view_components-0.0.42 app/components/primer/clipboard_copy.rb
primer_view_components-0.0.41 app/components/primer/clipboard_copy.rb
primer_view_components-0.0.40 app/components/primer/clipboard_copy.rb
primer_view_components-0.0.39 app/components/primer/clipboard_copy.rb