forked from primer/view_components
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] migrating Primer::ImageCrop to Primer::Alpha::ImageCrop (primer…
- Loading branch information
1 parent
595a675
commit 1724aa2
Showing
17 changed files
with
121 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/view-components': patch | ||
--- | ||
|
||
migrating Primer::ImageCrop to Primer::Alpha::ImageCrop |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module Alpha | ||
# 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| | ||
deny_tag_argument(**system_arguments) | ||
system_arguments[:tag] = :div | ||
system_arguments[:"data-loading-slot"] = true | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# @example Simple cropper | ||
# <%= render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC)) %> | ||
# | ||
# @example Square cropper | ||
# <%= render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: false)) %> | ||
# | ||
# @example Cropper with a custom loader | ||
# <%= render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: false)) do |cropper| %> | ||
# <% cropper.with_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 = deny_tag_argument(**system_arguments) | ||
@system_arguments[:tag] = "image-crop" | ||
@system_arguments[:src] = src | ||
@system_arguments[:rounded] = true if rounded | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
# 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| | ||
deny_tag_argument(**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: Primer::ExampleImage::BASE64_SRC)) %> | ||
# | ||
# @example Square cropper | ||
# <%= render(Primer::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: false)) %> | ||
# | ||
# @example Cropper with a custom loader | ||
# <%= render(Primer::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: false)) do |cropper| %> | ||
# <% cropper.with_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 = deny_tag_argument(**system_arguments) | ||
@system_arguments[:tag] = "image-crop" | ||
@system_arguments[:src] = src | ||
@system_arguments[:rounded] = true if rounded | ||
end | ||
class ImageCrop < Primer::Alpha::ImageCrop | ||
status :deprecated | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module Alpha | ||
# @label ImageCrop | ||
class ImageCropPreview < ViewComponent::Preview | ||
# @label Playground | ||
# | ||
# @param rounded [Boolean] | ||
def playground(rounded: false) | ||
render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded)) | ||
end | ||
|
||
# @label Default Options | ||
# | ||
# @param rounded [Boolean] | ||
def default(rounded: false) | ||
render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded)) | ||
end | ||
|
||
# @label Custom loading slot | ||
# | ||
# @param rounded [Boolean] | ||
def loading(rounded: false) | ||
render(Primer::Alpha::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded)) do |c| | ||
c.with_loading { "Loading..." } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters