From 9e8649c8bb86d284f2a2e74572dba774e07d399a Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:32:43 +0100 Subject: [PATCH 01/20] OEL-1147: Twig function to prepare section titles. Fix url issues. --- .../oe_whitelabel_helper/src/TwigExtension/TwigExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php index 16dd9244e..a2f7e5759 100644 --- a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php +++ b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php @@ -7,6 +7,7 @@ use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\oe_whitelabel_helper\EuropeanUnionLanguages; +use Drupal\Core\Url; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -122,6 +123,9 @@ public function bclFooterLinks(array $context, array $links): array { $altered_links = []; foreach ($links as $link) { + if ($link['href'] instanceof Url) { + $link['href'] = $link['href']->toString(); + } $altered_link = [ 'label' => $link['label'], 'path' => $link['href'], From c99685518c19e6de6874c2c81797c44e3550e618 Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:33:31 +0100 Subject: [PATCH 02/20] OEL-1147: Remove footer pattern, layouts and extra blocks. --- .../layouts/ec_footer_bottom_left.html.twig | 3 -- .../layouts/ec_footer_bottom_middle.html.twig | 7 ---- .../layouts/ec_footer_bottom_right.html.twig | 7 ---- .../layouts/ec_footer_middle_row.html.twig | 8 ---- templates/layouts/eu_footer_left.html.twig | 3 -- templates/layouts/eu_footer_middle.html.twig | 22 ---------- templates/layouts/eu_footer_right.html.twig | 8 ---- templates/layouts/footer_top_left.html.twig | 4 -- templates/layouts/footer_top_middle.html.twig | 29 ------------- templates/layouts/footer_top_right.html.twig | 29 ------------- ...k--oe-corporate-blocks-ec_footer.html.twig | 1 - ...k--oe-corporate-blocks-eu_footer.html.twig | 1 - .../patterns/footer/footer.ui_patterns.yml | 18 -------- .../pattern-footer--variant-ec.html.twig | 41 ------------------- .../pattern-footer--variant-eu.html.twig | 41 ------------------- 15 files changed, 222 deletions(-) delete mode 100644 templates/layouts/ec_footer_bottom_left.html.twig delete mode 100644 templates/layouts/ec_footer_bottom_middle.html.twig delete mode 100644 templates/layouts/ec_footer_bottom_right.html.twig delete mode 100644 templates/layouts/ec_footer_middle_row.html.twig delete mode 100644 templates/layouts/eu_footer_left.html.twig delete mode 100644 templates/layouts/eu_footer_middle.html.twig delete mode 100644 templates/layouts/eu_footer_right.html.twig delete mode 100644 templates/layouts/footer_top_left.html.twig delete mode 100644 templates/layouts/footer_top_middle.html.twig delete mode 100644 templates/layouts/footer_top_right.html.twig delete mode 100644 templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig delete mode 100644 templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig delete mode 100644 templates/patterns/footer/footer.ui_patterns.yml delete mode 100644 templates/patterns/footer/pattern-footer--variant-ec.html.twig delete mode 100644 templates/patterns/footer/pattern-footer--variant-eu.html.twig diff --git a/templates/layouts/ec_footer_bottom_left.html.twig b/templates/layouts/ec_footer_bottom_left.html.twig deleted file mode 100644 index 3e71e42d8..000000000 --- a/templates/layouts/ec_footer_bottom_left.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -
-

{{ 'European Commission'|t }}

-
diff --git a/templates/layouts/ec_footer_bottom_middle.html.twig b/templates/layouts/ec_footer_bottom_middle.html.twig deleted file mode 100644 index ee6f5c309..000000000 --- a/templates/layouts/ec_footer_bottom_middle.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% if links is defined and links is not empty and links is iterable %} -
- {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} -
-{% endif %} diff --git a/templates/layouts/ec_footer_bottom_right.html.twig b/templates/layouts/ec_footer_bottom_right.html.twig deleted file mode 100644 index ee6f5c309..000000000 --- a/templates/layouts/ec_footer_bottom_right.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% if links is defined and links is not empty and links is iterable %} -
- {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} -
-{% endif %} diff --git a/templates/layouts/ec_footer_middle_row.html.twig b/templates/layouts/ec_footer_middle_row.html.twig deleted file mode 100644 index a8dcecbbe..000000000 --- a/templates/layouts/ec_footer_middle_row.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -
-

{{ 'More information on:'|t }}

- {% if links is defined and links is not empty and links is iterable %} - {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} - {% endif %} -
diff --git a/templates/layouts/eu_footer_left.html.twig b/templates/layouts/eu_footer_left.html.twig deleted file mode 100644 index f1c952e87..000000000 --- a/templates/layouts/eu_footer_left.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -
- {{ bcl_block('whitelabel_eu_logo_block') }} -
diff --git a/templates/layouts/eu_footer_middle.html.twig b/templates/layouts/eu_footer_middle.html.twig deleted file mode 100644 index 50fcb5265..000000000 --- a/templates/layouts/eu_footer_middle.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -
-

{{ contact_eu_title }}

- {% if contact_eu_links is defined and contact_eu_links is not empty and contact_eu_links is iterable %} - {% for contact_link in contact_eu_links %} - {{ pattern('link', contact_link) }} - {% endfor %} - {% endif %} - -

{{ social_media_title }}

- {% if social_media_links is defined and social_media_links is not empty and social_media_links is iterable %} - {% for social_link in social_media_links %} - {{ pattern('link', social_link) }} - {% endfor %} - {% endif %} - -

{{ legal_title }}

- {% if legal_links is defined and legal_links is not empty and legal_links is iterable %} - {% for legal_link in legal_links %} - {{ pattern('link', legal_link) }} - {% endfor %} - {% endif %} -
diff --git a/templates/layouts/eu_footer_right.html.twig b/templates/layouts/eu_footer_right.html.twig deleted file mode 100644 index 8e84a2b05..000000000 --- a/templates/layouts/eu_footer_right.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -
-

{{ eu_institutions_title }}

- {% if eu_institutions_links is defined and eu_institutions_links is not empty and eu_institutions_links is iterable %} - {% for eu_link in eu_institutions_links %} - {{ pattern('link', eu_link) }} - {% endfor %} - {% endif %} -
diff --git a/templates/layouts/footer_top_left.html.twig b/templates/layouts/footer_top_left.html.twig deleted file mode 100644 index 1cf54e41a..000000000 --- a/templates/layouts/footer_top_left.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -
-

{{ title.link.label }}

-

{{ description }}

-
diff --git a/templates/layouts/footer_top_middle.html.twig b/templates/layouts/footer_top_middle.html.twig deleted file mode 100644 index 29fd539e7..000000000 --- a/templates/layouts/footer_top_middle.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{% if sections is defined and sections is not empty and sections is iterable %} -
- {% for section in sections %} - {% if loop.first %} -

{{ section.title }}

- {% else %} -

{{ section.title }}

- {% endif %} - {% if section.links is defined and section.links is not empty and section.links is iterable %} - {% set attributes = { - 'class': [ - 'text-decoration-none', - 'd-block', - 'mb-1' - ] - } %} - {% for link in section.links %} - {{ pattern('link', { - label: link.label, - path: link.path|render, - icon: link.icon, - icon_position: link.icon_position, - attributes: attributes - }) }} - {% endfor %} - {% endif %} - {% endfor %} -
-{% endif %} diff --git a/templates/layouts/footer_top_right.html.twig b/templates/layouts/footer_top_right.html.twig deleted file mode 100644 index 18adffdd0..000000000 --- a/templates/layouts/footer_top_right.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{% if sections is defined and sections is not empty and sections is iterable %} -
- {% for section in sections %} - {% if loop.first %} -

{{ section.title }}

- {% else %} -

{{ section.title }}

- {% endif %} - {% if section.links is defined and section.links is not empty and section.links is iterable %} - {% set attributes = { - 'class': [ - 'text-decoration-none', - 'd-block', - 'mb-1' - ] - } %} - {% for link in section.links %} - {{ pattern('link', { - label: link.label, - path: link.path|render, - icon: link.icon, - icon_position: link.icon_position, - attributes: attributes, - }) }} - {% endfor %} - {% endif %} - {% endfor %} -
-{% endif %} diff --git a/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig b/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig deleted file mode 100644 index cddd07099..000000000 --- a/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ content }} diff --git a/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig b/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig deleted file mode 100644 index cddd07099..000000000 --- a/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ content }} diff --git a/templates/patterns/footer/footer.ui_patterns.yml b/templates/patterns/footer/footer.ui_patterns.yml deleted file mode 100644 index 4ef07ce92..000000000 --- a/templates/patterns/footer/footer.ui_patterns.yml +++ /dev/null @@ -1,18 +0,0 @@ -footer: - label: Footer - description: Footer for oe_corporate blocks - variants: - ec: - label: European Commission - eu: - label: European Union - fields: - top_sections: - type: array - label: Sections at the top row of the footer - middle_sections: - type: array - label: Sections at the middle row the footer - bottom_sections: - type: array - label: Sections at the bottom row of the footer diff --git a/templates/patterns/footer/pattern-footer--variant-ec.html.twig b/templates/patterns/footer/pattern-footer--variant-ec.html.twig deleted file mode 100644 index f987fd2ab..000000000 --- a/templates/patterns/footer/pattern-footer--variant-ec.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -
- {% for section in top_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - description: section.description, - sections: section.sections - } %} - {% endfor %} -
-{% if middle_sections is defined and middle_sections is not empty and middle_sections is iterable %} - -{% endif %} -{% if bottom_sections is defined and bottom_sections is not empty and bottom_sections is iterable %} - -{% endif %} diff --git a/templates/patterns/footer/pattern-footer--variant-eu.html.twig b/templates/patterns/footer/pattern-footer--variant-eu.html.twig deleted file mode 100644 index a9db3f98c..000000000 --- a/templates/patterns/footer/pattern-footer--variant-eu.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -
- {% for section in top_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - description: section.description, - sections: section.sections - } %} - {% endfor %} -
-{% if middle_sections is defined and middle_sections is not empty and middle_sections is iterable %} - -{% endif %} -{% if bottom_sections is defined and bottom_sections is not empty and bottom_sections is iterable %} - -{% endif %} From b3fae0fd6d1da1e8bd0363a8805903192ecfbbc0 Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:34:21 +0100 Subject: [PATCH 03/20] OEL-1147: Add neutral variant in component library settings. --- oe_whitelabel.theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index 9c95a19ff..fca093230 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -111,7 +111,7 @@ function oe_whitelabel_form_system_theme_settings_alter(&$form, FormStateInterfa 'ec' => t('European Commission'), 'eu' => t('European Union'), ], - '#default_value' => theme_get_setting('component_library'), + '#default_value' => theme_get_setting('component_library') ?? 'eu', '#description' => t('Choose "European Commission" for websites hosted under the ec.europa.eu domain and "European Union" for websites hosted under the europa.eu domain.'), ]; $form['header_style'] = [ From 0866771b45f208c3d32411795c36bee4a82c6ecf Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:35:03 +0100 Subject: [PATCH 04/20] OEL-1147: Add NeutralFooterBlock extending from FooterBlockBase. --- .../src/Plugin/Block/NeutralFooterBlock.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php diff --git a/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php new file mode 100644 index 000000000..f1a7c1a67 --- /dev/null +++ b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php @@ -0,0 +1,44 @@ +addCacheContexts(['languages:language_interface']); + + $config = $this->configFactory->get('oe_corporate_blocks.ec_data.footer'); + $cache->addCacheableDependency($config); + + $build['#theme'] = 'oe_corporate_blocks_neutral_footer'; + + NestedArray::setValue($build, ['#corporate_footer', 'content_owner_details'], $config->get('content_owner_details')); + + $this->setSiteSpecificFooter($build, $cache); + + $cache->applyTo($build); + + return $build; + } + +} From a9f320c3b7322a34de5561d38c9b48959d19ead2 Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:35:21 +0100 Subject: [PATCH 05/20] OEL-1147: Corporate and neutral footer refactor. --- .../oe-corporate-blocks-ec-footer.html.twig | 180 ++++++---------- .../oe-corporate-blocks-eu-footer.html.twig | 192 ++++++++---------- ...-corporate-blocks-neutral-footer.html.twig | 104 ++++++++++ 3 files changed, 253 insertions(+), 223 deletions(-) create mode 100644 templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig diff --git a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig index 5a4dd8bd7..4a1cac8e8 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig @@ -1,121 +1,69 @@ -{# -/** - * @file - * Default theme implementation for rendering corporate blocks footer. - * - * Available variables: - * - site_owner: Site's owner. - * - site_specific_footer: Array (optional) with structure of the site specific footer compatible with the ECL ec-components-footer component. - * - site_identity: Site identity for custom footer. - * - social_links: Social media links for custom footer. - * - other_links: Other links for custom footer. - * - corporate_footer: Array with structure of corporate footer compatible with the ECL ec-components-footer component. - * - corporate_site_link: Corporate site link. - * - class_navigation: Provides the user with navigation through class names. - * - service_navigation: Contains services links - consistent throughout the family sites. - * - legal_navigation: Contains legal information links - consistent throughout the family sites. - * - * @ingroup themeable - */ -#} - -{% set _section_2 = [] %} -{% set _section_3 = [] %} - -{# First we parse the other_links, we make a simple grid. #} -{% for section in site_specific_footer.other_links %} - {% if loop.index is odd %} - {% set _section_2 = _section_2|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% else %} - {% set _section_3 = _section_3|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% endif %} -{% endfor %} - -{# When follow section is present. #} -{% if site_specific_footer.social_links is not empty %} - {# If section numbers are odd, then we flip the last row so to have the follow as first. #} - {% if _section_2|length > _section_3|length %} - {% set _last_in_section_2 = _section_2|last %} - - {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} - {% if _last_in_section_2 is empty %} - {% set _last_in_section_2 = _section_2[0] %} - {% set _section_2 = [] %} - {% endif %} - - {% set _section_2 = _section_2[:_section_2|length - 1] %} - {% set _section_3 = _section_3|merge([_last_in_section_2]) %} - - {% endif %} - - {# Follow section must always be the last on the left. #} - {% set _section_2 = _section_2|merge([{ - 'title': 'Follow us on social media'|t, - 'links': bcl_footer_links(site_specific_footer.social_links), - }]) %} -{% endif %} +{% extends "oe-corporate-blocks-neutral-footer.html.twig" %} +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} -{% set _top_sections = [ - { - 'section_id': 'footer_top_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('')|render - } - }, - 'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}), - }, - { - 'section_id': 'footer_top_middle', - 'sections': _section_2 - }, - { - 'section_id': 'footer_top_right', - 'sections': _section_3 - } -] %} + {% set site_identity_content %} +

{{ 'European Commission'|t }}

+ {% endset %} -{% set _bottom_sections = [ - { - 'section_id': 'ec_footer_bottom_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('')|render, + {% set _bottom_sections = { + 'extra_classes': 'pb-4 pb-lg-5 bcl-footer__bordered-row row mt-4', + 'cols': [ + { + 'classes': 'col-12 col-lg-4 pb-lg-4', + 'items': [ + { + 'type': 'content', + 'content': site_identity_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.service_navigation), + } + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.legal_navigation), + } + ], } - } - }, - { - 'section_id': 'ec_footer_bottom_middle', - 'links': bcl_footer_links(corporate_footer.service_navigation), - }, - { - 'section_id': 'ec_footer_bottom_right', - 'links': bcl_footer_links(corporate_footer.legal_navigation) - } -] %} + ], + } %} -{% set _middle_sections = [ - { - 'section_id': 'ec_footer_middle_row', - 'links': bcl_footer_links(corporate_footer.class_navigation), - } -] %} -
-
- {{ pattern('footer', { - 'variant': 'ec', - 'top_sections': _top_sections, - 'middle_sections': _middle_sections, - 'bottom_sections': _bottom_sections, - }) }} -
-
+ {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + 'variant': 'ec', + 'rows': [_top_sections, _bottom_sections], + 'attributes': attributes, + } only %} +{% endblock %} diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 6c7ce8547..96568ace8 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -1,110 +1,88 @@ -{# -/** - * @file - * Default theme implementation for rendering corporate blocks footer. - * - * Available variables: - * - corporate_footer: Array with structure compatible to ECL ec-components-footer component. - * - contact: EU contact data for corporate footer. - * - social_media_title: Title for social media links column. - * - social_media: Social media links for corporate footer. - * - institution_links_title: Title for institution links column. - * - institution_links: EU institutions links for corporate footer. - * - legal_links_title: Title for legal links column. - * - legal_links: Legal links for corporate footer. - * - * @ingroup themeable - */ -#} - -{% set _section_2 = [] %} -{% set _section_3 = [] %} - -{# First we parse the other_links, we make a simple grid. #} -{% for section in site_specific_footer.other_links %} - {% if loop.index is odd %} - {% set _section_2 = _section_2|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% else %} - {% set _section_3 = _section_3|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% endif %} -{% endfor %} - -{# When follow section is present. #} -{% if site_specific_footer.social_links is not empty %} - {# If section numbers are odd, then we flip the last row so to have the follow as first. #} - {% if _section_2|length > _section_3|length %} - {% set _last_in_section_2 = _section_2|last %} - - {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} - {% if _last_in_section_2 is empty %} - {% set _last_in_section_2 = _section_2[0] %} - {% set _section_2 = [] %} - {% endif %} - - {% set _section_2 = _section_2[:_section_2|length - 1] %} - {% set _section_3 = _section_3|merge([_last_in_section_2]) %} - - {% endif %} - - {# Follow section must always be the last on the left. #} - {% set _section_2 = _section_2|merge([{ - 'title': 'Follow us on social media'|t, - 'links': bcl_footer_links(site_specific_footer.social_links), - }]) %} -{% endif %} +{% extends "oe-corporate-blocks-neutral-footer.html.twig" %} +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} -{% set _top_sections = [ - { - 'section_id': 'footer_top_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('')|render + {% set _bottom_sections = { + 'extra_classes': 'pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row', + 'cols': [ + { + 'classes': 'col-12 col-lg-4 pb-4', + 'items': [ + { + 'type': 'content', + 'content': bcl_block('whitelabel_eu_logo_block'), + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': bcl_title(corporate_footer.contact_title, 'fw-bold border-bottom pb-2 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.contact), + }, + { + 'type': 'content', + 'content': bcl_title(corporate_footer.social_media_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.social_media), + }, + { + 'type': 'content', + 'content': bcl_title(corporate_footer.legal_links_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.legal_links), + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': bcl_title(corporate_footer.institution_links_title, 'fw-bold border-bottom pb-2 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.institution_links), + }, + ], } - }, - 'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}), - }, - { - 'section_id': 'footer_top_middle', - 'sections': _section_2 - }, - { - 'section_id': 'footer_top_right', - 'sections': _section_3 - } -] %} + ], + } %} -{% set _bottom_sections = [ - { - 'section_id': 'eu_footer_left' - }, - { - 'section_id': 'eu_footer_middle', - 'contact_eu_title': corporate_footer.contact_title, - 'contact_eu_links': bcl_footer_links(corporate_footer.contact), - 'social_media_title': corporate_footer.social_media_title, - 'social_media_links': bcl_footer_links(corporate_footer.social_media), - 'legal_title': corporate_footer.legal_links_title, - 'legal_links': bcl_footer_links(corporate_footer.legal_links) - }, - { - 'section_id': 'eu_footer_right', - 'eu_institutions_title': corporate_footer.institution_links_title, - 'eu_institutions_links': bcl_footer_links(corporate_footer.institution_links) - } -] %} -
-
- {{ pattern('footer', { - 'variant': 'eu', - 'top_sections': _top_sections, - 'bottom_sections': _bottom_sections, - }) }} -
-
+ {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + 'variant': 'eu', + 'rows': [_top_sections, _bottom_sections], + 'attributes': attributes, + } only %} +{% endblock %} diff --git a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig new file mode 100644 index 000000000..8769827ad --- /dev/null +++ b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig @@ -0,0 +1,104 @@ +{# +/** + * @file + * Neutral footer. + */ +#} + +{% set _section_2 = [] %} +{% set _section_3 = [] %} +{# First we parse the other_links, we make a simple grid. #} +{% for section in site_specific_footer.other_links %} + {% if loop.index is even %} + {% set _section_2 = _section_2|merge([ + { + 'type': 'content', + 'content': bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(section.links), + } + ]) %} + {% else %} + {% set _section_3 = _section_3|merge([ + { + 'type': 'content', + 'content': bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(section.links), + } + ]) %} + {% endif %} +{% endfor %} + +{# When follow section is present. #} +{% if site_specific_footer.social_links is not empty %} + {# If section numbers are odd, then we flip the last row so to have the follow as first. #} + {% if _section_2|length > _section_3|length %} + {% set _last_in_section_2 = _section_2|last %} + + {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} + {% if _last_in_section_2 is empty %} + {% set _last_in_section_2 = _section_2[0] %} + {% set _section_2 = [] %} + {% endif %} + + {% set _section_2 = _section_2[:_section_2|length - 1] %} + {% set _section_3 = _section_3|merge([_last_in_section_2]) %} + + {% endif %} + + {# Follow section must always be the last on the left. #} + {% set _section_2 = _section_2|merge([ + { + 'type': 'content', + 'content': bcl_title('Follow us on social media', 'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(site_specific_footer.social_links), + }]) %} +{% endif %} + +{% set footer_top_left_content %} +
+

{{ site_specific_footer.site_identity }}

+

{{ site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}) }}

+
+{% endset %} + +{% set attributes = create_attribute().addClass(['pb-4', 'mt-4']) %} + +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} + + {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + 'variant': 'neutral', + 'rows': [_top_sections], + 'attributes': attributes, + } only %} +{% endblock %} From eec3e0be1a23aa04d05bd444863f65f3f9b8d5f5 Mon Sep 17 00:00:00 2001 From: escuriola Date: Fri, 11 Feb 2022 13:36:29 +0100 Subject: [PATCH 06/20] OEL-1147: Now EC footer only has 2 rows. Fix test. --- tests/src/Kernel/FooterBlockTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index ff29c276f..c201d6d96 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -64,11 +64,11 @@ public function testEcFooterBlockRendering(): void { // For now we assert only minimal till we have a footer component. $rows = $crawler->filter('.row'); - $this->assertCount(3, $rows); + $this->assertCount(2, $rows); $borderedSections = $crawler->filter('.bcl-footer__bordered-row'); - $this->assertCount(2, $borderedSections); + $this->assertCount(1, $borderedSections); $sectionTitles = $crawler->filter('p.fw-bold.mb-2'); - $this->assertCount(3, $sectionTitles); + $this->assertCount(2, $sectionTitles); $sectionLinks = $crawler->filter('div.col-12.col-lg-4:nth-child(2) a.text-underline-hover.d-block.mb-1'); $this->assertCount(3, $sectionLinks); } From 9ac5618a0c3e03e5ee1a9c6ed3b03552c65e1736 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Feb 2022 10:28:10 +0100 Subject: [PATCH 07/20] OEL-1147: Fix extends call to neutral patterns from EC and EU footer pattern. --- .../navigation/oe-corporate-blocks-ec-footer.html.twig | 2 +- .../navigation/oe-corporate-blocks-eu-footer.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig index 4a1cac8e8..b0dfe6923 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig @@ -1,4 +1,4 @@ -{% extends "oe-corporate-blocks-neutral-footer.html.twig" %} +{% extends "@oe_whitelabel/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig" %} {% block content %} {% set _top_sections = { 'extra_classes': 'pt-4 pt-lg-5', diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 96568ace8..4fc2a8450 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -1,4 +1,4 @@ -{% extends "oe-corporate-blocks-neutral-footer.html.twig" %} +{% extends "@oe_whitelabel/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig" %} {% block content %} {% set _top_sections = { 'extra_classes': 'pt-4 pt-lg-5', From 7bb597fc28e14b6ae0806e472f6989168fd69506 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Feb 2022 15:50:00 +0100 Subject: [PATCH 08/20] OEL-1147: Missing template on theme hook. Fixing and add test to neutral footer. --- .../oe_whitelabel_helper.module | 10 +++++ .../src/Plugin/Block/NeutralFooterBlock.php | 2 +- tests/src/Kernel/FooterBlockTest.php | 38 +++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module index 576702473..b4efc1f19 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module @@ -26,5 +26,15 @@ function oe_whitelabel_helper_theme($existing, $type, $theme, $path) { 'address_delimiter' => NULL, ], ], + 'oe_corporate_blocks_neutral_footer' => [ + 'variables' => [ + 'corporate_footer' => [], + 'site_specific_footer' => [], + ], + 'preprocess functions' => [ + 'oe_corporate_blocks_preprocess_set_site_owner', + ], + ], ]; } + diff --git a/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php index f1a7c1a67..03ef209c3 100644 --- a/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php +++ b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php @@ -10,7 +10,7 @@ use Drupal\oe_corporate_blocks\Plugin\Block\FooterBlockBase; /** - * Provides the corporate EU footer block. + * Provides the Neutral footer block. * * @Block( * id = "oe_corporate_blocks_neutral_footer", diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index c201d6d96..74d63e5c1 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -17,16 +17,12 @@ class FooterBlockTest extends SparqlKernelTestBase { */ protected static $modules = [ 'block', - 'multivalue_form_element', 'oe_bootstrap_theme_helper', 'oe_corporate_blocks', 'oe_corporate_site_info', 'oe_whitelabel_helper', 'rdf_skos', 'system', - 'ui_patterns', - 'ui_patterns_library', - 'ui_patterns_settings', 'user', ]; @@ -63,6 +59,7 @@ public function testEcFooterBlockRendering(): void { $crawler = new Crawler($render->__toString()); // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--ec')); $rows = $crawler->filter('.row'); $this->assertCount(2, $rows); $borderedSections = $crawler->filter('.bcl-footer__bordered-row'); @@ -98,6 +95,7 @@ public function testEuFooterBlockRendering(): void { $crawler = new Crawler($render->__toString()); // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--eu')); $rows = $crawler->filter('.row'); $this->assertCount(2, $rows); $borderedSections = $crawler->filter('.bcl-footer__bordered-row'); @@ -108,4 +106,36 @@ public function testEuFooterBlockRendering(): void { $this->assertCount(10, $sectionLinks); } + /** + * Tests the rendering of blocks. + */ + public function testNeutralFooterBlockRendering(): void { + $entity_type_manager = $this->container + ->get('entity_type.manager') + ->getStorage('block'); + $entity = $entity_type_manager->create([ + 'id' => 'neutralfooterblock', + 'theme' => 'oe_whitelabel', + 'plugin' => 'oe_corporate_blocks_neutral_footer', + 'settings' => [ + 'id' => 'oe_corporate_blocks_neutral_footer', + 'label' => 'Neutral Footer block', + 'provider' => 'oe_corporate_blocks', + 'label_display' => '0', + ], + ]); + $entity->save(); + $builder = \Drupal::entityTypeManager()->getViewBuilder('block'); + $build = $builder->view($entity, 'block'); + $render = $this->container->get('renderer')->renderRoot($build); + $crawler = new Crawler($render->__toString()); + + // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--neutral')); + $rows = $crawler->filter('.row'); + $this->assertCount(1, $rows); + $sectionTitles = $crawler->filter('p.fw-bold.mb-2'); + $this->assertCount(1, $sectionTitles); + } + } From 0f165d893902fbf4a5e908af538271bdf23658cf Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 17 Feb 2022 16:15:03 +0100 Subject: [PATCH 09/20] OEL-1147: Replace bcl_block and bcl_title twig functions. --- .../navigation/oe-corporate-blocks-eu-footer.html.twig | 10 +++++----- .../oe-corporate-blocks-neutral-footer.html.twig | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 4fc2a8450..306936548 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -31,7 +31,7 @@ 'items': [ { 'type': 'content', - 'content': bcl_block('whitelabel_eu_logo_block'), + 'content': drupal_block('whitelabel_eu_logo_block'), }, ], }, @@ -40,7 +40,7 @@ 'items': [ { 'type': 'content', - 'content': bcl_title(corporate_footer.contact_title, 'fw-bold border-bottom pb-2 mb-2'), + 'content': _self.bcl_title(corporate_footer.contact_title, 'fw-bold border-bottom pb-2 mb-2'), }, { 'type': 'links', @@ -48,7 +48,7 @@ }, { 'type': 'content', - 'content': bcl_title(corporate_footer.social_media_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + 'content': _self.bcl_title(corporate_footer.social_media_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), }, { 'type': 'links', @@ -56,7 +56,7 @@ }, { 'type': 'content', - 'content': bcl_title(corporate_footer.legal_links_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + 'content': _self.bcl_title(corporate_footer.legal_links_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), }, { 'type': 'links', @@ -69,7 +69,7 @@ 'items': [ { 'type': 'content', - 'content': bcl_title(corporate_footer.institution_links_title, 'fw-bold border-bottom pb-2 mb-2'), + 'content': _self.bcl_title(corporate_footer.institution_links_title, 'fw-bold border-bottom pb-2 mb-2'), }, { 'type': 'links', diff --git a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig index 8769827ad..324a7cfa1 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig @@ -5,6 +5,10 @@ */ #} +{% macro bcl_title(title, classes) %} +

{{ title }}

+{% endmacro %} + {% set _section_2 = [] %} {% set _section_3 = [] %} {# First we parse the other_links, we make a simple grid. #} @@ -13,7 +17,7 @@ {% set _section_2 = _section_2|merge([ { 'type': 'content', - 'content': bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + 'content': _self.bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), }, { 'type': 'links', @@ -24,7 +28,7 @@ {% set _section_3 = _section_3|merge([ { 'type': 'content', - 'content': bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + 'content': _self.bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), }, { 'type': 'links', @@ -55,7 +59,7 @@ {% set _section_2 = _section_2|merge([ { 'type': 'content', - 'content': bcl_title('Follow us on social media', 'fw-bold border-bottom pb-2 mb-2 mt-3'), + 'content': _self.bcl_title('Follow us on social media', 'fw-bold border-bottom pb-2 mb-2 mt-3'), }, { 'type': 'links', From bbf8491d0a95c2ae35808875bcfae3735daa32f5 Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 17 Feb 2022 16:15:25 +0100 Subject: [PATCH 10/20] OEL-1147: Add twig_tweak and oe_corporate_blocks dependency. --- modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml index 0127dc76d..be3a2ef3d 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml @@ -6,5 +6,7 @@ core_version_requirement: ^9.2 dependencies: - oe_bootstrap_theme:oe_bootstrap_theme_helper + - openeuropa:oe_corporate_blocks + - drupal:twig_tweak 'interface translation project': oe_whitelabel_helper From 00f94485ebc3101923eeebcad47c4db6626a2e54 Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 17 Feb 2022 16:15:37 +0100 Subject: [PATCH 11/20] OEL-1147: Defaults to neutral. --- oe_whitelabel.theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index fca093230..bb3573db8 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -111,7 +111,7 @@ function oe_whitelabel_form_system_theme_settings_alter(&$form, FormStateInterfa 'ec' => t('European Commission'), 'eu' => t('European Union'), ], - '#default_value' => theme_get_setting('component_library') ?? 'eu', + '#default_value' => theme_get_setting('component_library') ?? 'neutral', '#description' => t('Choose "European Commission" for websites hosted under the ec.europa.eu domain and "European Union" for websites hosted under the europa.eu domain.'), ]; $form['header_style'] = [ From 8e9719f0068899c07e62c5bb0044d5e198dcf43a Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 17 Feb 2022 19:28:46 +0100 Subject: [PATCH 12/20] OEL-1147: Fix test. --- tests/src/Kernel/FooterBlockTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index 74d63e5c1..c1eaac1c3 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -24,6 +24,7 @@ class FooterBlockTest extends SparqlKernelTestBase { 'rdf_skos', 'system', 'user', + 'twig_tweak', ]; /** From e655b4a587459fa304a3a46c7b78cda8483f0b51 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 21 Feb 2022 15:25:28 +0100 Subject: [PATCH 13/20] OEL-1147: Mark bclBlock twig function as deprecated. --- .../oe_whitelabel_helper/src/TwigExtension/TwigExtension.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php index a2f7e5759..944b17e5f 100644 --- a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php +++ b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php @@ -172,6 +172,8 @@ public function bclFooterLinks(array $context, array $links): array { * * @return array * The block render array. + * + * @deprecated Use Twig Tweak instead. */ public function bclBlock(string $id, array $configuration = []): array { $configuration += ['label_display' => 'hidden']; From b7fd9570c6622ead2d415a945c5b88f55e484ff7 Mon Sep 17 00:00:00 2001 From: escuriola Date: Tue, 22 Feb 2022 12:08:06 +0100 Subject: [PATCH 14/20] OEL-1147: Remove EU logo block for footer. --- .../oe-corporate-blocks-eu-footer.html.twig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 306936548..13326a2b7 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -23,6 +23,15 @@ ], } %} + {% set eu_logo %} + + + {{ site_logo_alt }} + + {% endset %} + {% set _bottom_sections = { 'extra_classes': 'pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row', 'cols': [ @@ -31,7 +40,7 @@ 'items': [ { 'type': 'content', - 'content': drupal_block('whitelabel_eu_logo_block'), + 'content': eu_logo, }, ], }, From 672a046b1f076f8a3eb028545e330135d960eef5 Mon Sep 17 00:00:00 2001 From: escuriola Date: Tue, 22 Feb 2022 12:54:44 +0100 Subject: [PATCH 15/20] OEL-1147: Branding footer condition. --- ...lock.oe_whitelabel_ec_corporate_footer.yml | 7 +- ...lock.oe_whitelabel_eu_corporate_footer.yml | 24 +++ ...ock.block.oe_whitelabel_neutral_footer.yml | 24 +++ .../schema/oe_whitelabel_helper.schema.yml | 5 + .../CurrentComponentLibraryCondition.php | 151 ++++++++++++++++++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml create mode 100644 config/optional/block.block.oe_whitelabel_neutral_footer.yml create mode 100644 modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php diff --git a/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml b/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml index 34d701e6a..d52ef5793 100644 --- a/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml +++ b/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml @@ -16,4 +16,9 @@ settings: label: 'EC Footer block' provider: oe_corporate_blocks label_display: '0' -visibility: { } +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: ec + negate: false + context_mapping: { } diff --git a/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml b/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml new file mode 100644 index 000000000..1eaa3c403 --- /dev/null +++ b/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + module: + - oe_corporate_blocks + theme: + - oe_whitelabel +id: oe_whitelabel_eu_corporate_footer +theme: oe_whitelabel +region: footer +weight: 0 +provider: null +plugin: oe_corporate_blocks_eu_footer +settings: + id: oe_corporate_blocks_eu_footer + label: 'EU Footer block' + provider: oe_corporate_blocks + label_display: '0' +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: eu + negate: false + context_mapping: { } diff --git a/config/optional/block.block.oe_whitelabel_neutral_footer.yml b/config/optional/block.block.oe_whitelabel_neutral_footer.yml new file mode 100644 index 000000000..372470a5a --- /dev/null +++ b/config/optional/block.block.oe_whitelabel_neutral_footer.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + module: + - oe_whitelabel_helper + theme: + - oe_whitelabel +id: oe_whitelabel_neutral_footer +theme: oe_whitelabel +region: footer +weight: 0 +provider: null +plugin: oe_corporate_blocks_neutral_footer +settings: + id: oe_corporate_blocks_neutral_footer + label: 'Neutral Footer block' + provider: oe_whitelabel_helper + label_display: '0' +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: neutral + negate: false + context_mapping: { } diff --git a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml index a965f7179..df4af465a 100644 --- a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml +++ b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml @@ -5,3 +5,8 @@ field.formatter.settings.oe_whitelabel_helper_address_inline: delimiter: type: string label: 'Delimiter for address items.' +condition.plugin.oe_whitelabel_helper_current_component_library: + type: condition.plugin + mapping: + component_library: + type: string diff --git a/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php b/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php new file mode 100644 index 000000000..b15d6cc19 --- /dev/null +++ b/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php @@ -0,0 +1,151 @@ +configFactory = $config_factory; + $this->themeManager = $theme_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory'), + $container->get('theme.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'component_library' => '', + ] + parent::defaultConfiguration(); + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + // We allow for an empty value to be set. By doing that we make sure that + // no settings about this condition is actually saved in block visibility + // settings, unless the user explicitly sets one. + $form['component_library'] = [ + '#type' => 'select', + '#title' => $this->t('Component library'), + '#options' => [ + '' => $this->t('- Any -'), + 'neutral' => $this->t('Neutral'), + 'ec' => $this->t('European Commission'), + 'eu' => $this->t('European Union'), + ], + '#default_value' => $this->configuration['component_library'], + '#description' => t('Choose with which component library this condition should be met.'), + ]; + return parent::buildConfigurationForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['component_library'] = $form_state->getValue('component_library'); + parent::submitConfigurationForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function evaluate() { + if (empty($this->configuration['component_library'])) { + return TRUE; + } + $theme_name = $this->themeManager->getActiveTheme()->getName(); + + $component_library = $this->configFactory->get($theme_name . '.settings')->get('component_library'); + return $component_library === $this->configuration['component_library']; + } + + /** + * {@inheritdoc} + */ + public function summary() { + if (empty($this->configuration['component_library'])) { + return $this->t('The current component library can be set to anything'); + } + + if ($this->isNegated()) { + return $this->t('The current component library is not @component_library', ['@component_library' => $this->configuration['component_library']]); + } + + return $this->t('The current component library is @component_library', ['@component_library' => $this->configuration['component_library']]); + } + + /** + * {@inheritdoc} + */ + public function getCacheTags() { + $theme_name = $this->themeManager->getActiveTheme()->getName(); + + return Cache::mergeTags(['config:' . $theme_name . '.settings'], parent::getCacheTags()); + } + +} From 8078bfa5bfff78966ea0332993188d59fa06d973 Mon Sep 17 00:00:00 2001 From: escuriola Date: Wed, 23 Feb 2022 16:32:55 +0100 Subject: [PATCH 16/20] OEL-1147: Remove twig_tweak. --- modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml | 1 - tests/src/Kernel/FooterBlockTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml index be3a2ef3d..91e080984 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml @@ -7,6 +7,5 @@ core_version_requirement: ^9.2 dependencies: - oe_bootstrap_theme:oe_bootstrap_theme_helper - openeuropa:oe_corporate_blocks - - drupal:twig_tweak 'interface translation project': oe_whitelabel_helper diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index c1eaac1c3..74d63e5c1 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -24,7 +24,6 @@ class FooterBlockTest extends SparqlKernelTestBase { 'rdf_skos', 'system', 'user', - 'twig_tweak', ]; /** From ec5d778d254a60b7c883f577d34a4153624f35da Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Mar 2022 09:58:23 +0100 Subject: [PATCH 17/20] OEL-1147: Modify footer component include. --- .../navigation/oe-corporate-blocks-ec-footer.html.twig | 2 +- .../navigation/oe-corporate-blocks-eu-footer.html.twig | 2 +- .../navigation/oe-corporate-blocks-neutral-footer.html.twig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig index b0dfe6923..56b7d3721 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig @@ -60,7 +60,7 @@ ], } %} - {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + {% include '@oe-bcl/footer' with { 'variant': 'ec', 'rows': [_top_sections, _bottom_sections], 'attributes': attributes, diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 13326a2b7..cc8a6d075 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -89,7 +89,7 @@ ], } %} - {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + {% include '@oe-bcl/footer' with { 'variant': 'eu', 'rows': [_top_sections, _bottom_sections], 'attributes': attributes, diff --git a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig index 324a7cfa1..9ea73bc98 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig @@ -100,7 +100,7 @@ ], } %} - {% include '@oe-bcl/bcl-footer/bcl-footer.html.twig' with { + {% include '@oe-bcl/footer' with { 'variant': 'neutral', 'rows': [_top_sections], 'attributes': attributes, From 1b06f475dcd16cb71c3e65a09ef1fb02a7233eec Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Mar 2022 10:28:59 +0100 Subject: [PATCH 18/20] OEL-1147: PHPCS Fix extra newline. --- modules/oe_whitelabel_helper/oe_whitelabel_helper.module | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module index b4efc1f19..d257da954 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module @@ -37,4 +37,3 @@ function oe_whitelabel_helper_theme($existing, $type, $theme, $path) { ], ]; } - From d867e7169ff5ff96bfc935cc7592361d1814dcb9 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Mar 2022 14:39:58 +0100 Subject: [PATCH 19/20] OEL-1147: Back to previous oe_starter_content version. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 764fb0f83..08461b327 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "openeuropa/oe_contact_forms": "~1.1", "openeuropa/oe_corporate_blocks": "^4.4", "openeuropa/oe_multilingual": "^1.9", - "openeuropa/oe_starter_content": "1.x-dev", + "openeuropa/oe_starter_content": "1.x-dev#5a4a77b", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", "phpspec/prophecy-phpunit": "^1 || ^2" }, From 9d3aae1c21cda61db89940b8a29ccd582302a571 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 14 Mar 2022 15:29:07 +0100 Subject: [PATCH 20/20] OEL-1147: Remove extra div. --- .../navigation/oe-corporate-blocks-neutral-footer.html.twig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig index 9ea73bc98..a42d85ab8 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig @@ -68,10 +68,8 @@ {% endif %} {% set footer_top_left_content %} -
-

{{ site_specific_footer.site_identity }}

-

{{ site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}) }}

-
+

{{ site_specific_footer.site_identity }}

+

{{ site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}) }}

{% endset %} {% set attributes = create_attribute().addClass(['pb-4', 'mt-4']) %}