Skip to content

Commit 41ee55b

Browse files
TWE-10 - BE - Statistics group block (Division page) (#328)
* Add statistics group block to Division Page * Add a label format to NumericStatisticsBlock * TWE-10 | FE | New statistics group block (#334) --------- Co-authored-by: Sherry <[email protected]>
1 parent 31ee0ae commit 41ee55b

File tree

9 files changed

+86
-7
lines changed

9 files changed

+86
-7
lines changed

tbx/core/blocks.py

+21
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,27 @@ class NumericStatisticsBlock(blocks.StructBlock):
973973

974974
class Meta:
975975
icon = "table"
976+
label_format = "{headline_number} {description} {further_details}"
977+
978+
979+
class NumericStatisticsGroupBlock(blocks.StructBlock):
980+
title = blocks.CharBlock(max_length=255, required=False)
981+
intro = blocks.RichTextBlock(
982+
features=settings.NO_HEADING_RICH_TEXT_FEATURES, required=False
983+
)
984+
statistics = blocks.ListBlock(
985+
NumericStatisticsBlock(),
986+
max_num=4,
987+
min_num=1,
988+
)
989+
990+
class Meta:
991+
group = "Custom"
992+
icon = "table"
993+
label = "Numeric statistics"
994+
template = (
995+
"patterns/molecules/streamfield/blocks/numeric_stats_group_block.html"
996+
)
976997

977998

978999
class TextualStatisticsBlock(blocks.StructBlock):

tbx/divisions/blocks.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
FeaturedServicesBlock,
33
FourPhotoCollageBlock,
44
IntroductionWithImagesBlock,
5+
NumericStatisticsGroupBlock,
56
PartnersBlock,
67
StoryBlock,
78
)
@@ -10,5 +11,6 @@
1011
class DivisionStoryBlock(StoryBlock):
1112
four_photo_collage = FourPhotoCollageBlock()
1213
introduction_with_images = IntroductionWithImagesBlock()
14+
numeric_statistics = NumericStatisticsGroupBlock()
1315
partners_block = PartnersBlock()
1416
featured_services = FeaturedServicesBlock()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% load wagtailcore_tags wagtailimages_tags %}
2+
<div class="grid__stats-group stats-group">
3+
{% if value.title %}
4+
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading_level=2 heading=value.title classes="motif-heading motif-heading--two-c motif-heading--static stats-group__heading" %}
5+
{% endif %}
6+
{% if value.intro %}
7+
<div class="text text--five stats-group__intro">{{ value.intro|richtext }}</div>
8+
{% endif %}
9+
{# Stats #}
10+
{# Not sure if the impact report page (which uses stats_numeric.html) should be affected. #}
11+
{% include "patterns/molecules/streamfield/blocks/stats_numeric.html" with value=value.statistics %}
12+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
context:
2+
value:
3+
title: Lighting little fires
4+
intro: 'Torchbox has been supporting charities since the start of the digital era. Some of the stats we&apos;re particularly proud of:'
5+
statistics:
6+
- headline_number: 120
7+
description: charities
8+
further_details: and counting...
9+
- headline_number: 24
10+
description: years
11+
further_details: working with the sector
12+
- headline_number: '263%'
13+
description: traffic increase
14+
further_details: for an imaginary charity
15+
- headline_number: 1
16+
description: Guinness record
17+
further_details: working with the DEC

tbx/project_styleguide/templates/patterns/styleguide/components/components.html

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ <h2 class="underline mt-8 mb-2">Stats block textual</h2>
109109
{% include "patterns/molecules/streamfield/blocks/stats_textual.html" %}
110110
</div>
111111

112+
<div>
113+
<h2 class="underline mt-8 mb-2">Numeric stats group block</h2>
114+
{% include "patterns/molecules/streamfield/blocks/numeric_stats_group_block.html" %}
115+
</div>
116+
112117
<div>
113118
<h2 class="underline mt-8 mb-2">Event block</h2>
114119
{% include "patterns/molecules/streamfield/blocks/event_block.html" %}

tbx/static_src/sass/components/_grid.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
}
102102

103103
&__related-posts-simple,
104-
&__team-listing {
104+
&__team-listing,
105+
&__stats-group {
105106
grid-column: 2 / span 4;
106107

107108
@include media-query(large) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@use 'config' as *;
2+
3+
.stats-group {
4+
&__heading {
5+
margin-bottom: $spacer-mini;
6+
7+
@include media-query('large') {
8+
max-width: 50%;
9+
}
10+
}
11+
12+
&__intro {
13+
margin-bottom: $spacer-medium;
14+
15+
@include media-query('large') {
16+
margin-bottom: $spacer-half;
17+
max-width: 60%;
18+
}
19+
}
20+
}

tbx/static_src/sass/components/_stats.scss

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@
3636

3737
&__number {
3838
@include font-size(size-zero);
39-
color: var(--color--heading);
39+
color: var(--color--theme-primary);
4040
display: block;
41-
font-weight: $weight--light;
42-
line-height: 1;
41+
font-weight: $weight--semibold;
4342
}
4443

4544
&__text {
@@ -51,14 +50,15 @@
5150
}
5251

5352
&__description {
54-
@include font-size('size-five');
53+
@include font-size('size-four');
54+
font-weight: $weight--semibold;
5555
color: var(--color--heading);
5656
display: block;
57-
margin-bottom: $spacer-mini;
57+
line-height: 1;
5858
}
5959

6060
&__details {
61-
@include font-size('size-eight');
61+
@include font-size('size-seven');
6262
display: block;
6363
}
6464
}

tbx/static_src/sass/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
@use 'components/markdown-block';
4545
@use 'components/mode-switcher';
4646
@use 'components/motif-heading';
47+
@use 'components/stats-group';
4748
@use 'components/pagination';
4849
@use 'components/partners';
4950
@use 'components/photo-collage';

0 commit comments

Comments
 (0)