Skip to content

Commit

Permalink
Set default caption size using initialize keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Mar 13, 2021
1 parent dab7629 commit 111de21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/govuk_design_system_formbuilder/elements/caption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 111de21

Please sign in to comment.