From f1dda63b7539885d74c53070834963f630156e26 Mon Sep 17 00:00:00 2001 From: nimek2 Date: Mon, 25 Feb 2019 13:19:37 +0100 Subject: [PATCH] fix: Update EC Link structure (twig file and tests) (#34) --- .../__snapshots__/card.test.js.snap | 8 +-- .../__snapshots__/footer.test.js.snap | 56 ++++++++----------- .../__snapshots__/link.test.js.snap | 8 +-- .../packages/ec-component-link/link.html.twig | 16 ++++-- .../packages/ec-component-link/link.story.js | 2 + .../packages/ec-component-link/link.test.js | 10 ++-- 6 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/ec/packages/ec-component-card/__snapshots__/card.test.js.snap b/src/ec/packages/ec-component-card/__snapshots__/card.test.js.snap index d976428b0..f92cf13ee 100644 --- a/src/ec/packages/ec-component-card/__snapshots__/card.test.js.snap +++ b/src/ec/packages/ec-component-card/__snapshots__/card.test.js.snap @@ -11,7 +11,7 @@ exports[`EC - Card Card default - renders correctly 1`] = `
Meta 1 | Meta 2 | Meta 3

- Better regulation + Better regulation

@@ -77,7 +77,7 @@ exports[`EC - Card Card tile - renders correctly 1`] = ` href=\\"/example-1\\" class=\\"ecl-link ecl-link--standalone ecl-card__link\\" > - link 1 + link 1 diff --git a/src/ec/packages/ec-component-footer/__snapshots__/footer.test.js.snap b/src/ec/packages/ec-component-footer/__snapshots__/footer.test.js.snap index f36f3022b..ac829fad6 100644 --- a/src/ec/packages/ec-component-footer/__snapshots__/footer.test.js.snap +++ b/src/ec/packages/ec-component-footer/__snapshots__/footer.test.js.snap @@ -30,9 +30,7 @@ exports[`EC - Footer Corporate renders correctly 1`] = ` href=\\"/example\\" class=\\"ecl-link ecl-link--standalone ecl-footer__section-link\\" > - Commission and its priorities + Commission and its priorities @@ -155,51 +151,49 @@ exports[`EC - Footer Corporate renders correctly 1`] = ` href=\\"/example\\" class=\\"ecl-link ecl-link--standalone ecl-footer__common-link\\" > - About the Commission's new web presence + About the Commission's new web presence - Language policy + Language policy - Resources for partners + Resources for partners - Cookies + Cookies - Privacy policy + Privacy policy - Legal notice + Legal notice - Contact + Contact @@ -288,28 +282,28 @@ exports[`EC - Footer Custom renders correctly 1`] = ` href=\\"/example\\" class=\\"ecl-link ecl-link--standalone ecl-footer__identity-link\\" > - Contact + Contact - Sitemap + Sitemap - Lorem ipsum + Lorem ipsum - Lorem ipsum dolor sit + Lorem ipsum dolor sit @@ -328,9 +322,7 @@ exports[`EC - Footer Custom renders correctly 1`] = ` href=\\"/example\\" class=\\"ecl-link ecl-link--standalone ecl-footer__section-link\\" > - Commission and its priorities + Commission and its priorities @@ -453,51 +443,49 @@ exports[`EC - Footer Custom renders correctly 1`] = ` href=\\"/example\\" class=\\"ecl-link ecl-link--standalone ecl-footer__common-link\\" > - About the Commission's new web presence + About the Commission's new web presence - Language policy + Language policy - Resources for partners + Resources for partners - Cookies + Cookies - Privacy policy + Privacy policy - Legal notice + Legal notice - Contact + Contact diff --git a/src/ec/packages/ec-component-link/__snapshots__/link.test.js.snap b/src/ec/packages/ec-component-link/__snapshots__/link.test.js.snap index 4e3e7d8cb..740e776d5 100644 --- a/src/ec/packages/ec-component-link/__snapshots__/link.test.js.snap +++ b/src/ec/packages/ec-component-link/__snapshots__/link.test.js.snap @@ -2,14 +2,14 @@ exports[`EC - Link Default - link default renders correctly 1`] = ` " - + Default link " `; exports[`EC - Link Standalone - link standalone renders correctly 1`] = ` " - + Standalone link " `; @@ -19,7 +19,7 @@ exports[`EC - Link With icon after - link with icon renders correctly 1`] = ` href=\\"/path\\" class=\\"ecl-link ecl-link--standalone ecl-link--icon ecl-link--icon-after\\" > - + Standalone link with icon     - + Standalone link with icon " `; diff --git a/src/ec/packages/ec-component-link/link.html.twig b/src/ec/packages/ec-component-link/link.html.twig index 11fcb1cbe..dc1f26e14 100644 --- a/src/ec/packages/ec-component-link/link.html.twig +++ b/src/ec/packages/ec-component-link/link.html.twig @@ -62,11 +62,15 @@ {# Print the result #} - {% if _icon.name is not empty and _link.icon_position == 'before' %} - {% include '../ec-component-icon/icon.html.twig' with icon|merge({extra_classes: 'ecl-link__icon'}) %}   - {% endif %} - {{ _link.label }} - {% if _icon.name is not empty and _link.icon_position == 'after' %} -   {% include '../ec-component-icon/icon.html.twig' with icon|merge({extra_classes: 'ecl-link__icon'}) %} +{% if _icon.name is not empty %} + {% if _link.icon_position == 'before' %} + {% include '../ec-component-icon/icon.html.twig' with icon|merge({extra_classes: 'ecl-link__icon'}) %}   + {% endif %} + {{ _link.label }} + {% if _link.icon_position == 'after' %} +   {% include '../ec-component-icon/icon.html.twig' with icon|merge({extra_classes: 'ecl-link__icon'}) %} + {% endif %} + {% else %} + {{ _link.label }} {% endif %} diff --git a/src/ec/packages/ec-component-link/link.story.js b/src/ec/packages/ec-component-link/link.story.js index 6d448dcbf..cf1551b72 100644 --- a/src/ec/packages/ec-component-link/link.story.js +++ b/src/ec/packages/ec-component-link/link.story.js @@ -47,6 +47,7 @@ storiesOf('Components/Link', module) type: 'ui', name: iconsListSelect, path: defaultSprite, + size: 'fluid', }, }); }, @@ -76,6 +77,7 @@ storiesOf('Components/Link', module) type: 'ui', name: iconsListSelect, path: defaultSprite, + size: 'fluid', }, }); }, diff --git a/src/ec/packages/ec-component-link/link.test.js b/src/ec/packages/ec-component-link/link.test.js index 5f5191bfd..60beb2b08 100644 --- a/src/ec/packages/ec-component-link/link.test.js +++ b/src/ec/packages/ec-component-link/link.test.js @@ -7,7 +7,7 @@ describe('EC - Link', () => { const defaultDataStructure = { link: { type: '', - text: '', + label: '', path: '/path', }, }; @@ -17,7 +17,7 @@ describe('EC - Link', () => { expect.assertions(1); defaultDataStructure.link.type = 'default'; - defaultDataStructure.link.text = 'Default link'; + defaultDataStructure.link.label = 'Default link'; renderTwigFile(template, defaultDataStructure, (err, html) => { expect(html).toMatchSnapshot(); @@ -31,7 +31,7 @@ describe('EC - Link', () => { expect.assertions(1); defaultDataStructure.link.type = 'standalone'; - defaultDataStructure.link.text = 'Standalone link'; + defaultDataStructure.link.label = 'Standalone link'; renderTwigFile(template, defaultDataStructure, (err, html) => { expect(html).toMatchSnapshot(); @@ -45,7 +45,7 @@ describe('EC - Link', () => { expect.assertions(1); defaultDataStructure.link.type = 'standalone'; - defaultDataStructure.link.text = 'Standalone link with icon'; + defaultDataStructure.link.label = 'Standalone link with icon'; defaultDataStructure.link.icon_position = 'before'; defaultDataStructure.icon = { type: 'ui', @@ -66,7 +66,7 @@ describe('EC - Link', () => { expect.assertions(1); defaultDataStructure.link.type = 'standalone'; - defaultDataStructure.link.text = 'Standalone link with icon'; + defaultDataStructure.link.label = 'Standalone link with icon'; defaultDataStructure.link.icon_position = 'after'; defaultDataStructure.icon = { type: 'ui',