unfoldadmin / django-unfold

Modern Django admin theme for seamless interface development
https://unfoldadmin.com
MIT License
1.6k stars 161 forks source link

message should respect django settings #657

Closed Ehco1996 closed 6 days ago

Ehco1996 commented 1 month ago

Issue Description:

Do you have any examples?

When customizing message tags to support Bulma CSS on the user side, as shown below:

MESSAGE_TAGS = {
    messages.DEBUG: "is-info",
    messages.INFO: "is-info",
    messages.SUCCESS: "is-success",
    messages.WARNING: "is-warning",
    messages.ERROR: "is-danger",
}

The messages in the admin interface lose their CSS support.

Is it a third party application feature request?

No, it is not a third-party application feature request.

In case of third party application, when it was updated last time?

The application was last updated last week.

Describe your feature request

The issue arises due to a hardcoded check for tags in the template file:

unfold/templates/unfold/helpers/messages.html

To resolve this, the hardcoded tag check should be removed or modified to accommodate custom message tags, ensuring that the CSS support is maintained both in the user interface and the admin interface.

Proposed Solution:

Modify the template to avoid hardcoding specific tag checks, allowing for flexibility in message tag customization. This will ensure that custom tags, such as those for Bulma CSS, are properly rendered without losing CSS support in the admin interface.

Additional Context:

This issue affects users who wish to customize message tags for CSS frameworks like Bulma while maintaining the functionality and styling in the admin interface. By addressing the hardcoded tag checks, the application can provide a more flexible and user-friendly experience.

lukasvinclav commented 1 month ago

Thanks for detailed explanation. Can you create a PR with a proposal how to get a behavior okay on regular frontend and admin area? Just working example will be good enough and I will adjust details.

lukasvinclav commented 1 month ago

@Ehco1996 any update?

Ehco1996 commented 1 month ago

@lukasvinclav Apologies for the delayed response; I've drafted a PR here: https://github.com/unfoldadmin/django-unfold/pull/669

lukasvinclav commented 6 days ago

To be honest, I never used MESSAGE_TAGS before but after reading the documentation, I think, the only required action on my side is to add CSS class into messages.

Unfold is going to support all default message types and to support your custom classes, you must write your own CSS. In Unfold you can load your own CSS without any issues. If your own CSS class does not have any styling, the default one (gray) will be used.

https://unfoldadmin.com/docs/styles-scripts/

lukasvinclav commented 6 days ago

Message class added here #725