Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Flowbite dropdown ViewComponent (plus item and icon subcomponents) along with Lookbook previews and component tests, to support rendering dropdown menus in the component library.
Changes:
- Introduces
Flowbite::Dropdownwith an ERB template that renders a trigger button and hidden menu container. - Adds
Flowbite::Dropdown::ItemandFlowbite::Dropdown::ChevronIconsubcomponents. - Adds Minitest coverage and a Lookbook preview for the new dropdown component.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/components/flowbite/dropdown_test.rb | Adds rendering and attribute assertions for dropdown, item, and chevron icon components. |
| demo/test/components/previews/dropdown_preview.rb | Adds Lookbook previews demonstrating dropdown usage, styles, and button-style items. |
| demo/.yardoc/checksums | Updates YARD checksums to include the new dropdown component files. |
| app/components/flowbite/dropdown.rb | Introduces the main dropdown component API and default menu classes. |
| app/components/flowbite/dropdown/dropdown.html.erb | Adds the dropdown markup wiring the trigger button to the menu container. |
| app/components/flowbite/dropdown/item.rb | Adds a dropdown menu item component that renders as a link or button. |
| app/components/flowbite/dropdown/chevron_icon.rb | Adds the chevron-down SVG icon component used in the trigger button. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -0,0 +1,17 @@ | |||
| <div class="relative inline-block"> | |||
| <%= render(Flowbite::Button.new(id: button_id, "data-dropdown-toggle": id, **button_options)) do %> | |||
Comment on lines
+6
to
+8
| # The dropdown menu itself is toggled using Flowbite's JavaScript, via the | ||
| # +data-dropdown-toggle+ attribute. Make sure Flowbite's JavaScript is | ||
| # loaded on the page for the toggle behavior to work. |
Comment on lines
+36
to
+58
| def call | ||
| content_tag(:li) { render_link } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def classes | ||
| self.class.classes + @class | ||
| end | ||
|
|
||
| def link? | ||
| href.present? | ||
| end | ||
|
|
||
| def render_link | ||
| link_options = {class: classes}.merge(options) | ||
|
|
||
| if link? | ||
| content_tag(:a, content, href: href, **link_options) | ||
| else | ||
| content_tag(:button, content, type: "button", **link_options) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP: How to handle Javascript for the trigger? We don't want to assume the Flowbite.js is loaded, or do we? How about people using Stimulus controllers? Or HTML dialogs?