Sha256: 977e82f7173c0ea61d7fdeb5b72adb9db701243abbdf56aa78c87624609b4f65
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true module Yattho module Alpha # Use `Image` to render images. # # @accessibility # Always provide a meaningful `alt`. class Image < Yattho::Component status :alpha # @example Default # # <%= render(Yattho::Alpha::Image.new(src: Yattho::ExampleImage::BASE64_SRC, alt: "GitHub")) %> # # @example Helper # # <%= yattho_image(src: Yattho::ExampleImage::BASE64_SRC, alt: "GitHub") %> # # @example Lazy loading # # <%= render(Yattho::Alpha::Image.new(src: Yattho::ExampleImage::BASE64_SRC, alt: "GitHub", lazy: true)) %> # # @example Custom size # # <%= render(Yattho::Alpha::Image.new(src: Yattho::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(Yattho::BaseComponent.new(src: image_path(@src), **@system_arguments)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yattho_view_components-0.1.1 | app/components/yattho/alpha/image.rb |
yattho_view_components-0.0.1 | app/components/yattho/alpha/image.rb |