Sha256: e05ce0378fe713a21d9ac8efd81b4d23878e8619d0497d030ac4826d90e09459

Contents?: true

Size: 1.43 KB

Versions: 16

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Primer
  # A client-side mechanism to crop images.
  class ImageCrop < Primer::Component
    # A loading indicator that is shown while the image is loading.
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    renders_one :loading, lambda { |**system_arguments|
      system_arguments[:tag] = :div
      system_arguments[:"data-loading-slot"] = true

      Primer::BaseComponent.new(**system_arguments)
    }

    # @example Simple cropper
    #   <%= render(Primer::ImageCrop.new(src: "https://github.com/koddsson.png")) %>
    #
    # @example Square cropper
    #   <%= render(Primer::ImageCrop.new(src: "https://github.com/koddsson.png", rounded: false)) %>
    #
    # @example Cropper with a custom loader
    #   <%= render(Primer::ImageCrop.new(src: "https://github.com/koddsson.png", rounded: false)) do |cropper| %>
    #     <% cropper.loading(style: "width: 120px").with_content("Loading...") %>
    #   <% end %>
    #
    # @param src [String] The path of the image to crop.
    # @param rounded [Boolean] If the crop mask should be a circle. Defaults to true.
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    def initialize(src:, rounded: true, **system_arguments)
      @system_arguments = system_arguments
      @system_arguments[:tag] = "image-crop"
      @system_arguments[:src] = src
      @system_arguments[:rounded] = true if rounded
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
primer_view_components-0.0.61 app/components/primer/image_crop.rb
primer_view_components-0.0.60 app/components/primer/image_crop.rb
primer_view_components-0.0.59 app/components/primer/image_crop.rb
primer_view_components-0.0.58 app/components/primer/image_crop.rb
primer_view_components-0.0.57 app/components/primer/image_crop.rb
primer_view_components-0.0.56 app/components/primer/image_crop.rb
primer_view_components-0.0.55 app/components/primer/image_crop.rb
primer_view_components-0.0.54 app/components/primer/image_crop.rb
primer_view_components-0.0.53 app/components/primer/image_crop.rb
primer_view_components-0.0.52 app/components/primer/image_crop.rb
primer_view_components-0.0.51 app/components/primer/image_crop.rb
primer_view_components-0.0.50 app/components/primer/image_crop.rb
primer_view_components-0.0.49 app/components/primer/image_crop.rb
primer_view_components-0.0.48 app/components/primer/image_crop.rb
primer_view_components-0.0.47 app/components/primer/image_crop.rb
primer_view_components-0.0.46 app/components/primer/image_crop.rb