Skip to content

Commit

Permalink
EWPP-3816: Add support of extra_attributes for navigation_list pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed Feb 8, 2024
1 parent 34d895d commit 6304bb3
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 10 deletions.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"openeuropa/behat-transformation-context": "^0.2",
"openeuropa/code-review": "^2.0.0-alpha6",
"openeuropa/oe_contact_forms": "^1.11",
"openeuropa/oe_content": "^3.0.0-beta4",
"openeuropa/oe_content": "^3.0.0",
"openeuropa/oe_corporate_blocks": "^4.14",
"openeuropa/oe_corporate_countries": "^2.0.0-alpha8",
"openeuropa/oe_corporate_site_info": "^1.0.0-alpha8",
Expand Down Expand Up @@ -103,6 +103,13 @@
"https://www.drupal.org/project/address/issues/3144823": "https://www.drupal.org/files/issues/2020-11-05/3144823-6.patch"
}
},
"patches-ignore": {
"openeuropa/oe_content": {
"drupal/core": {
"Drupal 10.2.x only - see oe_content/README.md for 10.1.x - https://www.drupal.org/project/drupal/issues/2230909": "https://www.drupal.org/files/issues/2023-12-21/2230909-309.patch"
}
}
},
"drupal-scaffold": {
"locations": {
"web-root": "./build"
Expand Down
20 changes: 20 additions & 0 deletions patches/@ecl/twig-component-content-block+3.13.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/node_modules/@ecl/twig-component-content-block/content-block.html.twig b/node_modules/@ecl/twig-component-content-block/content-block.html.twig
index 141368d..8fffb43 100644
--- a/node_modules/@ecl/twig-component-content-block/content-block.html.twig
+++ b/node_modules/@ecl/twig-component-content-block/content-block.html.twig
@@ -147,6 +147,7 @@
link: _link.link|merge({
type: 'standalone',
}),
+ extra_attributes: _link.extra_attributes|default([]),
icon: _link.icon|default({})
} only %}
{%- else -%}
@@ -165,6 +166,7 @@
link: _link.link|merge({
type: 'standalone',
}),
+ extra_attributes: _link.extra_attributes|default([]),
icon: _link.icon|default({})
} only %}
{%- else -%}
2 changes: 1 addition & 1 deletion patches/@ecl/twig-component-menu+3.13.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ index 6891f9e..0944464 100644
<a
href="{{ child.path }}"
class="{{ _sublink_class }}"
+ {{ _sub_menu_item_attributes }}
+ {{ _sub_menu_item_attributes|raw }}
>
{{- child.label -}}
{%- if child.external -%}
Expand Down
14 changes: 14 additions & 0 deletions templates/patterns/navigation_list/navigation_list.ui_patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ navigation_list:
label: "External link"
description: "Whether the title URL is external or not."
preview: true
title_extra_attributes:
type: "array"
label: "Link attributes"
description: "Extra attributes for title link"
preview:
- name: "extra-attr"
value: "extra value"
description:
type: "text"
label: "Description"
Expand All @@ -30,6 +37,9 @@ navigation_list:
- label: 'Addressing shared challenges'
url: 'https://commission.europa.eu/education/policy-educational-issues/shared-challenges-education-and-training_en'
is_external: true
extra_attributes:
- name: "extra-attr2"
value: "extra value2"
- label: 'Setting objectives and measuring progress'
url: 'https://commission.europa.eu/education/policy-educational-issues/setting-objectives-and-measuring-progress_en'
- label: 'International cooperation'
Expand All @@ -42,6 +52,9 @@ navigation_list:
preview:
- label: 'Integrating migrants and refugees'
url: 'https://commission.europa.eu/education/policy-educational-issues/shared-challenges-education-and-training/integrating-migrants-and-refugees_en'
extra_attributes:
- name: "extra-attr2"
value: "extra value2"
- label: 'Early school leaving'
url: 'https://commission.europa.eu/education/policy-educational-issues/shared-challenges-education-and-training/early-school-leaving_en'
is_external: true
Expand All @@ -57,3 +70,4 @@ navigation_list:
preview:
src: "https://loremflickr.com/1000/500/arch"
alt: "Alternative text for image"

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

