Skip to content
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

TWE-19 - BE - Link columns block (Service area page) #337

Merged
Merged
18 changes: 18 additions & 0 deletions tbx/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,24 @@ class Meta:
)


class LinkColumnsBlock(blocks.StructBlock):
"""
Displays a list of links in columns.
Used on the service area page.
"""

title = blocks.CharBlock(max_length=255, required=False)
intro = blocks.RichTextBlock(
features=settings.NO_HEADING_RICH_TEXT_FEATURES, required=False
)
links = LinkBlock(max_num=None, min_num=1)

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


class PartnersBlock(blocks.StructBlock):
title = blocks.CharBlock(max_length=255, required=False)
partner_logos = blocks.ListBlock(CustomImageChooserBlock(), label="Logos")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
{% include "patterns/molecules/streamfield/blocks/work_chooser_block.html" %}
{% include "patterns/molecules/streamfield/blocks/pullquote_block.html" %}
{% include "patterns/molecules/streamfield/blocks/blog_chooser_block.html" %}
{% include "patterns/molecules/streamfield/blocks/link_columns_block.html" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% load wagtailcore_tags wagtailimages_tags %}
<div class="grid__link-columns link-columns">
<div class="link-columns__header">
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.title classes="motif-heading--two motif-heading--static link-columns__title " %}
{% if value.intro %}
<div class="link-columns__intro rich-text">{{ value.intro|richtext }}</div>
{% endif %}
</div>

<ul class="link-columns__links">
{% for link in value.links %}
<li class="link-columns__item">
<a class="link-columns__link" href="{{ link.value.url }}"><span class="link-columns__link-text">{{ link.value.text }}</span><span class="link-columns__tail">&nbsp;{% include "patterns/atoms/icons/icon.html" with name="arrow" classname="link-columns__arrow" %}</span></a>
</li>
{% endfor %}
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
context:
value:
title: Optional section title (Link columns)
intro: '<p>Optional section intro</p>'
links:
- value:
text: Digital marketing for charities
url: '#'
- value:
text: Search engine optimisation (SEO)
url: '#'
- value:
text: Website design and development
url: '#'
- value:
text: Strategy, innovation and AI
url: '#'
- value:
text: Google Ad Grants management
url: '#'
- value:
text: Digital marketing creative
url: '#'
- value:
text: Digital marketing training
url: '#'
- value:
text: Wagtail CMS services
url: '#'
- value:
text: Email marketing
url: '#'
- value:
text: Pay-per-click (PPC)
url: '#'
- value:
text: Social media management
url: '#'
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ <h2 class="underline mt-8 mb-2">Table block</h2>
{% include "patterns/molecules/streamfield/blocks/typed_table_block.html" %}
</div>

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

<div>
<h2 class="underline mt-8 mb-2">Division signpost block</h2>
{% include "patterns/molecules/streamfield/blocks/division_signpost_block.html" %}
Expand Down
2 changes: 2 additions & 0 deletions tbx/services/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
FeaturedCaseStudyBlock,
FourPhotoCollageBlock,
ImageWithAltTextBlock,
LinkColumnsBlock,
PartnersBlock,
PhotoCollageBlock,
PromoBlock,
Expand Down Expand Up @@ -70,4 +71,5 @@ class ServiceStoryBlock(StoryBlock):
class ServiceAreaStoryBlock(StoryBlock):
blog_chooser = BlogChooserBlock()
four_photo_collage = FourPhotoCollageBlock()
link_columns = LinkColumnsBlock()
work_chooser = WorkChooserBlock()
1 change: 1 addition & 0 deletions tbx/static_src/sass/components/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

&__related-posts-simple,
&__team-listing,
&__link-columns,
&__stats-group {
grid-column: 2 / span 4;

Expand Down
64 changes: 64 additions & 0 deletions tbx/static_src/sass/components/_link-columns.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@use 'config' as *;

.link-columns {
&__header {
margin-bottom: $spacer-half;
}

&__links {
@include media-query(medium) {
columns: 2;
column-gap: $spacer-large;
}

@include media-query(large) {
columns: 3;
column-gap: $spacer-half;
}
}

&__item {
padding: $spacer-mini-plus 0;
border-top: 1px solid var(--color--border);
}

&__link {
display: block;
width: fit-content;

&:focus {
@include focus-style();
}
}

&__link-text {
@include font-size(size-six);
@include link-styles(
$color: var(--color--link),
$interaction-color: var(--color--theme-primary),
$offset: 5px
);

&:hover {
transition: color $transition-quick;

@include reduced-motion() {
transition: none;
}
}
}

&__tail {
// Keep the arrow attached to the last word so it's not orphaned on a new line
white-space: nowrap;
display: inline;
}

&__arrow {
@include arrow-link-icon-styles(
$width: 18px,
$interaction-color: var(--color--theme-primary)
);
color: var(--color--theme-primary);
}
}
8 changes: 5 additions & 3 deletions tbx/static_src/sass/config/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,15 @@
@mixin arrow-link-icon-styles(
$mobile-hidden: false,
$color: var(--color--decoration),
$interaction-color: var(--color--link-interaction)
$interaction-color: var(--color--link-interaction),
$width: 72px,
$height: 22px
) {
// Apply all common styles regardless of mobile-hidden
display: inline-block;
color: $color;
width: 72px;
height: 22px;
width: $width;
height: $height;
transition: transform, $transition-quick;

@include reduced-motion() {
Expand Down
1 change: 1 addition & 0 deletions tbx/static_src/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@use 'components/image';
@use 'components/instagram-gallery';
@use 'components/intro-with-images';
@use 'components/link-columns';
@use 'components/link';
@use 'components/listing';
@use 'components/listing-avatar';
Expand Down
Loading