From c9b37b8cb2aafb69a6e05014f59690dfafe9833a Mon Sep 17 00:00:00 2001 From: Amanda Lim-Cabuloy Date: Fri, 10 Jan 2025 19:43:30 +0800 Subject: [PATCH 1/5] Add intro to BlogChooserBlock --- tbx/core/blocks.py | 3 +++ .../molecules/streamfield/blocks/blog_chooser_block.html | 9 +++++++++ .../molecules/streamfield/blocks/blog_chooser_block.yaml | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tbx/core/blocks.py b/tbx/core/blocks.py index 9c3e5c909..768d5a9ea 100644 --- a/tbx/core/blocks.py +++ b/tbx/core/blocks.py @@ -473,6 +473,9 @@ def clean(self, value): class BlogChooserBlock(blocks.StructBlock): featured_blog_heading = blocks.CharBlock(max_length=255) + intro = blocks.RichTextBlock( + features=settings.NO_HEADING_RICH_TEXT_FEATURES, required=False + ) blog_pages = blocks.ListBlock( blocks.PageChooserBlock(page_type="blog.BlogPage"), min_num=1, diff --git a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html index 075b5d6ae..4a7b1d92b 100644 --- a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html +++ b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html @@ -1,11 +1,20 @@ {% load wagtailcore_tags %} +{# Section heading #} {% if is_standard_page %}

{{ value.featured_blog_heading }}

{% else %} {% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.featured_blog_heading classes="motif-heading--two motif-heading--static motif-heading--half-width section-title--related-posts" %} {% endif %} +{# Section intro #} +{% if value.intro %} +
+ {{ value.intro|richtext }} +
+{% endif %} + +{# Blog posts #} {% endif %} + +{% for button in value.primary_button %} + {{ button.value.text }} +{% endfor %} + +{% for button in value.secondary_button %} + {{ button.value.text }} +{% endfor %} diff --git a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.yaml b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.yaml index df72bc19c..7aca6b447 100644 --- a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.yaml +++ b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.yaml @@ -2,6 +2,14 @@ context: value: featured_work_heading: Case studies # intro: '

An injection of fresh ideas, and the occasional challenging opinion, to ignite your fire.

' + # primary_button: + # - value: + # text: Primary button + # url: '#' + # secondary_button: + # - value: + # text: Secondary button + # url: '#' work_pages: - title: Imagining and designing a future product for MQ in 5 days flat client: 'MQ: Transforming Mental Health' From d8f324aff4770d238b9cbe023f97ac7434f8db90 Mon Sep 17 00:00:00 2001 From: Amanda Lim-Cabuloy Date: Mon, 3 Feb 2025 14:51:18 +0800 Subject: [PATCH 5/5] Add comments we only expect 1 button --- .../molecules/streamfield/blocks/blog_chooser_block.html | 2 ++ .../molecules/streamfield/blocks/work_chooser_block.html | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html index decfcb646..2e4121238 100644 --- a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html +++ b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html @@ -23,10 +23,12 @@

{% endfor %} +{# We expect only up to 1 primary button (`max_num=1` is set in the block definition.) #} {% for button in value.primary_button %} {{ button.value.text }} {% endfor %} +{# We expect only up to 1 secondary button (`max_num=1` is set in the block definition.) #} {% for button in value.secondary_button %} {{ button.value.text }} {% endfor %} diff --git a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.html b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.html index f158b4a1a..bb8cb4d0b 100644 --- a/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.html +++ b/tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.html @@ -25,10 +25,12 @@

{% endif %} +{# We expect only up to 1 primary button (`max_num=1` is set in the block definition.) #} {% for button in value.primary_button %} {{ button.value.text }} {% endfor %} +{# We expect only up to 1 secondary button (`max_num=1` is set in the block definition.) #} {% for button in value.secondary_button %} {{ button.value.text }} {% endfor %}