{% if title_url %}
{% set title = {
label: title,
path: title_url,
icon_path: ecl_icon_path,
external: external_link|default(false)
link: {
type: 'standalone',
label : title,
path : title_url,
icon_path: ecl_icon_path,
external: external_link|default(false)
},
extra_attributes: title_extra_attributes|default([])
} %}
{% endif %}

Expand All @@ -24,7 +28,8 @@
path : link.url,
icon_path: ecl_icon_path,
external: link.is_external|default(false)
}
},
extra_attributes: link.extra_attributes|default([])
} %}
{% set _primary_links = _primary_links|merge([_link]) %}
{% endfor %}
Expand All @@ -40,7 +45,8 @@
path : secondary_link.url,
icon_path: ecl_icon_path,
external: secondary_link.is_external|default(false)
}
},
extra_attributes: secondary_link.extra_attributes|default([])
} %}
{% set _secondary_links = _secondary_links|merge([_secondary_link]) %}
{% endfor %}
Expand Down
16 changes: 14 additions & 2 deletions tests/src/Kernel/fixtures/rendering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1786,12 +1786,18 @@
'#fields':
title: 'Navigation list title'
title_url: 'http://example.com'
title_extra_attributes:
- name: "extra-attr"
value: "extra value"
external_link: true
description: 'Navigation list description'
links:
- label: 'Child 1'
url: 'http://example.com/child1'
is_external: true
extra_attributes:
- name: "extra-attr1"
value: "extra value1"
- label: 'Child 2'
url: 'http://example.com/child2'
- label: 'Child 3'
Expand All @@ -1800,6 +1806,9 @@
- label: 'Secondary Link 1'
url: 'http://example.com/secondary1'
is_external: true
extra_attributes:
- name: "extra-attr2"
value: "extra value2"
- label: 'Secondary Link 2'
url: 'http://example.com/secondary2'
border: true
Expand All @@ -1826,6 +1835,9 @@
'li.ecl-content-block__link-item': 5
"img.ecl-navigation-list__image[src=\"https://placeimg.com/1000/500/arch\"]": 1
'img.ecl-navigation-list__image[alt="Alternative text for image"]': 1
'.ecl-content-block__link-list:nth-child(1) li.ecl-content-block__link-item:nth-child(1) a.ecl-link[extra-attr1="extra value1"]': 1
'.ecl-content-block__link-list:nth-child(2) li.ecl-content-block__link-item:nth-child(1) a.ecl-link[extra-attr2="extra value2"]': 1
'h1.ecl-content-block__title a.ecl-link[extra-attr="extra value"]': 1
- array:
'#type': pattern
'#id': navigation_list
Expand Down Expand Up @@ -3124,10 +3136,10 @@
'.ecl-menu__inner-header button.ecl-menu__close .ecl-button__label': "Close"
'.ecl-menu__inner-header button.ecl-menu__back .ecl-button__label': "Back"
'li.ecl-menu__item:nth-child(1) a.ecl-menu__link': "Parent 1"
'li.ecl-menu__item:nth-child(1) a.ecl-menu__link[data-name1="data-value1"]': "Parent 1"
'li.ecl-menu__item:nth-child(1) a.ecl-menu__link[data-name1="data value1"]': "Parent 1"
'li.ecl-menu__item:nth-child(2) a.ecl-menu__link': "Parent 2"
'li.ecl-menu__item:nth-child(1) ul.ecl-menu__sublist li.ecl-menu__subitem--current a.ecl-menu__sublink.ecl-link--icon-after': 'Child 1.1'
'li.ecl-menu__item:nth-child(1) ul.ecl-menu__sublist li.ecl-menu__subitem--current a.ecl-menu__sublink.ecl-link--icon-after[data-name2="data-value2"]': 'Child 1.1'
'li.ecl-menu__item:nth-child(1) ul.ecl-menu__sublist li.ecl-menu__subitem--current a.ecl-menu__sublink.ecl-link--icon-after[data-name2="data value2"]': 'Child 1.1'
'li.ecl-menu__item:nth-child(1) ul.ecl-menu__sublist li.ecl-menu__subitem:nth-child(3) a.ecl-menu__sublink.ecl-link--icon-after': 'Child 1.3'
'li.ecl-menu__item:nth-child(2) ul.ecl-menu__sublist li.ecl-menu__subitem:nth-child(3) a.ecl-menu__sublink.ecl-link--icon-after': 'Child 2.3'
equals:
Expand Down

0 comments on commit 6304bb3

Please sign in to comment.