Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home page box #1809

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions classes/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,28 @@ 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'], 'torso');
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'pound');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
return $search_box;
}

protected function getRegionalList() {
return null;
}
Expand Down
18 changes: 18 additions & 0 deletions classes/SPHomepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ 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'], 'torso' );
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'pound');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
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, string $icon): void
{
$this->quick_links[] = ['title' => $title, 'url' => $url, 'icon' => $icon];
}

}

?>
28 changes: 28 additions & 0 deletions classes/SectionView/NiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,38 @@ 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, 'torso');
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/','megaphone');
$search_box->add_quick_link('Subscribe to our newsletter', 'https://www.mysociety.org/subscribe/', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/','pound');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
return $search_box;
}

protected function getMLAList() {
global $THEUSER;
Expand Down
32 changes: 32 additions & 0 deletions classes/SectionView/SeneddView.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,43 @@ 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'],'torso');
} else {
$search_box->add_quick_link('Find out more about your MSs for ' . $constituencies[0] . ' and ' . $constituencies[1], '/postcode/?pc=' . $data["mp_data"]['postcode'],'torso');
}
}
$search_box->add_quick_link(gettext('Create and manage email alerts'), '/alert/','megaphone');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), 'https://www.mysociety.org/subscribe/', 'mail');
$search_box->add_quick_link(gettext('Donate to support our work'), '/support-us/', 'pound');
$search_box->add_quick_link(gettext('Learn more about TheyWorkForYou'), '/about/', 'magnifying-glass');
return $search_box;
}

