Skip to content

Commit 3d0997c

Browse files
committed
Merge branch 'integration/2024-evolution' into feature/twe-2-division-signpost-block
2 parents 1465253 + 4400045 commit 3d0997c

File tree

110 files changed

+991
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+991
-599
lines changed

docs/custom-features/theme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The Theme feature enables the customization of page styles through the applicati
66

77
The available color themes are defined using the `tbx.core.utils.models.ColourTheme` enumeration. Each theme option consists of a CSS class name and a human-readable label. The following themes are available:
88

9-
- `ColourTheme.NONE`: No specific theme applied. When the theme is set to "None", this means we don't add a `theme-****` class to the page, and the default theme (_Coral_, at the time of writing these docs) is applied.
9+
- `ColourTheme.NONE`: No specific theme applied. When the theme is set to "None", this means we don't add a `theme-****` class to the page, and the default theme (_Coral_, at the time of writing these docs) is applied (unless the page inherits a theme).
1010
- `ColourTheme.CORAL`: Applies a `theme-coral` class to the page.
11+
- `ColourTheme.NEBULINE`: Applies a `theme-nebuline` class to the page.
1112
- `ColourTheme.LAGOON`: Applies a `theme-lagoon` class to the page.
12-
- `ColourTheme.BANANA`: Applies a `theme-banana` class to the page.
13-
- `ColourTheme.EARTH`: Applies a `theme-earth` class to the page.
13+
- `ColourTheme.GREEN`: Applies a `theme-green` class to the page.
1414

1515
???+ tip
1616

docs/front-end/themes_and_modes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The CSS to set the mode is an html class of either `.mode-dark` or `.mode-light`
88

99
An editor has an option to select a theme on each page. Selecting a theme on a page will change it for that page, and all child pages, unless another selection is made further down the page tree.
1010

11-
There are currently 4 themes in use: coral, lagoon, banana and earth. The CSS to set the theme is an html class of either `.theme-coral`, `.theme-lagoon`, `.theme-banana` or `.theme-earth`.
11+
There are currently 4 themes in use: coral, nebuline, lagoon and green. The CSS to set the theme is an html class of either `.theme-coral`, `.theme-nebuline`, `.theme-lagoon` or `.theme-green`.
1212

1313
???+ note
1414

docs/front-end/utility-classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Most CSS classes used in this build are designed to fit with a particular compon
44

55
Some, such as the `listing` component are designed to be a base with variations across a number of variant components - this is made clear by the component naming: `listing--image.html`, `listing--simple.html` etc.
66

7-
However, we have some utility classes which are designed for re-use, along with the option to to use Tailwind utility classes. Classes that are designed for re-use include `button`, `heading--[xyz]`, `link`, `supporting`, `.body` and `icon--listing-arrow`.
7+
However, we have some utility classes which are designed for re-use, along with the option to to use Tailwind utility classes. Classes that are designed for re-use include `button`, `heading--[xyz]`, `text--[xyz]`, `link`, and `icon--listing-arrow`.
88

99
The same tailwind utility classes that are avialable in `wagtail-kit` are available in this build. `tailwind.config.js` includes the custom spacing for the build, allowing us to use classes such as `mb-spacerMini` where it wouldn't be practical to create a new scss component just for a one-off spacing adjustment.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Generated by Django 4.2.16 on 2024-12-09 08:08
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("blog", "0026_add_earth_colour_theme"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="blogindexpage",
15+
name="theme",
16+
field=models.CharField(
17+
blank=True,
18+
choices=[
19+
("", "None"),
20+
("theme-coral", "Coral"),
21+
("theme-nebuline", "Nebuline"),
22+
("theme-lagoon", "Lagoon"),
23+
("theme-green", "Green"),
24+
],
25+
max_length=25,
26+
),
27+
),
28+
migrations.AlterField(
29+
model_name="blogpage",
30+
name="theme",
31+
field=models.CharField(
32+
blank=True,
33+
choices=[
34+
("", "None"),
35+
("theme-coral", "Coral"),
36+
("theme-nebuline", "Nebuline"),
37+
("theme-lagoon", "Lagoon"),
38+
("theme-green", "Green"),
39+
],
40+
max_length=25,
41+
),
42+
),
43+
]

