Feat/badges#2220
Merged
Merged
Conversation
…l as accept badges within a radio option
🧪 Review environmenthttps://2nni67yvhwaxkebn3myrqmdyxy0cbweg.lambda-url.ca-central-1.on.aws/ |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new Badge component and extends the Radios (and underlying select) component to support optional borders and badges.
- Introduce a
badgemacro and storybook page showcasing its variants and usage. - Enhance
select/select_inputto acceptbadge_optionsandborderedflags, and updateradios/radiomacros accordingly. - Wire up three example WTForms
RadioFieldforms in storybook routing to demonstrate the new features.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/templates/views/storybook-menu.html | Add “Badge” entry to the storybook navigation menu. |
| app/templates/views/storybook/radios.html | Storybook examples for basic, bordered, and badged radios. |
| app/templates/views/storybook/badge.html | New storybook page demonstrating Badge component usage. |
| app/templates/components/select-input.html | Extend select and select_input macros with badge_options and bordered. |
| app/templates/components/radios.html | Update radios and radio macros to pass through new options. |
| app/templates/components/badge.html | Implement the badge macro. |
| app/main/views/storybook.py | Define three example forms and pass them into storybook route. |
| app/assets/stylesheets/index.css | Adjust PurgeCSS ignore comments around large CSS block. |
Comments suppressed due to low confidence (2)
app/main/views/storybook.py:8
- [nitpick] Class names should follow PascalCase. Rename
Exampleform1toExampleForm1(and similarly for Exampleform2/Exampleform3).
class Exampleform1(Form):
app/templates/components/radios.html:18
- [nitpick] The
radiomacro acceptsbadge_optionsbut notbordered, leading to inconsistency withradiosandselect_input. Consider adding aborderedparameter here or removingbadge_optionsif it’s never used standalone.
{% macro radio(option, disable=[], option_hints={}, data_target=None, as_list_item=False, badge_options=None) %}
Comment on lines
+80
to
+81
| {% if badge_options and badge_options[option.data] %} | ||
| {{ badge(badge_options[option.data][0], badge_options[option.data][1], extra_class="float-right") }} |
There was a problem hiding this comment.
Accessing badge_options[option.data] directly will raise a KeyError for options without badges. Use badge_options.get(option.data) or check option.data in badge_options first.
Suggested change
| {% if badge_options and badge_options[option.data] %} | |
| {{ badge(badge_options[option.data][0], badge_options[option.data][1], extra_class="float-right") }} | |
| {% if badge_options and badge_options.get(option.data) %} | |
| {{ badge(badge_options.get(option.data)[0], badge_options.get(option.data)[1], extra_class="float-right") }} |
Comment on lines
+2229
to
+2230
| "Receive a code by email","FR Receive a code by email" | ||
| "Receive a code by text message","FR Receive a code by text message" |
Contributor
There was a problem hiding this comment.
Suggested change
| "Receive a code by email","FR Receive a code by email" | |
| "Receive a code by text message","FR Receive a code by text message" | |
| "Receive a code by email","Recevoir un code par courriel" | |
| "Receive a code by text message","Recevoir un code par message texte" |
amazingphilippe
approved these changes
Jul 9, 2025
amazingphilippe
left a comment
Contributor
There was a problem hiding this comment.
Looks good! Added some nicer FR translations
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.
Summary | Résumé
This PR adds a new badge component, and updates the radio component to be able to be bordered, and/or contain badges.
Badge component
Bordered radio
Bordered radio with badges
Test instructions | Instructions pour tester la modification