protected function getMSList() {
global $THEUSER;

Expand Down
16 changes: 16 additions & 0 deletions locale/cy_GB.UTF-8/LC_MESSAGES/TheyWorkForYou.po
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ msgstr "Ni allwch chwilio am fwy nag un ystod o ddyddiadau."
msgid "Maximum term length is 255 characters."
msgstr "Yr hyd term mwyaf yw 255 nod."

#: classes/SectionView/SeneddView.php:131
msgid "Create and manage email alerts"
msgstr "Creu hysbysiad"

#: classes/SectionView/SeneddView.php:132
msgid "Subscribe to our newsletter"
msgstr "Cofrestrwch am y newyddion diweddaraf gan mySociety"

#: classes/SectionView/SeneddView.php:133
msgid "Donate to support our work"
msgstr "Cyfrannu"

#: classes/SectionView/SeneddView.php:134
msgid "Learn more about TheyWorkForYou"
msgstr "Ynglŷn â TheyWorkForYou"

#: classes/User.php:196
msgid "Please enter a password"
msgstr "Rhowch eich cyfrinair"
Expand Down
2 changes: 1 addition & 1 deletion tests/AcceptBasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private function fetch_page($path, $file = 'index.php', $vars = array())
public function testHome()
{
$page = $this->fetch_page('');
$this->assertStringContainsString('Find out more', $page);
$this->assertStringContainsString('Learn more about', $page);
$this->assertStringContainsString('Create an alert', $page);
$this->assertStringContainsString('Upcoming', $page);
}
Expand Down
1 change: 1 addition & 0 deletions www/docs/style/img/mysoc-footer/logo-mysociety-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/niassembly-photo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/parliament-photo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/scotland-photo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/senedd-photo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/uk-parliament-desktop.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-huge.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-mobile.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-tablet.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion www/docs/style/sass/_mysoc_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $mysoc-footer-background-color: #fff !default;
$mysoc-footer-text-color: #333 !default;
$mysoc-footer-site-name-text-color: $mysoc-footer-text-color !default;

$mysoc-footer-link-text-color: #4FADED !default;
$mysoc-footer-link-text-color: $links !default;
$mysoc-footer-link-hover-text-color: darken($mysoc-footer-link-text-color, 10%) !default;

$mysoc-footer-site-name-font-size: 1.5em !default;
Expand Down
15 changes: 11 additions & 4 deletions www/docs/style/sass/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ $column-gutter: 3%;
$row-width: em-calc(1140);
$block-grid-default-spacing: 3%;

$primary-color: #62b356;
$primary-color: #4b7e45;
$primary-color-100: lighten($primary-color, 45%);
$primary-color-200: lighten($primary-color, 40%);
$primary-color-300: lighten($primary-color, 35%);
$primary-color-600: darken($primary-color, 5%);
$primary-color-700: darken($primary-color, 10%);
$secondary-color: #A94CA6;
$color-red: #dc3545;
$color-yellow: #ffe500;

$body-bg: #f3f1eb;
$body-font-color: #333333;
$links: #4faded;
$links: #1567ae;
$brand: $primary-color;
$footer: #444;
$topbar-bg-color: $brand;
Expand Down Expand Up @@ -260,7 +267,7 @@ $margin: 1em;
// $paragraph-font-family: inherit;
// $paragraph-font-weight: normal;
// $paragraph-font-size: 1em;
// $paragraph-line-height: 1.6;
$paragraph-line-height: 1.4;
// $paragraph-margin-bottom: em-calc(20);
// $paragraph-aside-font-size: em-calc(14);
// $paragraph-aside-line-height: 1.35;
Expand Down Expand Up @@ -408,7 +415,7 @@ $margin: 1em;

// We use these to build padding for buttons.

// $button-med: em-calc(12);
$button-med: em-calc(8);
// $button-tny: em-calc(7);
// $button-sml: em-calc(9);
// $button-lrg: em-calc(16);
Expand Down
47 changes: 26 additions & 21 deletions www/docs/style/sass/_twfy-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ $medium-screen: 48em;
$large-screen: 65em;
$huge-screen: 71.25em;

$colour_primary: #62b356 !default;
$colour_primary: $primary-color !default;
$colour_black: #222222;
$colour_dark_grey: #666361;
$colour_grey: #7E7B78;
$colour_grey: #727170;
$colour_mid_grey: #ccc7c3;
$colour_light_grey: #e9e7e4;
$colour_off_white : #f2f1ef;
Expand Down Expand Up @@ -230,11 +230,14 @@ $weight_bold: 700;


.site-nav a.donate-button {
background-color: darken($colour_pale_red, 10%);
&:hover,
&:focus {
background-color: darken($colour_pale_red, 15%);
background-color: $color-red;
&:hover {
background-color: darken($color-red, 5%);
};
&:focus {
background-color: $color-yellow;
color: $body-font-color;
}
color: #FFF;
font-weight: $weight_bold;
@include border-radius(3px);
Expand All @@ -245,19 +248,26 @@ $weight_bold: 700;
font-weight: $weight_semibold;
border: 0;
@include border-radius(3px);
&:hover,
&:hover {
background-color: $primary-color-700;
}

&:focus {
background-color: darken($colour_primary, 10%);
background-color: $color-yellow;
color: $body-font-color;
}
}

button {
@extend .button;
}

.secondary-button,
.button--secondary {
background-color: $colour_off_white;
border: 1px solid $colour_light_grey;
color: $colour_dark_grey;
&:hover,
&:focus {
&:hover {
background-color: darken($colour_off_white, 5%);
color: $colour_black;
border-color: darken($colour_light_grey, 10%);
Expand All @@ -266,16 +276,14 @@ $weight_bold: 700;

.button--negative {
background-color: $colour_pale_red;
&:hover,
&:focus {
&:hover {
background-color: darken($colour_pale_red, 10%);
}
}

x
.button--red {
background-color: red;
&:hover,
&:focus {
&:hover {
background-color: darken($colour_pale_red, 10%);
}
}
Expand All @@ -297,8 +305,7 @@ $weight_bold: 700;
.button--violet {
background-color: $colour_violet;
&:hover,
&:active,
&:focus {
&:active {
background-color: darken($colour_violet, 10%);
}
}
Expand All @@ -307,8 +314,7 @@ $weight_bold: 700;
background-color: $colour_off_white;
color: #333;
&:hover,
&:active,
&:focus {
&:active {
color: #333;
background-color: darken($colour_off_white, 10%);
}
Expand All @@ -324,8 +330,7 @@ $weight_bold: 700;
}

&:hover,
&:active,
&:focus {
&:active {
background-color: darken(#3b5998, 10%);
}
}
Expand Down
Loading
Loading