tbx/blog/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def blog_posts(self):
4646
prefetch_author_images = models.Prefetch(
4747
"authors__author__image",
4848
queryset=CustomImage.objects.prefetch_renditions(
49-
"format-webp|fill-72x72",
49+
"format-webp|fill-100x100",
5050
"format-webp|fill-144x144",
5151
"format-webp|fill-286x286",
5252
),
@@ -185,7 +185,7 @@ def related_blog_posts(self):
185185
prefetch_author_images = models.Prefetch(
186186
"authors__author__image",
187187
queryset=CustomImage.objects.prefetch_renditions(
188-
"format-webp|fill-72x72",
188+
"format-webp|fill-100x100",
189189
"format-webp|fill-144x144",
190190
"format-webp|fill-286x286",
191191
),

tbx/core/factories.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Meta:
2323

2424
class HomePageFactory(wagtail_factories.PageFactory):
2525
title = "Home"
26+
hero_heading_1 = "The digital partner"
27+
hero_heading_2 = "for positive change"
2628

2729
class Meta:
2830
model = HomePage
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Generated by Django 4.2.16 on 2024-12-09 08:08
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("torchbox", "0037_merge_20240725_1000"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="homepage",
15+
name="theme",
16+
field=models.CharField(
17+
blank=True,
18+
choices=[
19+
("", "None"),
20+
("theme-coral", "Coral"),
21+
("theme-nebuline", "Nebuline"),
22+
("theme-lagoon", "Lagoon"),
23+
("theme-green", "Green"),
24+
],
25+
max_length=25,
26+
),
27+
),
28+
migrations.AlterField(
29+
model_name="standardpage",
30+
name="theme",
31+
field=models.CharField(
32+
blank=True,
33+
choices=[
34+
("", "None"),
35+
("theme-coral", "Coral"),
36+
("theme-nebuline", "Nebuline"),
37+
("theme-lagoon", "Lagoon"),
38+
("theme-green", "Green"),
39+
],
40+
max_length=25,
41+
),
42+
),
43+
]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Generated by Django 4.2.16 on 2024-12-04 08:04
2+
3+
from django.db import migrations, models
4+
import wagtail.fields
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("torchbox", "0038_update_theme_colour_choices"),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name="homepage",
16+
name="introduction",
17+
),
18+
migrations.AddField(
19+
model_name="homepage",
20+
name="hero_heading_1",
21+
field=models.CharField(default="", max_length=255),
22+
preserve_default=False,
23+
),
24+
migrations.AddField(
25+
model_name="homepage",
26+
name="hero_heading_2",
27+
field=models.CharField(default="", max_length=255),
28+
preserve_default=False,
29+
),
30+
migrations.AddField(
31+
model_name="homepage",
32+
name="hero_introduction",
33+
field=wagtail.fields.RichTextField(blank=True),
34+
),
35+
]

tbx/core/models.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
from django.db import models
22
from django.utils.functional import cached_property
3+
from django.utils.safestring import mark_safe
34

