Skip to content

Commit

Permalink
Section-optional banner block for mid-content
Browse files Browse the repository at this point in the history
  • Loading branch information
akmiller01 committed Apr 17, 2024
1 parent 3b342e3 commit 6cffb8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions di_website/common/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class ImageBlock(StructBlock):


class BannerBlock(StructBlock):
section = True
image = ImageChooserBlock(required=False)
image_credit_name = TextBlock(required=False, help_text='The name of the image source')
image_credit_url = URLBlock(required=False, help_text='A link to the image source, if any')
Expand Down Expand Up @@ -196,6 +197,10 @@ class Meta():
label = 'Banner Block'


class ContentBannerBlock(BannerBlock):
section = False


class SectionParagraphBlock(StructBlock):
text = RichTextBlock(features=RICHTEXT_FEATURES_NO_FOOTNOTES)
center = BooleanBlock(default=False, required=False)
Expand Down
6 changes: 4 additions & 2 deletions di_website/publications/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
StructBlock,
TextBlock,
URLBlock,
PageChooserBlock
PageChooserBlock,
ContentBannerBlock
)
from wagtail.snippets.blocks import SnippetChooserBlock

Expand Down Expand Up @@ -337,7 +338,8 @@ class Meta:
('advanced_interactive_chart', AdvancedInteractiveChartBlock()),
('cta', CallToActionBlock()),
('accordion', AccordionBlock()),
('so_what', SoWhat())
('so_what', SoWhat()),
('content_banner', ContentBannerBlock()),
]

def flexible_content_streamfield(blank=False):
Expand Down
4 changes: 4 additions & 0 deletions di_website/templates/blocks/banner/banner_block.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% load wagtailcore_tags wagtailimages_tags responsive %}

{% if self.section %}
<section class="section">
{% endif %}
<div class="row row--narrow">
<div class="banner{% if self.light %} banner--light{% endif %}">
<div class="l-banner{% if self.media_orientation == 'right' %} l-banner--reverse{% endif %}">
Expand Down Expand Up @@ -56,4 +58,6 @@
</div>
</div>
</div>
{% if self.section %}
</section>
{% endif %}

0 comments on commit 6cffb8f

Please sign in to comment.