Skip to content

Commit

Permalink
EWPP-2875: Add EC logo and remove the title from EC footers.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Dec 7, 2022
1 parent 93b4ca9 commit 892ecc8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 40 deletions.
24 changes: 24 additions & 0 deletions oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,30 @@ function oe_theme_theme_suggestions_oe_corporate_blocks_eu_footer_alter(array &$
* Implements hook_preprocess_HOOK().
*/
function oe_theme_preprocess_oe_corporate_blocks_ec_footer(array &$variables) {
$site_logo_href = 'https://commission.europa.eu';
// Ensure the site logo falls back to english version if the language is
// not EU language.
$language_code = \Drupal::languageManager()->getCurrentLanguage()->getId();
if (!EuropeanUnionLanguages::hasLanguage($language_code)) {
if ($language_code === 'nb') {
// Set correct icon for Norwegian language.
$variables['current_language_id'] = 'no';
}
else {
// Check whether ECL provides a logo for the language.
$ecl_logo = DRUPAL_ROOT . '/' . drupal_get_path('theme', 'oe_theme') . '/dist/' . $variables['ecl_component_library'] . '/images/logo/';
$ecl_logo .= $variables['ecl_component_library'] === 'eu' ? 'standard-version/positive/' : 'positive/';
$ecl_logo .= 'logo-' . $variables['ecl_component_library'] . '--' . $language_code . '.svg';
if (!file_exists($ecl_logo)) {
// Provide fallback "en" icon if language logo doesn't exist.
$variables['current_language_id'] = 'en';
}
}
}
else {
$site_logo_href .= '/index_' . EuropeanUnionLanguages::getInternalLanguageCode($variables['current_language_id']);
}
$variables['path'] = $site_logo_href;
_oe_theme_preprocess_site_specific_footer_links($variables);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

{% set _first_column = [
{
'title': {
'link': {
'label': corporate_footer.corporate_site_link.label,
'path': corporate_footer.corporate_site_link.href,
'logo': {
'aria_label': 'Home'|t ~ ' - ' ~ 'European Commission'|t,
'alt': 'European Commission logo'|t,
'title': 'European Commission'|t,
'language': current_language_id,
'path': path,
'src_desktop': ecl_logo_path ~ '/negative/logo-ec--' ~ current_language_id|to_internal_language_id ~ '.svg',
},
},
'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}),
},
] %}
Expand All @@ -36,7 +38,6 @@
},
]
%}

{% block content %}
{% include '@ecl-twig/site-footer' with {
'rows': [[_first_column, _second_column]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@
{% set _bottom_row = [
[
{
'title': {
'link': {
'label': corporate_footer.corporate_site_link.label,
'path': corporate_footer.corporate_site_link.href,
'logo': {
'aria_label': 'Home'|t ~ ' - ' ~ 'European Commission'|t,
'alt': 'European Commission logo'|t,
'title': 'European Commission'|t,
'language': current_language_id,
'path': path,
'src_desktop': ecl_logo_path ~ '/negative/logo-ec--' ~ current_language_id|to_internal_language_id ~ '.svg',
},
},
}
],
[
Expand Down
8 changes: 4 additions & 4 deletions tests/features/corporate-blocks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Corporate blocks feature
Scenario Outline: By default the European Commission footer is displayed.
Given I am an anonymous user
When I am on "<page>"
Then I should see the European Commission footer with link "https://ec.europa.eu/info/index_en"
Then I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission"

Examples:
| page |
Expand All @@ -27,18 +27,18 @@ Feature: Corporate blocks feature
Scenario Outline: Changing the site's style will display either the European Commission or the European Union footer.
Given I am an anonymous user
When I am on "<page>"
Then I should see the European Commission footer with link "https://ec.europa.eu/info/index_en"
Then I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission"
And I should not see the "European Union" footer

When the theme is configured to use the "European Union" style
And I reload the page
Then I should not see the "European Commission" footer
But I should see the European Union footer with link "https://european-union.europa.eu/index_en" label "Home - European Union" image alt "European Union flag" title "European Union"
But I should see the "European Union" footer with link "https://european-union.europa.eu/index_en" label "Home - European Union" image alt "European Union flag" title "European Union"

When the theme is configured to use the "European Commission" style
And I reload the page
Then I should not see the "European Union" footer
But I should see the European Commission footer with link "https://ec.europa.eu/info/index_en"
But I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission"

Examples:
| page |
Expand Down
34 changes: 9 additions & 25 deletions tests/src/Behat/OeThemeTestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,13 @@ protected function getDemoPageByTitle(string $title): NodeInterface {
/**
* Assert given corporate footer presence on page.
*
* @Then I should see the European Commission footer with link :link
* @Then I should see the :component_library footer with link :link label :label image alt :img_alt title :img_title
*/
public function assertEuropeanCommissionFooterBlockOnPage(string $link): void {
// Make sure a corporate footer is present on the page.
$this->assertSession()->elementExists('css', 'footer.ecl-site-footer');
// European Commission footer is presented.
Assert::assertEquals('European Commission', $this->getFooterType(), 'European Commission footer is not presented on the page.');

// Assert footer data.
$title_link = $this->getSession()->getPage()->find('css', '.ecl-site-footer__title-link[href="' . $link . '"]');
Assert::assertNotEmpty($title_link, 'European Commission footer link is not found.');
}

/**
* Assert given corporate footer presence on page.
*
* @Then I should see the European Union footer with link :link label :label image alt :img_alt title :img_title
*/
public function assertEuropeanUnionFooterBlockOnPage(string $link, string $label, string $img_alt, string $img_title): void {
public function assertEuropeanFooterBlockOnPage(string $component_library, string $link, string $label, string $img_alt, string $img_title): void {
// Make sure a corporate footer is present on the page.
$this->assertSession()->elementExists('css', 'footer.ecl-site-footer');
// European Union footer is presented.
Assert::assertEquals('European Union', $this->getFooterType(), 'European Union footer is not presented on the page.');
Assert::assertEquals($component_library, $this->getFooterType(), 'European Union footer is not presented on the page.');

// Assert footer data.
$page = $this->getSession()->getPage();
Expand Down Expand Up @@ -371,17 +355,17 @@ public function setCorporateLibrary(string $component_library): void {
* Determines footer type.
*
* The ECL doesn't provide a way to determine type of the footer except as
* to check the existence of the logo.
* 'European Union' has logo, 'European Commission' doesn't.
* to check the attributes of the logo.
*
* @return string
* 'European Union' or 'European Commission'.
*/
protected function getFooterType(): string {
$logo = $this->getSession()
->getPage()
->find('css', 'footer.ecl-site-footer img.ecl-site-footer__logo-image-desktop');
return empty($logo) ? 'European Commission' : 'European Union';
$logo = $this->getSession()->getPage()->find('css', 'footer.ecl-site-footer .ecl-site-footer__logo-link');
if ($logo->getAttribute('aria-label') === 'Home - European Union') {
return 'European Union';
}
return 'European Commission';
}

/**
Expand Down

0 comments on commit 892ecc8

Please sign in to comment.