45
from modelcluster.fields import ParentalKey
56
from tbx.core.utils.fields import StreamField
7+
from tbx.core.utils.formatting import (
8+
convert_bold_links_to_pink,
9+
convert_italic_links_to_purple,
10+
)
611
from tbx.core.utils.models import (
712
ColourThemeMixin,
813
NavigationFields,
@@ -130,7 +135,9 @@ class HomePagePartnerLogo(Orderable):
130135
# Home Page
131136
class HomePage(ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, Page):
132137
template = "patterns/pages/home/home_page.html"
133-
introduction = models.TextField(blank=True)
138+
hero_heading_1 = models.CharField(max_length=255)
139+
hero_heading_2 = models.CharField(max_length=255)
140+
hero_introduction = RichTextField(blank=True, features=["bold", "italic", "link"])
134141
body = StreamField(HomePageStoryBlock())
135142

136143
class Meta:
@@ -143,7 +150,35 @@ def partner_logos(self):
143150
return []
144151

145152
content_panels = Page.content_panels + [
146-
FieldPanel("introduction"),
153+
MultiFieldPanel(
154+
[
155+
FieldPanel(
156+
"hero_heading_1",
157+
heading="Heading (Part 1)",
158+
help_text="This is the non-bold part of the heading.",
159+
),
160+
FieldPanel(
161+
"hero_heading_2",
162+
heading="Heading (Part 2)",
163+
help_text="This is the bold part of the heading.",
164+
),
165+
FieldPanel(
166+
"hero_introduction",
167+
heading="Introduction",
168+
help_text=mark_safe(
169+
"Use bold to mark links as"
170+
' <span style="color:#EE5276">pink</span>,'
171+
" and use italics to mark links as"
172+
' <span style="color:#6F60D0">purple</span>.'
173+
),
174+
),
175+
],
176+
heading="Hero",
177+
help_text=(
178+
"When combined, part 1 & part 2 of the heading can be treated as one"
179+
" sentence or one paragraph, depending on the presence of punctuation."
180+
),
181+
),
147182
InlinePanel("logos", heading="Partner logos", label="logo", max_num=7),
148183
FieldPanel("body"),
149184
]
@@ -163,6 +198,9 @@ def partner_logos(self):
163198
def get_context(self, request):
164199
context = super().get_context(request)
165200
context["is_home_page"] = True
201+
context["hero_introduction"] = convert_bold_links_to_pink(
202+
convert_italic_links_to_purple(self.hero_introduction)
203+
)
166204
return context
167205

168206

tbx/core/tests/test_colour_theme.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_theme_on_an_indexpage(self):
171171
self.assertNotIn(theme, html_classes)
172172

173173
def test_custom_theme_on_descendants(self):
174-
self.workindex.theme = ColourTheme.BANANA
174+
self.workindex.theme = ColourTheme.NEBULINE
175175
self.workindex.save()
176176
self.workindex.refresh_from_db()
177177

@@ -181,32 +181,32 @@ def test_custom_theme_on_descendants(self):
181181
self.assertEqual(self.blogindex.theme, ColourTheme.NONE)
182182
self.assertEqual(self.blogindex.theme_class, ColourTheme.NONE)
183183

184-
self.assertEqual(self.workindex.theme, ColourTheme.BANANA)
185-
self.assertEqual(self.workindex.theme_class, ColourTheme.BANANA)
184+
self.assertEqual(self.workindex.theme, ColourTheme.NEBULINE)
185+
self.assertEqual(self.workindex.theme_class, ColourTheme.NEBULINE)
186186

187187
# child of workindex
188188
work = HistoricalWorkPageFactory(parent=self.workindex)
189189
self.assertEqual(work.theme, ColourTheme.NONE)
190-
self.assertEqual(work.theme_class, ColourTheme.BANANA)
190+
self.assertEqual(work.theme_class, ColourTheme.NEBULINE)
191191

192192
# another child of workindex, this time we set the theme
193193
morework = HistoricalWorkPageFactory(
194-
parent=self.workindex, theme=ColourTheme.EARTH
194+
parent=self.workindex, theme=ColourTheme.GREEN
195195
)
196196

197-
self.assertEqual(morework.theme, ColourTheme.EARTH)
198-
self.assertEqual(morework.theme_class, ColourTheme.EARTH)
197+
self.assertEqual(morework.theme, ColourTheme.GREEN)
198+
self.assertEqual(morework.theme_class, ColourTheme.GREEN)
199199
# sibling shouldn't be affected
200200
self.assertEqual(work.theme, ColourTheme.NONE)
201-
self.assertEqual(work.theme_class, ColourTheme.BANANA)
201+
self.assertEqual(work.theme_class, ColourTheme.NEBULINE)
202202
# parent shouldn't be affected
203-
self.assertEqual(self.workindex.theme, ColourTheme.BANANA)
204-
self.assertEqual(self.workindex.theme_class, ColourTheme.BANANA)
203+
self.assertEqual(self.workindex.theme, ColourTheme.NEBULINE)
204+
self.assertEqual(self.workindex.theme_class, ColourTheme.NEBULINE)
205205

206206
# child of morework
207207
std_page = StandardPageFactory(parent=morework)
208208
# `theme_class` should be inherited from parent
209-
self.assertEqual(std_page.theme_class, ColourTheme.EARTH)
209+
self.assertEqual(std_page.theme_class, ColourTheme.GREEN)
210210
# but `theme` should remain unset
211211
self.assertEqual(std_page.theme, ColourTheme.NONE)
212212

@@ -239,10 +239,10 @@ def test_custom_theme_on_descendants(self):
239239

240240
# Check that we have the correct classes applied
241241
self.assertIn(f"template-{class_suffix}", html_classes)
242-
self.assertIn(ColourTheme.BANANA, html_classes)
242+
self.assertIn(ColourTheme.NEBULINE, html_classes)
243243
# The rest of the theme classes should not be applied
244244
for theme in list(
245-
filter(lambda theme: theme != ColourTheme.BANANA, self.themes)
245+
filter(lambda theme: theme != ColourTheme.NEBULINE, self.themes)
246246
):
247247
self.assertNotIn(theme, html_classes)
248248

@@ -256,9 +256,9 @@ def test_custom_theme_on_descendants(self):
256256

257257
# Check that we have the correct classes applied
258258
self.assertIn(f"template-{class_suffix}", html_classes)
259-
self.assertIn(ColourTheme.EARTH, html_classes)
259+
self.assertIn(ColourTheme.GREEN, html_classes)
260260
# The rest of the theme classes should not be applied
261261
for theme in list(
262-
filter(lambda theme: theme != ColourTheme.EARTH, self.themes)
262+
filter(lambda theme: theme != ColourTheme.GREEN, self.themes)
263263
):
264264
self.assertNotIn(theme, html_classes)

0 commit comments

Comments
 (0)