-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bgcolor
and textcolor
fields to DonateBanner
model
#12986
Add bgcolor
and textcolor
fields to DonateBanner
model
#12986
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ramram-mf , thanks for adding these customization options for the donate banner. I have left a few comments that I think would help with UX and code maintainability.
Hi @ramram-mf! Thank you for your work on this, it's looking good 👍 Just adding the notes we discussed:
|
…n-fo' of github-mf:MozillaFoundation/foundation.mozilla.org into TP1-1234-investigate-background-font-color-customization-fo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making those changes @ramram-mf! This looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ramram-mf!
Thanks very much for taking this work on. After testing this out on the review app, I can confirm that everything is working as expected. I appreciate you fixing the indexing issue when it came to repurposing the background_image
field name, and transferring over existing data. Great work!
I liked your approach of disabling the background_color
field when a background image is selected.
However, I have a slight concern that users might find it a bit confusing without immediate context, as there isn’t any help text to clarify why background_color
is disabled when both fields are set, until they hit “Save.”
To simplify things and add clarity for users, I’d suggest leveraging Wagtail’s MultiFieldPanel
and HelpPanel
. This would allow us to provide clear instructions right within the CMS interface. Here’s an example:
MultiFieldPanel(
[
HelpPanel(content="Select either an image or a color to serve as the background for the banner."),
FieldPanel("background_image"),
FieldPanel("background_color"),
],
heading="Background",
)
With this approach, the CMS will display clear instructions before users make their selection:
We can then handle validation in the models clean()
method.
Here's what that might look like:
def clean(self):
super().clean()
both_selected_error = "Please select either a background image or a background color for the banner."
none_selected_error = "Please select a background image or a background color for the banner."
# Validate that either background_image or background_color is set, not both.
if self.background_image and self.background_color:
raise ValidationError(
{
"background_image": ValidationError(both_selected_error),
"background_color": ValidationError(both_selected_error),
}
)
if not self.background_image and not self.background_color:
raise ValidationError(
{
"background_image": ValidationError(none_selected_error),
"background_color": ValidationError(none_selected_error),
}
)
This way, if both or none of the fields are set, they’ll see a styled validation error reminding them to choose just one:
This update could help streamline the user experience and keep the codebase leaner by removing the two new files needed for the custom disabling logic. Let me know what you think!
Thanks again for your hard work!
…n-fo' of github-mf:MozillaFoundation/foundation.mozilla.org into TP1-1234-investigate-background-font-color-customization-fo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ramram-mf! Great work 🙌 LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @ramram-mf ! Also thank you @danielfmiranda for your great suggestion.
Description
This PR updates the
DonateBanner
model with the addition of two new fieldsbackground_color
andtext_color
, allowing the user to customize the donate banner present on all site pages. It also renames the previously incorrectly namedbackground_image
toforeground_image
and adds abackground_image
field to store the newly implemented background image feature for the banner.To test
admin2:admin2
credentials.Settings > Donate banner
page, click on theChoose
in order to pick a banner to show.Save
button on the bottom of the page.Edit
menu:Note the new model fields
Background image
,Background color
andText color
. Customize the background color of the banner. Save and browse the preview app homepage.Confirm that the background color has changed in the homepage.
Link to sample test page: https://foundation-s-tp1-1234-i-bhpnku.herokuapp.com/en/
Related PRs/issues: #12881
┆Issue is synchronized with this Jira Story