diff --git a/app/components/bulma/subtitle_component.rb b/app/components/bulma/subtitle_component.rb index d67aace..ab2dbf3 100644 --- a/app/components/bulma/subtitle_component.rb +++ b/app/components/bulma/subtitle_component.rb @@ -2,12 +2,13 @@ module Bulma class SubtitleComponent < Component - def initialize(text = nil) + def initialize(text = nil, size: nil) @text = text + @size = size end def call - content_tag :p, @text || content, class: "subtitle" + content_tag :p, @text || content, class: class_names("subtitle", "is-#{@size}" => @size.present?) end end end diff --git a/spec/components/bulma/subtitle_component_spec.rb b/spec/components/bulma/subtitle_component_spec.rb index bab57ef..bc2552a 100644 --- a/spec/components/bulma/subtitle_component_spec.rb +++ b/spec/components/bulma/subtitle_component_spec.rb @@ -18,4 +18,10 @@ expect(page).to have_content "Subtitle" end + + it "allows to specify size as option" do + render_inline(described_class.new(size: 5)) + + expect(page).to have_css "p.is-5" + end end