From 111de21f0089656f0f41569d539b613d24b89fd8 Mon Sep 17 00:00:00 2001 From: Peter Yates Date: Sat, 13 Mar 2021 21:06:47 +0000 Subject: [PATCH] Set default caption size using initialize keywords --- lib/govuk_design_system_formbuilder/elements/caption.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/govuk_design_system_formbuilder/elements/caption.rb b/lib/govuk_design_system_formbuilder/elements/caption.rb index 947103c4..03edc159 100644 --- a/lib/govuk_design_system_formbuilder/elements/caption.rb +++ b/lib/govuk_design_system_formbuilder/elements/caption.rb @@ -3,7 +3,7 @@ module Elements class Caption < Base include Traits::Localisation - def initialize(builder, object_name, attribute_name, text: nil, size: nil, **kwargs) + def initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs) super(builder, object_name, attribute_name) @text = text(text) @@ -28,7 +28,7 @@ def text(override) end def size_class(size) - case size || config.default_caption_size + case size when 'xl' then %(#{brand}-caption-xl) when 'l' then %(#{brand}-caption-l) when 'm' then %(#{brand}-caption-m)