Skip to content

TWE-9 - BE - Featured services block (Division page) #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions tbx/core/blocks.py
Original file line number Diff line number Diff line change
@@ -281,6 +281,41 @@ class Meta:
template = "patterns/molecules/streamfield/blocks/dynamic_hero_block.html"


class FeaturedPageCardBlock(blocks.StructBlock):
heading = blocks.CharBlock(required=False)
description = blocks.RichTextBlock(features=settings.NO_HEADING_RICH_TEXT_FEATURES)
image = ImageChooserBlock()
link_text = blocks.CharBlock()
accessible_link_text = blocks.CharBlock(
help_text=(
"Used by screen readers. This should be descriptive for accessibility. "
'If not filled, the "Link text" field will be used instead.'
),
required=False,
)
page = blocks.PageChooserBlock()

class Meta:
icon = "breadcrumb-expand"


class FeaturedServicesBlock(blocks.StructBlock):
title = blocks.CharBlock(max_length=255, required=False)
intro = blocks.RichTextBlock(
features=settings.NO_HEADING_RICH_TEXT_FEATURES, required=False
)
cards = blocks.ListBlock(
FeaturedPageCardBlock(),
max_num=4,
min_num=2,
)

class Meta:
group = "Custom"
icon = "link"
template = "patterns/molecules/streamfield/blocks/featured_services_block.html"


