Sha256: 6a731d14967371b127796fed7bf03f0b01f1b2a0efaab0aaedf033764657293a
Contents?: true
Size: 1.18 KB
Versions: 18
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Koi module Form module Elements class Image < GOVUKDesignSystemFormBuilder::Base include FileElement 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 = caption @hint = hint @html_attributes = kwargs.merge(file_input_options) @form_group = form_group end def preview options = {} add_option(options, :data, "#{stimulus_controller}_target", "preview") add_option(options, :class, "preview-image") add_option(options, :class, "hidden") unless preview? tag.div(**options) do tag.img(src: preview_url, class: "image-thumbnail") + destroy_element_trigger end end private def stimulus_controller "image-field" end def form_group_class "govuk-image-field" end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems