Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3be818d
Update netcentric-logo.svg with rockstar2025
jvaldas Feb 10, 2025
023c13d
add login form
joanbeltran-cn Feb 14, 2025
30bb774
basic validation
joanbeltran-cn Feb 14, 2025
acb4838
reload when adding/removing the cookie
joanbeltran-cn Feb 17, 2025
4a74465
add userchanged cookie
joanbeltran-cn Feb 25, 2025
3ba2334
style personalisation
joanbeltran-cn Feb 26, 2025
f970d12
different levels of offers
joanbeltran-cn Mar 4, 2025
3e2a59b
fix suboffers
joanbeltran-cn Mar 5, 2025
e7608ee
hard reload on login logout
joanbeltran-cn Mar 5, 2025
c0889eb
nocache
joanbeltran-cn Mar 5, 2025
20ea251
adding nocache param
joanbeltran-cn Mar 5, 2025
6b30b77
add images
joanbeltran-cn Mar 6, 2025
ea396c4
style first offer
joanbeltran-cn Mar 7, 2025
8e591e3
more offer style
joanbeltran-cn Mar 7, 2025
40d2ab9
more offer style
joanbeltran-cn Mar 7, 2025
29a6ee2
change content to subject
joanbeltran-cn Mar 10, 2025
44ec091
CBE offer
joanbeltran-cn Mar 11, 2025
e219551
userchanged cookie
joanbeltran-cn Mar 11, 2025
5754ab1
remove invalid json info blocks
joanbeltran-cn Mar 11, 2025
74af7ee
cards first content
joanbeltran-cn Mar 12, 2025
56d52c2
cards - a bit more styling
joanbeltran-cn Mar 12, 2025
1ad9679
card offer styles and responsive
joanbeltran-cn Mar 13, 2025
58e132c
text sizes
joanbeltran-cn Mar 13, 2025
4f750c9
big text space
joanbeltran-cn Mar 13, 2025
d20a6c5
big text space
joanbeltran-cn Mar 13, 2025
c6bf3af
big text space
joanbeltran-cn Mar 13, 2025
7e020db
remove custom image flickr
joanbeltran-cn Mar 14, 2025
3c1a939
fix personalizationdata check
joanbeltran-cn Mar 14, 2025
d69dbec
sign in form
joanbeltran-cn Mar 17, 2025
6add6ae
change payload
joanbeltran-cn Mar 18, 2025
ee4787e
resposive images and other small changes
joanbeltran-cn Mar 18, 2025
ef483b8
image loading in ed
joanbeltran-cn Mar 18, 2025
50f215d
little changes
joanbeltran-cn Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blocks/header/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ header nav .nav-brand p {
}

header nav .nav-brand .icon, header nav .nav-brand .icon svg {
width: 150px;
width: 110px;
height: 40px;
}

Expand Down
17 changes: 16 additions & 1 deletion blocks/header/header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { decorateIcons, getMetadata, getLanguagePath } from '../../scripts/lib-franklin.js';
import { addChevronToButtons } from '../../scripts/scripts.js';
import initLogIn from '../../scripts/login.js';
import { getImageURL } from '../../scripts/personalisation-helpers.js';

const mobileBreakpoint = 900;
let globalWindowWidth = window.innerWidth;
Expand Down Expand Up @@ -106,6 +108,8 @@
const langSwitch = header.querySelector('.nav-tools ul');
const langLinks = langSwitch.querySelectorAll('li:not(:last-of-type) a');

initLogIn(langSwitch.querySelector('li:last-of-type a'));