class FourPhotoCollageBlock(blocks.StructBlock):
"""
Accepts 4 photos shown as a collage + text below.
@@ -391,8 +426,13 @@ class ColourTheme(models.TextChoices):
heading = blocks.CharBlock(required=False)
description = blocks.RichTextBlock(features=settings.NO_HEADING_RICH_TEXT_FEATURES)
image = ImageChooserBlock()
link_text = blocks.CharBlock(
help_text=("This should be descriptive for accessibility."),
link_text = blocks.CharBlock()
accessible_link_text = blocks.CharBlock(
help_text=(
"Used by screen readers. This should be descriptive for accessibility. "
'If not filled, the "Link text" field will be used instead.'
),
required=False,
)
page = blocks.PageChooserBlock()

2 changes: 2 additions & 0 deletions tbx/divisions/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from tbx.core.blocks import (
FeaturedServicesBlock,
FourPhotoCollageBlock,
IntroductionWithImagesBlock,
PartnersBlock,
@@ -10,3 +11,4 @@ class DivisionStoryBlock(StoryBlock):
four_photo_collage = FourPhotoCollageBlock()
introduction_with_images = IntroductionWithImagesBlock()
partners_block = PartnersBlock()
featured_services = FeaturedServicesBlock()
Original file line number Diff line number Diff line change
@@ -15,6 +15,10 @@
<path fill="currentColor" d="M0 7.846h18.646L12.042.981l.83-.981 8.176 8.5-8.175 8.5-.83-.98 6.603-6.866H0V7.846z"/>
</symbol>

<symbol id="arrow-wide-sm" viewBox="0 0 52 21">
<path fill="currentColor" d="M0.5 9.69231L48.5325 9.69231L40.3757 1.21154L41.4011 -4.41436e-07L51.5 10.5L41.4011 21L40.3757 19.7885L48.5325 11.3077L1 11.3077L0.5 9.69231Z"/>
</symbol>

<symbol id="arrow-wide" viewBox="0 0 72 22" fill="none">
<path fill="currentColor" d="M0 10.192h69.032l-8.156-8.48L61.9.5 72 11 61.901 21.5l-1.025-1.212 8.157-8.48H0v-1.616Z"/>
</symbol>
Original file line number Diff line number Diff line change
@@ -18,7 +18,12 @@ <h2 class="heading heading--two division-signpost__heading">{% firstof card.head
</div>
{% srcset_image card.image format-webp fill-{540x280,490x280} sizes="(max-width: 598px) 540px, (min-width: 599px) 490px" alt="" %}
{# The title and icon need to be on the same line with no whitespace to prevent the arrow being orphaned on a new line #}
<a href="{% pageurl card.page %}" class="button-link button-link--{{ card.card_colour }}">{{ card.link_text }}&nbsp;{% include "patterns/atoms/icons/icon.html" with name="arrow-wide" classname="button-link__arrow" %}<span class="sr-only"> about {% firstof card.heading card.page.title %} division</span></a>
<a href="{% pageurl card.page %}"
class="button-link button-link--{{ card.card_colour }}"
{% if card.accessible_link_text %}aria-label="{{ card.accessible_link_text }}"{% endif %}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@helenb @albinazs What are your thoughts on me adding a new field explicitly for accessible link text?

I tried having a descriptive link_text (i.e. "Read more on out charity services") on staging but it doesn't look great, and appending {{ link_text }} about {{ heading }} division can get a bit clunky depending on the content of link_text.

>
{{ card.link_text }}&nbsp;{% include "patterns/atoms/icons/icon.html" with name="arrow-wide" classname="button-link__arrow" %}
</a>
</li>
{% endfor %}
</ul>
Original file line number Diff line number Diff line change
@@ -7,14 +7,17 @@ context:
heading: Charity
description: Amplify your impact, reach more supporters and transform your organisation with tailored digital strategies and solutions
link_text: Find out more
accessible_link_text: Find out more about our charity services
- card_colour: 'theme-nebuline'
heading: Public
description: Navigate complex challenges. Accelerate your mission and transform public services through digital
link_text: Find out more
accessible_link_text: Find out more about our public sector services
- card_colour: 'theme-lagoon'
heading: Wagtail CMS services
heading: Wagtail
description: Empower your editors and developers to do their best work with Wagtail, the world's leading open-source Python CMS.
link_text: Find out more
accessible_link_text: Find out more about our Wagtail CMS services

tags:
srcset_image:
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% load wagtailcore_tags wagtailimages_tags %}
<div class="grid__featured-services featured-services">
<div class="featured-services__header">
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.title classes="motif-heading--two motif-heading--static featured-services__title " %}
{% if value.intro %}
<div class="featured-services__intro rich-text">{{ value.intro|richtext }}</div>
{% endif %}
</div>
<ul class="featured-services__cards">
{% for card in value.cards %}
<li class="featured-services__card">
{% srcset_image card.image format-webp fill-{750x420,650x420} sizes="(max-width: 750px) 100vw, (min-width: 751px) 650px" alt="" %}
<div class="featured-services__text">
<h3 class="featured-services__heading heading heading--two-b">{% firstof card.heading card.page.title %}</h3>
<div class="featured-services__description rich-text">{{ card.description|richtext }}</div>
</div>
{# The title and icon need to be on the same line with no whitespace to prevent the arrow being orphaned on a new line #}
<a href="{% pageurl card.page %}"
class="button-link button-link--compact"
{% if card.accessible_link_text %}aria-label="{{ card.accessible_link_text }}"{% endif %}
>
{{ card.link_text }}&nbsp;{% include "patterns/atoms/icons/icon.html" with name="arrow-wide-sm" classname="button-link__arrow" %}
</a>
</li>
{% endfor %}
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
context:
value:
title: What we do
intro: 'Discover how we can help you achieve your goals through our range of services.'
cards:
- heading: Advocacy, Engagement & Income
description: '<p>Grow your audience, mobilise and increase your income through design, communication and strategy</p>'
link_text: Our services
accessible_link_text: Our Advocacy, Engagement & Income services
- heading: Measure, Analyse & Optimise
description: '<p>Organise your data to gain the insights and confidence needed to boost your charity&apos;s performance.</p>'
link_text: Our services
accessible_link_text: Our Measure, Analyse & Optimise services
- heading: Scale impact through Technology
description: '<p>We design technology that&apos;s built for humans. Scale your impact and better deliver your services by leveraging our expertise.</p>'
link_text: Our services
accessible_link_text: Our services on scaling impact through Technology

tags:
srcset_image:
'card.image format-webp fill-{750x420,650x420} sizes="(max-width: 750px) 100vw, (min-width: 751px) 650px" alt=""':
raw: |
<img height="420" sizes="(max-width: 750px) 100vw, (min-width: 751px) 650px" src="https://picsum.photos/750/420.webp" srcset="https://picsum.photos/750/420.webp 750w, https://picsum.photos/650/420.webp 650w" width="750" alt="">
Original file line number Diff line number Diff line change
@@ -204,6 +204,11 @@ <h2 class="underline mt-8 mb-2">Division signpost block</h2>
{% include "patterns/molecules/streamfield/blocks/division_signpost_block.html" %}
</div>

<div>
<h2 class="underline mt-8 mb-2">Featured services block</h2>
{% include "patterns/molecules/streamfield/blocks/featured_services_block.html" %}
</div>

<div>
<h2 class="underline mt-8 mb-2">Footer CTA</h2>
{% include "patterns/molecules/footer-cta/footer-cta.html" with value=partners_data %}
Original file line number Diff line number Diff line change
@@ -126,6 +126,11 @@ tags:
raw: |
<img alt="" height="280" sizes="(max-width: 598px) 540px, (min-width: 599px) 490px" src="https://picsum.photos/540/280.webp" srcset="https://picsum.photos/540/280.webp 540w, https://picsum.photos/490/280.webp 490w" width="540">
image:
# featured services block
'card.image format-webp fill-{750x420,650x420} sizes="(max-width: 750px) 100vw, (min-width: 751px) 650px" alt=""':
raw: |
<img height="420" sizes="(max-width: 750px) 100vw, (min-width: 751px) 650px" src="https://picsum.photos/750/420.webp" srcset="https://picsum.photos/750/420.webp 750w, https://picsum.photos/650/420.webp 650w" width="750" alt="">
image:
# company logo for pull quote
value.logo max-110x70 format-webp class="pullquote__company-logo":
raw: |
10 changes: 10 additions & 0 deletions tbx/static_src/sass/components/_button-link.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use 'config' as *;

.button-link {
$root: &;
@include font-size('size-four');
@include high-contrast-text-decoration();
font-weight: $weight--semibold;
@@ -12,6 +13,15 @@
transition: background-color $transition-quick;
background-color: var(--color--theme-primary);

// compact variant of the button with reduced padding
&--compact {
padding: 13px $spacer-small;

#{$root}__arrow {
margin-left: $spacer-mini;
}
}

@include reduced-motion() {
transition: none;
}
52 changes: 52 additions & 0 deletions tbx/static_src/sass/components/_featured-services.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@use 'config' as *;

.featured-services {
&__header {
margin-bottom: $spacer-medium;
}

&__cards {
display: grid;
gap: $spacer-mini-plus;
grid-template-columns: repeat(1, 1fr);

@include media-query(medium) {
grid-template-columns: repeat(2, 1fr);
}

@include media-query(large) {
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}
}

&__card {
display: flex;
flex-direction: column;
width: 100%;
transition: background-color $transition-quick;
background-color: var(--color--dark-background);

&:has(.button-link:hover) {
background-color: var(--color--black);
}

@include high-contrast-mode() {
border: 1px solid var(--color--text);
}
}

&__text {
padding: $spacer-small-plus $spacer-small $spacer-medium;
margin-bottom: auto;
}

&__heading {
color: var(--color--white);
margin-bottom: $spacer-mini;
}

// override the rich-text font-size
&__description.rich-text {
@include font-size(size-seven);
}
}
19 changes: 10 additions & 9 deletions tbx/static_src/sass/components/_grid.scss
Original file line number Diff line number Diff line change
@@ -109,6 +109,16 @@
}
}

&__division-signpost,
&__featured-services {
grid-column: 2 / span 4;
margin-bottom: $spacer;

@include media-query(large) {
grid-column: 2 / span 12;
}
}

&__wide-image {
margin-bottom: $spacer-medium;
grid-column: 2 / span 5;
@@ -326,15 +336,6 @@
}
}

&__division-signpost {
grid-column: 2 / span 4;
margin-bottom: $spacer;

@include media-query(large) {
grid-column: 2 / span 12;
}
}

// header and navigation grid elements
&__header-logo {
grid-column: 2 / span 2;
1 change: 1 addition & 0 deletions tbx/static_src/sass/main.scss
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
@use 'components/employee-owned-icon';
@use 'components/event-block';
@use 'components/featured-case-study';
@use 'components/featured-services';
@use 'components/footer';
@use 'components/footer-cta';
@use 'components/form';