Skip to content

Commit 41b7d85

Browse files
authored
Add an email text option to the contact snippet (#285)
* Add an email text option to the contact snippet
1 parent 1632078 commit 41b7d85

File tree

8 files changed

+50
-7
lines changed

8 files changed

+50
-7
lines changed

docs/custom-features/contact.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ The `tbx.people.Contact` model represents contact information, including details
88

99
1. `title`: A descriptive title for the contact block, typically used as a heading.
1010
2. `text`: Additional text to accompany the contact information, providing further context.
11-
3. `cta`: Call-to-action block, allowing customization of a button link and text.
12-
4. `name`: The name of the contact person or entity.
13-
5. `role`: The role or position of the contact person.
14-
6. `image`: An image associated with the contact.
15-
7. `default_contact`: Flag to designate this contact as the default for the site.
11+
3. `email_text`: An email field which will display an email address and link below the button cta.
12+
4. `cta`: Call-to-action block, allowing customization of a button link and text.
13+
5. `name`: The name of the contact person or entity.
14+
6. `role`: The role or position of the contact person.
15+
7. `image`: An image associated with the contact.
16+
8. `default_contact`: Flag to designate this contact as the default for the site.
1617

1718
The `Contact` model also includes functionality to:
1819

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.11 on 2024-07-19 09:03
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("people", "0009_add_earth_colour_theme"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="contact",
15+
name="email_text",
16+
field=models.EmailField(blank=True, max_length=254),
17+
),
18+
]

tbx/people/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class Contact(index.Indexed, models.Model):
4444
text = models.TextField(
4545
blank=True,
4646
)
47+
email_text = models.EmailField(
48+
blank=True,
49+
)
4750
cta = StreamField(
4851
[("call_to_action", ContactCTABlock(label="CTA"))],
4952
blank=True,
@@ -106,6 +109,7 @@ def button_text(self):
106109
panels = [
107110
FieldPanel("title"),
108111
FieldPanel("text"),
112+
FieldPanel("email_text"),
109113
FieldPanel("cta", heading="Call to action"),
110114
MultiFieldPanel(
111115
[

tbx/project_styleguide/templates/patterns/molecules/footer-cta/footer-cta.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="grid__footer-contact footer-cta">
22
{% include "patterns/atoms/motif-heading/motif-heading.html" with heading=contact_heading heading_level=2 classes="motif-heading--two motif-heading--static footer-cta__heading" %}
33

4-
<p class="footer-cta__text">{{ contact_text }} </p>
4+
<p class="footer-cta__text">{{ contact_text }}</p>
55

66
<div class="footer-cta__grid">
77
{% include "patterns/atoms/avatar/avatar.html" with avatar=contact_image classes="footer-cta__avatar avatar--smallest" %}
@@ -13,6 +13,11 @@
1313

1414
<div class="footer-cta__button-wrapper">
1515
<a href="{{ contact_link }}" class="button footer-cta__button">{{ contact_action }}</a>
16+
17+
{% if contact_email %}
18+
<p class="footer-cta__email-wrapper"><a class="footer-cta__email" href="mailto:{{ contact_email }}">{{ contact_email }}</a></p>
19+
{% endif %}
1620
</div>
21+
1722
</div>
1823
</div>

tbx/project_styleguide/templates/patterns/molecules/footer-cta/footer-cta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ context:
44
contact_name: Will Heinemann
55
contact_role: New Business Director
66
contact_link: '#'
7+
contact_email: [email protected]
78
contact_action: Get in touch
89

910
tags:

tbx/project_styleguide/templates/patterns/organisms/footer/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<span class="grid__footer-line footer__line"></span>
77
{% with contact=page.footer_contact %}
88
{% if contact %}
9-
{% include "patterns/molecules/footer-cta/footer-cta.html" with contact_heading=contact.title contact_text=contact.text contact_link=contact.link contact_name=contact.name contact_role=contact.role contact_image=contact.image contact_action=contact.button_text %}
9+
{% include "patterns/molecules/footer-cta/footer-cta.html" with contact_heading=contact.title contact_text=contact.text contact_link=contact.link contact_name=contact.name contact_role=contact.role contact_image=contact.image contact_action=contact.button_text contact_email=contact.email_text %}
1010
{% endif %}
1111
{% endwith %}
1212

tbx/project_styleguide/templates/patterns/organisms/footer/footer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ context:
66
name: Will Heinemann
77
role: New Business Director
88
link: '#'
9+
email_text: '[email protected]'
910
button_text: Get in touch
1011
settings:
1112
navigation:

tbx/static_src/sass/components/_footer-cta.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,17 @@
6767
&__button {
6868
padding: 12px 20px;
6969
}
70+
71+
&__email-wrapper {
72+
margin-top: $spacer-small;
73+
margin-bottom: $spacer-small;
74+
75+
@include media-query(large) {
76+
margin-bottom: 0;
77+
}
78+
}
79+
80+
&__email {
81+
@include link-styles();
82+
}
7083
}

0 commit comments

Comments
 (0)