Skip to content

Commit

Permalink
fixup! New search box approach with temp photos
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Jul 8, 2024
1 parent 4b019d8 commit b16b13f
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 68 deletions.
17 changes: 17 additions & 0 deletions classes/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,27 @@ public function display() {
$data['featured'] = $this->getEditorialContent();
$data['topics'] = $this->getFrontPageTopics();
$data['divisions'] = $this->getRecentDivisions();
$data['search_box'] = $this->getSearchBox($data);

return $data;
}

protected function getSearchBox(array $data): Search\SearchBox{
$search_box = new Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--overall";
$search_box->homepage_subhead = "";
$search_box->homepage_desc = "Understand who represents you, across the UK's Parliaments.";
$search_box->search_section = "";
$search_box->quick_links = [];
if (count($data["mp_data"])) {
$search_box->add_quick_link('Find out more about your MP (' . $data["mp_data"]['name'] . ')', $data["mp_data"]['mp_url']);
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/');
$search_box->add_quick_link('Donate to support our work', '/support-us/');
return $search_box;
}

protected function getRegionalList() {
return null;
}
Expand Down
17 changes: 17 additions & 0 deletions classes/SPHomepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ class SPHomepage extends Homepage {
'SPWRANSLIST' => array('recent_wrans', 'spwransfront', 'Written answers'),
);

protected function getSearchBox(array $data): Search\SearchBox{
$search_box = new Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--scotland";
$search_box->homepage_subhead = "Scottish Parliament";
$search_box->homepage_desc = "";
$search_box->search_section = "scotland";
$search_box->quick_links = [];
if (count($data["mp_data"])) {
$regional_con = $data["regional"][0]["constituency"];
$search_box->add_quick_link('Find out more about your MSPs for ' . $data["mp_data"]["constituency"] . '(' . $regional_con . ')', '/postcode/?pc=' . $data["mp_data"]['postcode'] );
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/');
$search_box->add_quick_link('Donate to support our work', '/support-us/');
return $search_box;
}

protected function getEditorialContent() {
$debatelist = new \SPLIST;
$item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
Expand Down
34 changes: 34 additions & 0 deletions classes/Search/SearchBox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace MySociety\TheyWorkForYou\Search;


class SearchBox
{
public string $homepage_panel_class;
public string $homepage_subhead;
public string $homepage_desc;
public string $search_section;
public array $quick_links;

public function __construct(string $homepage_panel_class = '',
string $homepage_subhead = '',
string $homepage_desc = '',
string $search_section = '',
array $quick_links = [])
{
$this->homepage_panel_class = $homepage_panel_class;
$this->homepage_subhead = $homepage_subhead;
$this->homepage_desc = $homepage_desc;
$this->search_section = $search_section;
$this->quick_links = $quick_links;
}

public function add_quick_link(string $title, string $url): void
{
$this->quick_links[] = ['title' => $title, 'url' => $url];
}

}

?>
29 changes: 29 additions & 0 deletions classes/SectionView/NiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,40 @@ protected function display_front_ni() {
$data['debates'] = array( 'recent' => $recent);

$data['regional'] = $this->getMLAList();
$data['search_box'] = $this->getSearchBox($data);
$data['template'] = 'ni/index';

return $data;
}



protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox{

global $THEUSER;

if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
$postcode = $THEUSER->postcode();
} else {
$postcode = null;
}

$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--niassembly";
$search_box->homepage_subhead = "Northern Ireland Assembly";
$search_box->homepage_desc = "";
$search_box->search_section = "ni";
$search_box->quick_links = [];
if (count($data["regional"])) {
$constituency = $data["regional"][0]["constituency"];
$search_box->add_quick_link('Find out more about your MLAs for ' . $constituency, '/postcode/?pc=' . $postcode);
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/');
$search_box->add_quick_link('Donate to support our work', '/support-us/');
return $search_box;
}

protected function getMLAList() {
global $THEUSER;

Expand Down
31 changes: 31 additions & 0 deletions classes/SectionView/SeneddView.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,42 @@ protected function display_front_senedd() {
$data['debates'] = array( 'recent' => $recent);

$data['regional'] = $this->getMSList();
$data['search_box'] = $this->getSearchBox($data);
$data['template'] = 'senedd/index';

return $data;
}

protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox{
$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--senedd";
if (LANGUAGE == 'cy') {
$search_box->homepage_subhead = "Senedd";
} else {
$search_box->homepage_subhead = "Senedd / Welsh Parliament";
}
$search_box->homepage_desc = "";
$search_box->search_section = "senedd";
$search_box->quick_links = [];
if (count($data["regional"])) {
// get all unique constituencies
$constituencies = array();
foreach ($data["regional"] as $member) {
$constituencies[$member["constituency"]] = 1;
}
$constituencies = array_keys($constituencies);
if (LANGUAGE == 'cy'){
$search_box->add_quick_link('Darganfod mwy am eich Aelodau Cynulliad dros ' . $constituencies[0] . ' a ' . $constituencies[1], '/postcode/?pc=' . $data["mp_data"]['postcode']);
} else {
$search_box->add_quick_link('Find out more about your MSs for ' . $constituencies[0] . ' and ' . $constituencies[1], '/postcode/?pc=' . $data["mp_data"]['postcode']);
}
}
$search_box->add_quick_link(gettext('Create and manage email alerts'), '/alert/');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), 'https://www.mysociety.org/subscribe/');
$search_box->add_quick_link(gettext('Donate to support our work'), '/support-us/');
return $search_box;
}

protected function getMSList() {
global $THEUSER;

Expand Down
66 changes: 44 additions & 22 deletions www/docs/style/sass/parts/_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,71 @@
.panel--homepage--overall {
background: rgba(#000, 0.5) url('../img/parliament-photo.jpg') center/cover no-repeat;
background-blend-mode: overlay; /* Blends the color with the image */

.quick-links__item {
background-color: #444;
display: inline-block;
}
}

.panel--homepage--senedd {
background: rgba(#000, 0.5) url('../img/senedd-photo.jpg') center/cover no-repeat;
background-blend-mode: overlay; /* Blends the color with the image */
background-blend-mode: overlay;

.quick-links__item {
background-color: #444;
display: inline-block;
}
}

.panel--homepage--scotland {
background: rgba(#000, 0.5) url('../img/scotland-photo.jpg') center/cover no-repeat;
background-blend-mode: overlay; /* Blends the color with the image */
background-blend-mode: overlay;

.quick-links__item {
background-color: #444;
display: inline-block;
}
}

.panel--homepage--niassembly {
background: rgba(#000, 0.5) url('../img/niassembly-photo.jpg') center/cover no-repeat;
background-blend-mode: overlay; /* Blends the color with the image */
background-blend-mode: overlay;

.quick-links__item {
background-color: #444;
display: inline-block;
}
}

.home__quick-links{
padding-top:20px;

}

.panel--primary {
// background-color: $colour_primary;
// background-image: url('../img/houses-of-parliament-tablet.jpg');
// background: linear-gradient(to right, $colour_primary 65%, rgba($colour_primary, 0.0) 68%, rgba($colour_primary, 0.0)), url('../img/houses-of-parliament-tablet.jpg');
background-size: cover;
background-repeat: no-repeat;
color: $colour_off_white;

a, h2, h3 {
color: inherit;
h1 {
color: $colour_off_white;
margin-bottom: 5px;
}

h2, label, li {
color: $colour_mid_grey;
}

a {
color: #fff;
}

h3 {
color: $colour_off_white
}


.button {
background-color: #fff;
color: darken($colour_primary, 20%);
Expand Down Expand Up @@ -101,21 +137,7 @@
padding-bottom: 0;
}

.panel--primary {

h1 {
color: $colour_off_white;
margin-bottom: 5px;
}

h2, label, h3, li {
color: $colour_mid_grey;
}

a {
color: #fff;
}
}

.panel--inverted {
background-color: #444;
Expand Down
22 changes: 11 additions & 11 deletions www/includes/easyparliament/templates/html/homepage/search-box.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<div class="panel panel--primary <?= $homepage_panel_class ?>">
<div class="panel panel--primary <?= $search_box->homepage_panel_class ?>">
<div class ="row nested-row">
<div class="home__search">
<div>
<h1 class="site-home__logo">TheyWorkForYou</h1>
</div>
<?php if ($homepage_subhead) { ?>
<?php if ($search_box->homepage_subhead) { ?>
<div>
<h2 class="site-home__logo" style="color:#fff"><?= $homepage_subhead ?></h2>
<h2 class="site-home__logo" style="color:#fff"><?= $search_box->homepage_subhead ?></h2>
</div>
<?php } ?>
<?php if ($homepage_desc) { ?>
<p><?= $homepage_desc ?></p>
<?php if ($search_box->homepage_desc) { ?>
<p><?= $search_box->homepage_desc ?></p>
<?php } ?>
</div>
</div>
<div class="row nested-row ">
<div class="home__search">
<form action="<?= $urls['search'] ?>" method="GET" onsubmit="trackFormSubmit(this, 'Search', 'Submit', 'Home'); return false;">
<?php if ($search_section) { ?>
<input type="hidden" name="section" value="<?= $search_section ?>">
<?php if ($search_box->search_section) { ?>
<input type="hidden" name="section" value="<?= $search_box->search_section ?>">
<?php } ?>
<div class="row collapse">
<div class="medium-9 columns">
Expand All @@ -42,18 +42,18 @@
</ul>
<?php } ?>
</div>
<div class="home__quick-links" style="padding-top:20px;">
<div class="home__quick-links">
<h3>Quick links</h3>
<ul class="quick-links__list">
<?php foreach ($quick_links as $quick_link) { ?>
<li><a href="<?= $quick_link['url'] ?>"><?= $quick_link['title'] ?></a></li>
<?php foreach ($search_box->quick_links as $search_box->quick_link) { ?>
<li><div class="quick-links__item"><a href="<?= $search_box->quick_link['url'] ?>"><?= $search_box->quick_link['title'] ?></a></div></li>
<?php } ?>
</ul>

</div>
<div>
<p style="margin-bottom:0px">Built by
<a href="https://www.mysociety.org?utm_source=theyworkforyou.com&amp;utm_content=footer+logo&amp;utm_medium=link&amp;utm_campaign=mysoc_footer" class="mysoc__org__logo mysoc__org__logo--mysociety">mySociety</a>
<a href="https://www.mysociety.org?utm_source=theyworkforyou.com&amp;utm_medium=link&amp;utm_campaign=twfy_search_box" class="mysoc__org__logo mysoc__org__logo--mysociety">mySociety</a>
</p>
</div>
</div>
11 changes: 0 additions & 11 deletions www/includes/easyparliament/templates/html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
<div class="homepage-panels">

<?php
$homepage_panel_class = "panel--homepage--overall";
$homepage_subhead = "";
$homepage_desc = "Helping you understand who represents you, across the UK's Parliaments.";
$search_section = "";
$quick_links = [];
$quick_links[] = ['title' => 'Create and manage email alerts', 'url' => '/alert/'];
if (count($mp_data)) {
$quick_links[] = ['title' => 'Find out more about your MP', 'url' => $mp_data['mp_url']];
}
$quick_links[] = ['title' => 'Subscribe to our newsletter', 'url' => 'https://www.mysociety.org/subscribe/'];
$quick_links[] = ['title' => 'Donate to support our work', 'url' => '/support-us/'];
include 'homepage/search-box.php';
?>

Expand Down
8 changes: 0 additions & 8 deletions www/includes/easyparliament/templates/html/ni/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<div class="homepage-panels">

<?php
$homepage_panel_class = "panel--homepage--niassembly";
$homepage_subhead = "Northern Ireland Assembly";
$homepage_desc = "";
$search_section = "ni";
$quick_links = [];
$quick_links[] = ['title' => 'Create and manage email alerts', 'url' => '/alert/'];
$quick_links[] = ['title' => 'Subscribe to our newsletter', 'url' => 'https://www.mysociety.org/subscribe/'];
$quick_links[] = ['title' => 'Donate to support our work', 'url' => '/support-us/'];
include dirname(__FILE__) . '/../homepage/search-box.php';
?>

Expand Down
8 changes: 0 additions & 8 deletions www/includes/easyparliament/templates/html/scotland/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<div class="homepage-panels">

<?php
$homepage_panel_class = "panel--homepage--scotland";
$homepage_subhead = "Scottish Parliament";
$homepage_desc = "";
$search_section = "scotland";
$quick_links = [];
$quick_links[] = ['title' => 'Create and manage email alerts', 'url' => '/alert/'];
$quick_links[] = ['title' => 'Subscribe to our newsletter', 'url' => 'https://www.mysociety.org/subscribe/'];
$quick_links[] = ['title' => 'Donate to support our work', 'url' => '/support-us/'];
include dirname(__FILE__) . '/../homepage/search-box.php';
?>

Expand Down
8 changes: 0 additions & 8 deletions www/includes/easyparliament/templates/html/senedd/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<div class="homepage-panels">

<?php
$homepage_panel_class = "panel--homepage--senedd";
$homepage_subhead = "Senedd / Welsh Parliament";
$homepage_desc = "";
$search_section = "senedd";
$quick_links = [];
$quick_links[] = ['title' => 'Create and manage email alerts', 'url' => '/alert/'];
$quick_links[] = ['title' => 'Subscribe to our newsletter', 'url' => 'https://www.mysociety.org/subscribe/'];
$quick_links[] = ['title' => 'Donate to support our work', 'url' => '/support-us/'];
include dirname(__FILE__) . '/../homepage/search-box.php';
?>

Expand Down

0 comments on commit b16b13f

Please sign in to comment.