Skip to content

Commit

Permalink
Add support to specify size for SubtitleComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotoral committed Feb 7, 2024
1 parent d20d35a commit 3a1aead
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/components/bulma/subtitle_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions spec/components/bulma/subtitle_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3a1aead

Please sign in to comment.