Class: Koi::Form::Elements::Image
- Inherits:
-
GOVUKDesignSystemFormBuilder::Base
- Object
- GOVUKDesignSystemFormBuilder::Base
- Koi::Form::Elements::Image
- Includes:
- FileElement
- Defined in:
- lib/koi/form/elements/image.rb
Instance Method Summary collapse
-
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs) ⇒ Image
constructor
A new instance of Image.
- #preview ⇒ Object
Methods included from FileElement
Constructor Details
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs) ⇒ Image
Returns a new instance of Image.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/koi/form/elements/image.rb', line 9 def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs, &) super(builder, object_name, attribute_name, &) @mime_types = mime_types @label = label @caption = @hint = hint @html_attributes = kwargs.merge() @form_group = form_group end |
Instance Method Details
#preview ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/koi/form/elements/image.rb', line 21 def preview = {} add_option(, :data, "#{stimulus_controller}_target", "preview") add_option(, :class, "preview-image") add_option(, :class, "hidden") unless preview? tag.div(**) do tag.img(src: preview_url, class: "image-thumbnail") + destroy_element_trigger end end |