Skip to content

Commit

Permalink
EWPP-1149: Fix support for social media icons and arrows in facts and…
Browse files Browse the repository at this point in the history
… figures paragraphs.
  • Loading branch information
imanoleguskiza committed Jul 22, 2021
1 parent 419049f commit 8017ba4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
24 changes: 16 additions & 8 deletions modules/oe_theme_helper/src/TwigExtension/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,32 +277,40 @@ public function toEclAttributes($attributes): array {
*/
public function toEclIcon(array $context, $icon, string $size = ''): array {
$path = $context['ecl_icon_path'];
$social_path = $context['ecl_icon_social_media_path'];

// ECL supported icons naming and rotation.
$icons = [
'facebook' => [
'name' => 'facebook',
'social' => TRUE,
],
'instagram' => [
'name' => 'instagram',
'social' => TRUE,
],
'linkedin' => [
'name' => 'linkedin',
'social' => TRUE,
],
'pinterest' => [
'name' => 'pinterest',
'social' => TRUE,
],
'rss' => [
'name' => 'rss',
],
'skype' => [
'name' => 'skype',
'social' => TRUE,
],
'twitter' => [
'name' => 'twitter',
'social' => TRUE,
],
'youtube' => [
'name' => 'youtube',
'social' => TRUE,
],
'audio' => [
'name' => 'audio',
Expand Down Expand Up @@ -469,9 +477,6 @@ public function toEclIcon(array $context, $icon, string $size = ''): array {
'plus' => [
'name' => 'plus',
],
'rounded-arrow' => [
'name' => 'rounded-arrow',
],
'solid-arrow' => [
'name' => 'solid-arrow',
],
Expand All @@ -485,7 +490,7 @@ public function toEclIcon(array $context, $icon, string $size = ''): array {
'name' => 'close',
],
'up' => [
'name' => 'rounded-arrow',
'name' => 'corner-arrow',
],
'arrow-down' => [
'name' => 'solid-arrow',
Expand All @@ -495,25 +500,28 @@ public function toEclIcon(array $context, $icon, string $size = ''): array {
'name' => 'solid-arrow',
],
'breadcrumb' => [
'name' => 'rounded-arrow',
'name' => 'corner-arrow',
'transform' => 'rotate-90',
],
'down' => [
'name' => 'rounded-arrow',
'name' => 'corner-arrow',
'transform' => 'rotate-180',
],
'left' => [
'name' => 'rounded-arrow',
'name' => 'corner-arrow',
'transform' => 'rotate-270',
],
'right' => [
'name' => 'rounded-arrow',
'name' => 'corner-arrow',
'transform' => 'rotate-90',
],
];

if (array_key_exists($icon, $icons)) {
$icons[$icon]['path'] = $path;
if (isset($icons[$icon]['social']) && $icons[$icon]['social']) {
$icons[$icon]['path'] = $social_path;
}
if ($size) {
$icons[$icon]['size'] = $size;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ facts_figures:
label: "Facts"
description: "List of facts"
preview:
- icon: "infographic"
- icon: "instagram"
value: "00.0 million"
title: "Lorem ipsum"
description: "Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero."
- icon: "spreadsheet"
- icon: "twitter"
value: "00.0 million"
title: "Sed hendrerit"
description: "Turpis varius congue venenatis, erat dui feugiat felis."
- icon: "calendar"
value: "00.0 million"
title: "Donec suscipit interdum augue, ac dapibus eros finibus a."
description: "Cras vestibulum efficitur mi, quis porta tellus rutrum ut. Quisque at pulvinar sem."
- icon: "digital"
- icon: "euro"
value: "00.0 million"
title: "Aenean dapibus"
description: "Aliquam lacinia diam eu sem malesuada, in interdum ante bibendum."
Expand Down
4 changes: 2 additions & 2 deletions tests/Kernel/fixtures/rendering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@
'#id': 'facts_figures'
'#fields':
items:
- icon: 'infographic'
- icon: 'instagram'
value: '00.0 million'
title: 'Lorem ipsum'
description: 'Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.'
Expand All @@ -2652,7 +2652,7 @@
'div.ecl-fact-figures__item:nth-child(2) svg.ecl-icon.ecl-icon--m.ecl-fact-figures__icon': 1
'div.ecl-fact-figures__view-all': 1
equals:
'div.ecl-fact-figures__item:nth-child(1) svg.ecl-icon.ecl-icon--m.ecl-fact-figures__icon': '<use xlink:href="/themes/custom/oe_theme/dist/ec/images/icons/sprites/icons.svg#infographic"></use>'
'div.ecl-fact-figures__item:nth-child(1) svg.ecl-icon.ecl-icon--m.ecl-fact-figures__icon': '<use xlink:href="/themes/custom/oe_theme/dist/ec/icons-social-media/sprites/icons-social-media.svg#infographic"></use>'
'div.ecl-fact-figures__item:nth-child(1) div.ecl-fact-figures__value': '00.0 million'
'div.ecl-fact-figures__item:nth-child(1) div.ecl-fact-figures__title': 'Lorem ipsum'
'div.ecl-fact-figures__item:nth-child(1) div.ecl-fact-figures__description': 'Nunc condimentum sapien ut nibh finibus suscipit vitae at justo. Morbi quis odio faucibus, commodo tortor id, elementum libero.'
Expand Down

0 comments on commit 8017ba4

Please sign in to comment.