const defaultLanguage = 'en';
const currentLang = document.documentElement.lang;
const isInDefaultLang = currentLang === defaultLanguage;
Expand Down Expand Up @@ -139,13 +143,24 @@
// fetch nav content
const resp = await fetch(`${getLanguagePath()}${getNavPath()}.plain.html`);
if (resp.ok) {
const html = await resp.text();
let html = await resp.text();
const isCampaignTemplate = document.querySelector('meta[content="campaign"]');

// decorate nav DOM
const nav = document.createElement('nav');
if (window.personalizationData?.content?.profileImageURL) {
const classes = 'icon icon-netcentric-logo icon-decorated personalized';
const url = getImageURL(window.personalizationData.content.profileImageURL);
const altText = window.personalizationData.content?.firstName || 'Netcentric logo';
html = html.replace('<span class="icon icon-netcentric-logo"></span>', `
<span class="icon icon-netcentric-logo icon-decorated personalized">
<img src="${url}" alt="${altText}" class="${classes}" />
</span>
`);
}
nav.innerHTML = html;


Check failure on line 163 in blocks/header/header.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
const classes = isCampaignTemplate ? ['brand'] : ['brand', 'sections', 'search', 'tools'];
classes.forEach((e, j) => {
const section = nav.children[j];
Expand Down
36 changes: 36 additions & 0 deletions blocks/personalization-card/personalization-card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.personalization-card {
width: var(--section-width);
margin: 0 auto;
padding: 28px 0;
margin-block-end: 30px;

.card-offer {
padding-inline: 20px;

@media (min-width: 900px) {
display: flex;
column-gap: 20px;
}
}

img {
@media (min-width: 900px) {
width: 40%;
}
}

h1 {
color: inherit;
margin-block: 0;
}
}

.personalization-card-wrapper {
background-color: var(--c-dark-plum);
margin-inline: 0 !important;
width: 100% !important;
}

.personalization-card-container {
padding: 0 !important;
}
46 changes: 46 additions & 0 deletions blocks/personalization-card/personalization-card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { isValidJSON } from '../../scripts/personalisation-helpers.js';
import { addChevronToButtons } from '../../scripts/scripts.js';

function createCardOffer(offer) {
const offerElement = document.createElement('div');
const title = offer.title?.content ? `<h1>${offer.title?.content}</h1>` : '';
const text = offer.body?.content ? `<p>${offer.body?.content}</p>` : '';
const button = offer.buttons[0]?.text?.content ? `<p class="button-container"><a href="#" class="button primary">${offer.buttons[0]?.text?.content}</a></p>` : '';
const image = offer.image?.url ? `<img src="${offer.image?.url}" alt="${offer.image?.alt}" />` : '';
offerElement.className = 'section dark-plum card-offer';
offerElement.innerHTML = `
${image}
<div class="offer-details">
${title}
${text}
${button}
</div>
`;
return offerElement;
}

function handleOffers(block, offer) {
const cardOffer = createCardOffer(offer);
addChevronToButtons(block);
block.append(cardOffer);
}

export default function decorate(block) {
const content = block.textContent.trim();
const editedContent = content.replace('Personalization Card:', '').trim();
if (!isValidJSON(editedContent)) {
block.parentElement.remove();
return;
}
const data = JSON.parse(editedContent);
block.children[0].remove();
data.forEach((offer) => {
if (Array.isArray(offer.content)) {
offer.content.forEach((subOffer) => {
handleOffers(block, subOffer);
});
} else {
handleOffers(block, offer.content);
}
});
}

Check failure on line 46 in blocks/personalization-card/personalization-card.js

View workflow job for this annotation

GitHub Actions / build

Newline required at end of file but not found
3 changes: 3 additions & 0 deletions blocks/personalization-cbe/personalization-cbe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.personalization-cbe {

}
13 changes: 13 additions & 0 deletions blocks/personalization-cbe/personalization-cbe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isValidJSON } from '../../scripts/personalisation-helpers.js';

export default function decorate(block) {
const content = block.textContent.trim();
const editedContent = content.replace('Personalization CBE:', '').trim();
if (!isValidJSON(editedContent)) {
block.parentElement.remove();
return;
}
const data = JSON.parse(editedContent);
block.children[0].remove();
window.personalizationData = {...data[0]};

Check failure on line 12 in blocks/personalization-cbe/personalization-cbe.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'

Check failure on line 12 in blocks/personalization-cbe/personalization-cbe.js

View workflow job for this annotation

GitHub Actions / build

A space is required after '{'
}

Check failure on line 13 in blocks/personalization-cbe/personalization-cbe.js

View workflow job for this annotation

GitHub Actions / build

Newline required at end of file but not found
79 changes: 79 additions & 0 deletions blocks/personalization-ed/personalization-ed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.personalization-ed {
display: grid;
grid-template-columns: 1fr;
column-gap: 20px;
row-gap: 40px;
margin-block-end: 80px;

> *:first-child {
.img-wrap {
position: relative;
}

h2 {
font-size: 38px;
}

p {
font-size: 30px;
}

@media (min-width: 900px) {
grid-column: span 2;

.img-mask {
position: absolute;
top: 0;
left: auto;
width: 100%;
height: 100%;
background-color: #000;
opacity: 0.4;
}

.offer-details {
position: absolute;
top: 40%;
z-index: 2;
left: 20px;
}

h2, p {
color: #fff;
font-weight: bold;
text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
}

@media (min-width: 1200px) {
.offer-details {
width: 65%;
}
}
}

> *:not(:first-child) {
grid-column: span 1;
}

> *:only-child {
grid-column: span 2;
}

@media (min-width: 900px) {
grid-template-columns: 1fr 1fr;
}

.ed-offer {
position: relative;
margin-inline: 20px;

h2 {
margin-block: 0;
}
}

img {
display: block;
}
}
52 changes: 52 additions & 0 deletions blocks/personalization-ed/personalization-ed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { isValidJSON, getImageURL, getCookie } from '../../scripts/personalisation-helpers.js';
import { createOptimizedPicture } from '../../scripts/lib-franklin.js';


Check failure on line 4 in blocks/personalization-ed/personalization-ed.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
function createEdOffer(offer, index) {
const offerElement = document.createElement('div');
const imageSrc = offer.imageURL ? getImageURL(offer.imageURL) : '/insights/2023/12/media_1db1f637bcc9a28245d76086f2d141781cbcc080d.png?width=2000&format=webply&optimize=medium';
const subject = offer.subject ? `<p>${offer.subject}</p>` : '';
const button = offer.buttonText ? `<p class="button-container"><a href="#" class="button primary">${offer.buttonText}</a></p>` : '';
const isAutenticated = getCookie('ncUser');
const imgMask = isAutenticated ? '<div class="img-mask"></div>' : '';
const imageLoading = !isAutenticated && index === 0;
const offerPicture = createOptimizedPicture(imageSrc, offer.offerName, imageLoading, [{ media: '(min-width: 900px)', width: '2000' }, { width: '1000' }]);
offerElement.classList.add('ed-offer');
offerElement.innerHTML = `
<div class="img-wrapper">
${offerPicture.outerHTML}
${imgMask}
</div>
<div class="offer-details">
${subject}
<h2>${offer.text}</h2>
${button}
</div>
`;
return offerElement;
}

function handleOffers(block, offer, index) {
const edOffer = createEdOffer(offer, index);
block.append(edOffer);
}

export default function decorate(block) {
const content = block.textContent.trim();
const editedContent = content.replace('Personalization ED:', '').trim();
if (!isValidJSON(editedContent)) {
block.parentElement.remove();
return;
}
const data = JSON.parse(editedContent);
block.children[0].remove();
data.forEach((offer, index) => {
if (Array.isArray(offer.content)) {
offer.content.forEach((subOffer, subIndex) => {
handleOffers(block, subOffer, subIndex);
});
} else {
handleOffers(block, offer.content, index);
}
});
}

Check failure on line 52 in blocks/personalization-ed/personalization-ed.js

View workflow job for this annotation

GitHub Actions / build

Newline required at end of file but not found
249 changes: 248 additions & 1 deletion icons/netcentric-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading