Skip to content

Commit 38d54f0

Browse files
committed
Add voting appeal specific content
1 parent 59675fd commit 38d54f0

3 files changed

Lines changed: 121 additions & 2 deletions

File tree

www/docs/style/sass/parts/_donation-banner.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,29 @@
2323
);
2424
}
2525

26-
@media (min-width: $medium-screen) {
26+
@media (min-width: $medium-screen) {
2727
padding: 2.5em;
2828
}
2929
}
3030

31+
// More prominent variant used for voting summary appeal.
32+
.panel--donation-banner--appeal {
33+
border-width: 2px;
34+
border-color: $primary-color;
35+
36+
&::before {
37+
height: 6px;
38+
}
39+
40+
.donation-banner__title {
41+
font-size: 1.3em;
42+
43+
@media (min-width: $medium-screen) {
44+
font-size: 1.5em;
45+
}
46+
}
47+
}
48+
3149
.donation-banner__content {
3250
padding: 0; // Override panel default padding
3351
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
$appeal_start = strtotime('2026-07-01 00:00:00');
4+
$appeal_end = strtotime('2026-07-16 23:59:59');
5+
6+
$now = time();
7+
$voting_appeal_active = ($now >= $appeal_start && $now <= $appeal_end);
8+
9+
// Admin override for testing (e.g. ?show_voting_appeal=1 / ?show_voting_appeal=0)
10+
if (isset($_GET['show_voting_appeal'])) {
11+
$voting_appeal_active = $_GET['show_voting_appeal'] === '1';
12+
}
13+
14+
// Expanded by default; remember if the user has collapsed it (own cookie, lasts 1 week).
15+
// Uses a distinct cookie name so collapsing the appeal does not affect the standard
16+
// donation banner shown on other MP pages, and vice-versa.
17+
$appeal_expanded = !isset($_COOKIE['voting_appeal_collapsed']);
18+
19+
$current_page = isset($pagetype) && $pagetype ? $pagetype : 'votes';
20+
$utm = 'utm_source=' . urlencode($current_page) . '&utm_campaign=twfy_voting_appeal';
21+
?>
22+
23+
<?php if ($voting_appeal_active) { ?>
24+
<div class="panel panel--donation-banner panel--donation-banner--appeal" id="voting-appeal">
25+
<div class="donation-banner__content">
26+
<div class="donation-banner__header">
27+
<h3 class="donation-banner__title">
28+
<span class="donation-banner__icon">💚</span>
29+
We've updated our voting summaries
30+
</h3>
31+
<button class="donation-banner__toggle js-voting-appeal-toggle" aria-expanded="<?= $appeal_expanded ? 'true' : 'false' ?>" aria-controls="voting-appeal-details">
32+
<span class="donation-banner__toggle-text">Why we need your support</span>
33+
<span class="donation-banner__toggle-arrow">↓</span>
34+
</button>
35+
</div>
36+
37+
<div id="voting-appeal-details" class="donation-banner__details<?= $appeal_expanded ? ' is-open' : '' ?>">
38+
<div class="donation-banner__message">
39+
<p>
40+
Our small team <a href="https://www.mysociety.org/2026/07/01/theyworkforyou-voting-summaries-update-july-2026/">works hard</a> to show how your MP has voted on the issues that matter to you.
41+
</p>
42+
<p>
43+
Your donations help keep TheyWorkForYou running and independent. If it's useful to you, please help keep it going.
44+
</p>
45+
</div>
46+
47+
<div class="donation-banner__actions">
48+
<a href="/support-us/?<?= $utm ?>#donate-form" class="button tertiary">
49+
Support TheyWorkForYou
50+
</a>
51+
<a href="/support-us/?how-often=monthly&how-much=5&<?= $utm ?>#donate-form" class="button button--outline">
52+
£5/month
53+
</a>
54+
<a href="/support-us/?how-often=one-off&how-much=10&<?= $utm ?>#donate-form" class="button button--outline">
55+
£10 one-off
56+
</a>
57+
</div>
58+
</div>
59+
</div>
60+
</div>
61+
62+
<script>
63+
// Toggle functionality for the voting appeal banner
64+
(function() {
65+
const toggle = document.querySelector('.js-voting-appeal-toggle');
66+
const details = document.querySelector('#voting-appeal-details');
67+
68+
if (toggle && details) {
69+
toggle.addEventListener('click', function() {
70+
const isExpanded = toggle.getAttribute('aria-expanded') === 'true';
71+
72+
if (isExpanded) {
73+
details.classList.remove('is-open');
74+
toggle.setAttribute('aria-expanded', 'false');
75+
76+
// Set cookie to remember collapsed state for 1 week
77+
var expires = new Date();
78+
expires.setTime(expires.getTime() + (7 * 24 * 60 * 60 * 1000)); // 7 days
79+
document.cookie = 'voting_appeal_collapsed=1;expires=' + expires.toUTCString() + ';path=/';
80+
} else {
81+
details.classList.add('is-open');
82+
toggle.setAttribute('aria-expanded', 'true');
83+
84+
// Remove the collapsed cookie
85+
document.cookie = 'voting_appeal_collapsed=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/';
86+
}
87+
});
88+
}
89+
})();
90+
</script>
91+
<?php } else { ?>
92+
<?php
93+
// Outside the campaign window, fall back to the standard 20% donation banner.
94+
include __DIR__ . '/_donation_banner.php';
95+
?>
96+
<?php }; ?>

www/includes/easyparliament/templates/html/mp/votes.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
</div>
2020
<div class="primary-content__unit">
2121

22-
<?php include '_donation_banner.php'; ?>
22+
<?php
23+
// During the voting appeal campaign this shows the aggressive 100%
24+
// appeal; outside the window it falls back internally to the standard
25+
// 20% donation banner.
26+
include '_voting_appeal.php';
27+
?>
2328

2429
<?php if ($profile_message): ?>
2530
<div class="panel panel--profile-message">

0 commit comments

Comments
 (0)