-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Primer::Image to Primer::Alpha::Image (#1527)
Co-authored-by: Actions Auto Build <[email protected]>
- Loading branch information
1 parent
c026577
commit 595a675
Showing
14 changed files
with
108 additions
and
86 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 | ||
--- | ||
|
||
deprecating Primer::Image in favor of Primer::Alpha::Image |
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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module Alpha | ||
# Use `Image` to render images. | ||
# | ||
# @accessibility | ||
# Always provide a meaningful `alt`. | ||
class Image < Primer::Component | ||
status :alpha | ||
|
||
# @example Default | ||
# | ||
# <%= render(Primer::Alpha::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub")) %> | ||
# | ||
# @example Helper | ||
# | ||
# <%= primer_image(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub") %> | ||
# | ||
# @example Lazy loading | ||
# | ||
# <%= render(Primer::Alpha::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub", lazy: true)) %> | ||
# | ||
# @example Custom size | ||
# | ||
# <%= render(Primer::Alpha::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub", height: 100, width: 100)) %> | ||
# | ||
# @param src [String] The source url of the image. | ||
# @param alt [String] Specifies an alternate text for the image. | ||
# @param lazy [Boolean] Whether or not to lazily load the image. | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(src:, alt:, lazy: false, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
|
||
@src = src | ||
@system_arguments[:tag] = :img | ||
@system_arguments[:alt] = alt | ||
|
||
return unless lazy | ||
|
||
@system_arguments[:loading] = :lazy | ||
@system_arguments[:decoding] = :async | ||
end | ||
|
||
def call | ||
render(Primer::BaseComponent.new(src: image_path(@src), **@system_arguments)) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
# Use `Image` to render images. | ||
# | ||
# @accessibility | ||
# Always provide a meaningful `alt`. | ||
class Image < Primer::Component | ||
# @example Default | ||
# | ||
# <%= render(Primer::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub")) %> | ||
# | ||
# @example Helper | ||
# | ||
# <%= primer_image(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub") %> | ||
# | ||
# @example Lazy loading | ||
# | ||
# <%= render(Primer::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub", lazy: true)) %> | ||
# | ||
# @example Custom size | ||
# | ||
# <%= render(Primer::Image.new(src: Primer::ExampleImage::BASE64_SRC, alt: "GitHub", height: 100, width: 100)) %> | ||
# | ||
# @param src [String] The source url of the image. | ||
# @param alt [String] Specifies an alternate text for the image. | ||
# @param lazy [Boolean] Whether or not to lazily load the image. | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(src:, alt:, lazy: false, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
|
||
@src = src | ||
@system_arguments[:tag] = :img | ||
@system_arguments[:alt] = alt | ||
|
||
return unless lazy | ||
|
||
@system_arguments[:loading] = :lazy | ||
@system_arguments[:decoding] = :async | ||
end | ||
|
||
def call | ||
render(Primer::BaseComponent.new(src: image_path(@src), **@system_arguments)) | ||
end | ||
class Image < Primer::Alpha::Image | ||
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
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