-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1218 from international-labour-organization/develop
Patch Release 20 September
- Loading branch information
Showing
4 changed files
with
126 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ilo-org/twig": patch | ||
--- | ||
|
||
Adds backward compatibility to the socialmedia component which in 1.1.1 removed the twitter icon and replaced it with X. With this, passing `twitter` to as an argument to the icon field will render an X icon. |
103 changes: 65 additions & 38 deletions
103
packages/twig/cypress/e2e/navigation/social-media.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,73 @@ | ||
describe("social media", () => { | ||
import fixture from "../../fixtures/socialmedia.json"; | ||
|
||
const url = `/pattern-preview?id=socialmedia&fields=${encodeURI( | ||
JSON.stringify(fixture) | ||
)}`; | ||
|
||
describe("Social Media", () => { | ||
beforeEach(() => { | ||
cy.visit("/patterns/socialmedia"); | ||
cy.getPreview("socialmedia").first().as("socialMediaSection"); | ||
cy.visit(url); | ||
cy.get(".ilo--social-media").as("socialMedia"); | ||
}); | ||
|
||
it("checks if social media renders as expected", () => { | ||
cy.get("@socialMediaSection").within(() => { | ||
cy.get(".ilo--social-media") | ||
.should("exist") | ||
.within(() => { | ||
cy.get(".ilo--social-media--list--item") | ||
.first() | ||
.within(() => { | ||
cy.get("a").should("have.attr", "title", "X"); | ||
}); | ||
|
||
cy.get(".ilo--social-media--list--item") | ||
.last() | ||
.within(() => { | ||
cy.get("a").should("have.attr", "title", "Youtube"); | ||
}); | ||
}); | ||
it("renders the headline if provided", () => { | ||
cy.fixture("socialmedia").then((data) => { | ||
if (data.headline) { | ||
cy.get("@socialMedia") | ||
.find("h5.ilo--social-media--headline") | ||
.should("contain.text", data.headline); | ||
} else { | ||
cy.get("@socialMedia") | ||
.find("h5.ilo--social-media--headline") | ||
.should("not.exist"); | ||
} | ||
}); | ||
}); | ||
|
||
it("checks for navigation in social media icons", () => { | ||
cy.get("@socialMediaSection").within(() => { | ||
cy.get(".ilo--social-media") | ||
.should("exist") | ||
.within(() => { | ||
cy.get(".ilo--social-media--list--item") | ||
.eq(2) | ||
.within(() => { | ||
cy.get("a") | ||
.should( | ||
"have.attr", | ||
"href", | ||
"https://www.linkedin.com/company/international-labour-organization-ilo" | ||
) | ||
.should("have.attr", "target", "_blank"); | ||
}); | ||
}); | ||
}); | ||
it("renders the correct number of social media icons", () => { | ||
cy.get("@socialMedia") | ||
.find("li.ilo--social-media--list--item") | ||
.should("have.length", fixture.icons.length); | ||
}); | ||
|
||
it("should ensure each icon has a background image with a data url", () => { | ||
cy.visit(url); | ||
cy.get("@socialMedia") | ||
.find("ul.ilo--social-media--list li a") | ||
.each(($icon) => { | ||
cy.wrap($icon) | ||
.should("have.css", "background-image") | ||
.and("match", /url\(.+\)/); | ||
}); | ||
}); | ||
|
||
it("should ensure Twitter and X icons have the same background image", () => { | ||
let xIconBg, twitterIconBg; | ||
|
||
// Get the X icon | ||
cy.get("@socialMedia") | ||
.find('a:contains("X")') | ||
.then(($xIcon) => { | ||
xIconBg = $xIcon.css("background-image"); | ||
}); | ||
|
||
// Get the Twitter icon by its text content | ||
cy.get("@socialMedia") | ||
.find('a:contains("Twitter")') | ||
.then(($twitterIcon) => { | ||
twitterIconBg = $twitterIcon.css("background-image"); | ||
}) | ||
.then(() => { | ||
expect(xIconBg).to.equal(twitterIconBg); | ||
}); | ||
}); | ||
|
||
it("should ensure each icon has a title attribute", () => { | ||
cy.visit(url); | ||
cy.get("@socialMedia") | ||
.find("ul.ilo--social-media--list li a") | ||
.each(($icon) => { | ||
cy.wrap($icon).should("have.attr", "title"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"headline": "Follow us on social media", | ||
"icons": [ | ||
{ | ||
"icon": "tiktok", | ||
"label": "tiktok", | ||
"url": "https://tiktok.com/ilo" | ||
}, | ||
{ | ||
"icon": "flickr", | ||
"label": "flickr", | ||
"url": "https://flickr.com/ilo" | ||
}, | ||
{ | ||
"icon": "x", | ||
"label": "x", | ||
"url": "https://x.com/ilo" | ||
}, | ||
{ | ||
"icon": "youtube", | ||
"label": "youtube", | ||
"url": "https://youtube.com/ilo" | ||
}, | ||
{ | ||
"icon": "twitter", | ||
"label": "twitter", | ||
"url": "https://x.com/ilo" | ||
}, | ||
{ | ||
"icon": "facebook", | ||
"label": "facebook", | ||
"url": "https://facebook.com/ilo" | ||
}, | ||
{ | ||
"icon": "instagram", | ||
"label": "instagram", | ||
"url": "https://instagram.com/ilo" | ||
}, | ||
{ | ||
"icon": "linkedin", | ||
"label": "linkedin", | ||
"url": "https://linkedin.com/ilo" | ||
} | ||
], | ||
"settings": { | ||
"theme": "light", | ||
"justify": "start", | ||
"iconSize": "normal" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{# | ||
SOCIALMEDIA COMPONENT | ||
#} | ||
{# socialmedia.twig #} | ||
<div class="{{ prefix }}--social-media {{ prefix }}--social-media__theme__{{ theme|default("light") }} {{ prefix }}--social-media__justify__{{ align|default("start") }}"> | ||
{% if headline %} | ||
<h5 class="{{ prefix }}--social-media--headline">{{ headline }}</h5> | ||
{% endif %} | ||
<ul class="{{ prefix }}--social-media--list"> | ||
{% for item in icons %} | ||
{# @TODO: Get rid of this during the next major release#} | ||
{% set iconName = item.icon == 'twitter' ? 'x' : item.icon %} | ||
<li class="{{ prefix }}--social-media--list--item"> | ||
<a class="{{ prefix }}--social-media--list--item--icon {{ prefix }}--social-media--list--item--icon__{{ iconSize|default("normal") }} {{ prefix }}--social-media--list--item--icon__{{ item.icon }}" href={{ item.url }} title={{ item.label|capitalize }} target="_blank"> | ||
{{item.label|capitalize}} | ||
<a class="{{ prefix }}--social-media--list--item--icon {{ prefix }}--social-media--list--item--icon__{{ iconSize|default("normal") }} {{ prefix }}--social-media--list--item--icon__{{ iconName }}" href="{{ item.url }}" title="{{ item.label|capitalize }}" target="_blank"> | ||
{{ item.label|capitalize }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> |