From 3a1aeadee1da72bd8d7433fda6258899896f96cd Mon Sep 17 00:00:00 2001 From: Diego Toral Date: Wed, 7 Feb 2024 11:28:39 -0800 Subject: [PATCH] Add support to specify size for SubtitleComponent --- app/components/bulma/subtitle_component.rb | 5 +++-- spec/components/bulma/subtitle_component_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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