Class: BulmaPhlex::Image
- Inherits:
-
Base
- Object
- Base
- BulmaPhlex::Image
- Defined in:
- lib/bulma_phlex/image.rb
Overview
Renders a Bulma image component.
Class Method Summary collapse
-
.new(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Object
Parameters.
Instance Method Summary collapse
-
#initialize(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Image
constructor
A new instance of Image.
- #view_template ⇒ Object
Constructor Details
#initialize(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Image
Returns a new instance of Image.
19 20 21 22 23 24 25 26 27 |
# File 'lib/bulma_phlex/image.rb', line 19 def initialize(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) @src = src @alt = alt @rounded = rounded @size = size @ratio = ratio @img_attributes = img_attributes @html_attributes = html_attributes end |
Class Method Details
.new(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) ⇒ Object
Parameters
src:— The image source URL (required)alt:— The image alt text (optional)rounded:— Whether to apply theis-roundedclass (optional, default: false)size:— The image size (optional, e.g., 64 foris-64x64)ratio:— The image ratio (optional, e.g., "1by1", "4by3", "16by9")img_attributes:— Additional HTML attributes for the img element (optional)**html_attributes— Additional HTML attributes for the figure element (optional)
15 16 17 |
# File 'lib/bulma_phlex/image.rb', line 15 def self.new(src:, alt: nil, rounded: false, size: nil, ratio: nil, img_attributes: {}, **html_attributes) super end |
Instance Method Details
#view_template ⇒ Object
29 30 31 32 33 |
# File 'lib/bulma_phlex/image.rb', line 29 def view_template figure(**mix({ class: figure_classes }, @html_attributes)) do img(**mix({ src: @src, alt: @alt, class: img_classes }, @img_attributes)) end end |