Conversation
All other components use a block to define their content, Button should as well.
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes the Button component API to match other components by using block-based content definition instead of a label parameter. This improves consistency across the component library.
- Removed the
labelparameter from the Button constructor - Updated the component to use block content via the
contentmethod - Updated all tests and preview code to use the new block-based syntax
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/components/flowbite/button.rb | Removes label parameter and attr_reader, updates render method to use content |
| test/components/flowbite/button_test.rb | Updates all test cases to use block syntax instead of label parameter |
| demo/test/components/previews/button_preview.rb | Updates all preview examples to use block syntax instead of label parameter |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| def default | ||
| render(Flowbite::Button.new(label: "Default")) | ||
| render(Flowbite::Button.new) { "Default" } |
There was a problem hiding this comment.
For consistency's sake, that is the way to go. I still find it a bit odd that you cannot pass the (label) content to the initializer, like in an options or :label => {:content => "something") hash or similar.
There was a problem hiding this comment.
It should probably look like Flowbite::Button.new(content: "something"), which I guess could be acceptable for the simplest case. The block style is well suited for the more complex cases as well, though, ie if you want more elements in your button:
<%= render(Flowbite::Button.new) do %>
<div>
<%= image_tag("icon") %>
<%= translate(".submit") %>
</div>
<small><%= translate(".submit_details" %></small>
<% end %>which would be cumbersome to do well in an argument.
All other components use a block to define their content, Button should as well.