Sha256: 913b1274b4c7366f0d7d513f16d8ace5a26a321266cbb54074ca868c65413dcd

Contents?: true

Size: 1.04 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
primer_view_components-0.0.38 app/components/primer/clipboard_copy.rb