Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Flowbite::Styles class to provide better error messages when an unknown style is requested. The class acts as a wrapper around a hash of styles, delegating to Flowbite::Style instances internally and providing helpful error messages that list available styles when a requested style is not found.
- Introduces
Flowbite::Stylesclass withfrom_hashfactory method and customStyleNotFoundError - Updates all component
stylesmethods to useFlowbite::Styles.from_hashinstead of plain hashes - Changes style definitions from
Flowbite::Style.newinstances to plain hashes that are wrapped byfrom_hash
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/components/flowbite/styles.rb | New class providing improved error handling for style lookups with helpful error messages |
| app/components/flowbite/input/validation_error.rb | Updated to use Flowbite::Styles.from_hash (inconsistent - still uses Style.new) |
| app/components/flowbite/input/textarea.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/radio_button.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/label.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/hint.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/file.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/field.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/input/checkbox.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/card.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/button/pill.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/button/outline.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| app/components/flowbite/button.rb | Converted style definitions to plain hashes for use with Styles.from_hash |
| CHANGELOG.md | Documents the improved error message feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This gives us a bit more control and allows us better error messages.
Since we've already confirmed the key exists with we can safely use `@styles[style_name]` instead of `@styles.fetch(style_name)` for direct hash access.
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.
No description provided.