Skip to content

Commit

Permalink
Add support for size to Bulma::ContentComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotoral committed Jan 11, 2024
1 parent 55203e0 commit 2ee5aca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased]

- Added support to size for `Bulma::ContentComponent`
- Created basic `Bulma::ContentComponent` with preview class
- Updated 'demo/Gemfile.lock' to latest version of the gem

Expand Down
9 changes: 8 additions & 1 deletion app/components/bulma/content_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

module Bulma
class ContentComponent < Component
def initialize(size: nil)
@size = size
end

def call
content_tag :div, content, class: "content"
content_tag :div, content, class: class_names(
"content",
"is-#{@size}" => @size.present?
)
end
end
end
6 changes: 6 additions & 0 deletions spec/components/bulma/content_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@

expect(page).to have_css "div.content", text: "My content"
end

it "allows to specify size as a symbol" do
render_inline(described_class.new(size: :small))

expect(page).to have_css "div.content.is-small"
end
end

0 comments on commit 2ee5aca

Please sign in to comment.