Skip to content

Commit

Permalink
Tidy up the info/warning panel and fix title/no title output (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab authored Jan 13, 2025
1 parent 70c93d7 commit 69d21e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions cms/core/blocks/panels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from wagtail import blocks


Expand All @@ -12,20 +13,17 @@ class PanelBlock(blocks.StructBlock):

variant = blocks.ChoiceBlock(
choices=[
("warn", _("Warning")),
("info", _("Information")),
("announcement", "Announcement"),
("bare", "Bare"),
("branded", "Branded"),
("error", "Error"),
("ghost", "Ghost"),
("success", "Success"),
("warn-branded", "Warn (branded)"),
("warn", "Warn"),
],
default="warn",
)
body = blocks.RichTextBlock(features=settings.RICH_TEXT_BASIC)
title = blocks.CharBlock(required=False, label="Title (optional)")
title = blocks.CharBlock(required=False, label=_("Title (optional)"))

class Meta:
label = "Warning or information panel"
label = _("Warning or information panel")
template = "templates/components/streamfield/panel_block.html"
12 changes: 5 additions & 7 deletions cms/jinja2/templates/components/streamfield/panel_block.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{% from "components/panel/_macro.njk" import onsPanel %}

{# fmt:off #}
{{ onsPanel({
"variant": value.variant,
"body": value.body,
"title": value.title
}) }}
{# fmt:on #}
{% if value.title %}
{{- onsPanel({"variant": value.variant, "body": value.body, "title": value.title}) -}}
{% else %}
{{- onsPanel({"variant": value.variant, "body": value.body}) -}}
{% endif %}

0 comments on commit 69d21e3

Please sign in to comment.