Skip to content

Commit ebba81f

Browse files
authored
Add blog chooser and work chooser blocks to the standard page (#290)
* Add blog chooser and work chooser blocks to the standard page
1 parent 41b7d85 commit ebba81f

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

tbx/core/blocks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,24 @@ class BlogChooserBlock(blocks.StructBlock):
440440
max_num=3,
441441
)
442442

443+
def get_context(self, value, parent_context=None):
444+
context = super().get_context(value, parent_context=parent_context)
445+
context["is_standard_page"] = False
446+
return context
447+
443448
class Meta:
444449
icon = "link"
445450
template = "patterns/molecules/streamfield/blocks/blog_chooser_block.html"
446451
group = "Custom"
447452

448453

454+
class BlogChooserStandardPageBlock(BlogChooserBlock):
455+
def get_context(self, value, parent_context=None):
456+
context = super().get_context(value, parent_context=parent_context)
457+
context["is_standard_page"] = True
458+
return context
459+
460+
449461
class WorkChooserBlock(blocks.StructBlock):
450462
featured_work_heading = blocks.CharBlock(max_length=255)
451463
work_pages = blocks.ListBlock(
@@ -481,6 +493,7 @@ def get_context(self, value, parent_context=None):
481493
context["work_pages"] = [
482494
work_pages[_id] for _id in work_page_ids if _id in work_pages
483495
]
496+
context["is_standard_page"] = False
484497
return context
485498

486499
class Meta:
@@ -489,6 +502,13 @@ class Meta:
489502
group = "Custom"
490503

491504

505+
class WorkChooserStandardPageBlock(WorkChooserBlock):
506+
def get_context(self, value, parent_context=None):
507+
context = super().get_context(value, parent_context=parent_context)
508+
context["is_standard_page"] = True
509+
return context
510+
511+
492512
class EventLinkStructValue(ButtonLinkStructValue):
493513
def get_button_link_block(self):
494514
return self.get("url")[0]
@@ -918,6 +938,8 @@ class Meta:
918938

919939
class StandardPageStoryBlock(StoryBlock):
920940
promo = PromoBlock()
941+
blog_chooser = BlogChooserStandardPageBlock()
942+
work_chooser = WorkChooserStandardPageBlock()
921943

922944

923945
class HomePageStoryBlock(blocks.StreamBlock):

tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/blog_chooser_block.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{% load wagtailcore_tags %}
22

3-
{% 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" %}
3+
{% if is_standard_page %}
4+
<h2 class="heading heading--two-b grid__heading mb-spacerMedium">{{ value.featured_blog_heading }}</h2>
5+
{% else %}
6+
{% 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" %}
7+
{% endif %}
48

59
<ul class="grid__related-posts streamfield__related-posts mb-spacerMedium lg:mb-spacerLarge">
610
{% for blog_page in value.blog_pages %}

tbx/project_styleguide/templates/patterns/molecules/streamfield/blocks/work_chooser_block.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% load wagtailcore_tags %}
22

33
{% if work_pages %}
4-
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.featured_work_heading classes="motif-heading--two motif-heading--static motif-heading--half-width section-title--related-posts" %}
4+
{% if is_standard_page %}
5+
<h2 class="heading heading--two-b grid__heading mb-spacerMedium">{{ value.featured_work_heading }}</h2>
6+
{% else %}
7+
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.featured_work_heading classes="motif-heading--two motif-heading--static motif-heading--half-width section-title--related-posts" %}
8+
{% endif %}
59

610
<ul class="grid__related-posts streamfield__related-posts mb-spacerMedium lg:mb-spacerLarge">
711
{% for work_page in work_pages %}

tbx/static_src/sass/components/_grid.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@
319319
grid-column: 5 / span 1;
320320
}
321321

322+
// standard page adjustments for blog chooser and work chooser
323+
.template-standard-page & {
324+
&__related-posts {
325+
grid-column: 2 / span 4;
326+
327+
@include media-query(large) {
328+
grid-column: 4 / span 7;
329+
}
330+
}
331+
}
332+
322333
// Move everything over by 1 column on the blog page and work pages
323334
.template-blog-page &,
324335
.template-work-page & {

0 commit comments

Comments
 (0)