Sha256: 10fc2ad130d21ba0252a3c7b06478c918be796383bef8d5c2ef013e94afe3d79
Contents?: true
Size: 856 Bytes
Versions: 4
Compression:
Stored size: 856 Bytes
Contents
module GOVUKDesignSystemFormBuilder module Elements class Caption < Base include Traits::Localisation def initialize(builder, object_name, attribute_name, text:, size: 'm') super(builder, object_name, attribute_name) @text = caption_text(text) @size_class = caption_size_class(size) end def html return nil if @text.blank? tag.span(@text, class: @size_class) end def caption_text(override) override || localised_text(:caption) end def caption_size_class(size) case size when 'xl' then %(#{brand}-caption-xl) when 'l' then %(#{brand}-caption-l) when 'm' then %(#{brand}-caption-m) else fail ArgumentError, "invalid size '#{size}', must be xl, l or m" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems