Skip to content

Commit

Permalink
[MWPW-160730] - Project Red logo update for adobecom and bacom (#3112)
Browse files Browse the repository at this point in the history
* Add changes for new logo update on acom and bacom pages

* Lint fix

* Fix review comment

* Added default dark mode icon
  • Loading branch information
Deva309 authored Nov 5, 2024
1 parent 1e16205 commit 8db9c32
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 10 additions & 0 deletions libs/blocks/global-navigation/global-navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,22 @@ header.global-navigation {
flex-shrink: 0;
}

.feds-brand-image.brand-image-only {
height: 36px;
width: auto;
}

.feds-brand-image picture, .feds-brand-image img, .feds-brand-image svg,
.feds-logo-image picture, .feds-logo-image img, .feds-logo-image svg {
width: 100%;
display: block;
}

.feds-brand-image.brand-image-only picture, .feds-brand-image.brand-image-only img, .feds-brand-image.brand-image-only svg {
width: auto;
height: 100%;
}

.feds-brand-label,
.feds-logo-label {
flex-shrink: 0;
Expand Down
16 changes: 9 additions & 7 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ const setupKeyboardNav = async () => {
});
};

const getBrandImage = (image) => {
const getBrandImage = (image, brandImageOnly) => {
// Return the default Adobe logo if an image is not available
if (!image) return CONFIG.icons.company;
if (!image) return brandImageOnly ? CONFIG.icons.brand : CONFIG.icons.company;

// Try to decorate image as PNG, JPG or JPEG
const imgText = image?.textContent || '';
Expand All @@ -242,7 +242,7 @@ const getBrandImage = (image) => {
}

// Return the default Adobe logo if the image could not be decorated
return CONFIG.icons.company;
return brandImageOnly ? CONFIG.icons.brand : CONFIG.icons.company;
};

const closeOnClickOutside = (e) => {
Expand Down Expand Up @@ -760,8 +760,9 @@ class Gnav {
if (!link) return '';

// Check which elements should be rendered
const isBrandImage = rawBlock.matches(selectors.brandImageOnly);
const renderImage = !rawBlock.matches('.no-logo');
const renderLabel = includeLabel && !rawBlock.matches('.image-only');
const renderLabel = !isBrandImage && includeLabel && !rawBlock.matches('.image-only');

if (!renderImage && !renderLabel) return '';

Expand All @@ -773,18 +774,19 @@ class Gnav {

const images = blockLinks.filter((blockLink) => imgRegex.test(blockLink.href)
|| imgRegex.test(blockLink.textContent));
if (images.length === 2) return getBrandImage(images[1]);
if (images.length === 2) return getBrandImage(images[1], isBrandImage);
}
const svgImg = rawBlock.querySelector('picture img[src$=".svg"]');
if (svgImg) return svgImg;

const image = blockLinks.find((blockLink) => imgRegex.test(blockLink.href)
|| imgRegex.test(blockLink.textContent));
return getBrandImage(image);
return getBrandImage(image, isBrandImage);
};

const brandImageClass = isBrandImage ? ` ${selectors.brandImageOnly.slice(1)}` : '';
const imageEl = renderImage
? toFragment`<span class="${classPrefix}-image">${getImageEl()}</span>`
? toFragment`<span class="${classPrefix}-image${brandImageClass}">${getImageEl()}</span>`
: '';

// Create label element
Expand Down
3 changes: 3 additions & 0 deletions libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ export const selectors = {
menuColumn: '.feds-menu-column',
gnavPromo: '.gnav-promo',
columnBreak: '.column-break',
brandImageOnly: '.brand-image-only',
};

export const icons = {
brand: '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 64.57 35"><defs><style>.cls-1{fill: #eb1000;}</style></defs><path class="cls-1" d="M6.27,10.22h4.39l6.2,14.94h-4.64l-3.92-9.92-2.59,6.51h3.08l1.23,3.41H0l6.27-14.94ZM22.03,13.32c.45,0,.94.04,1.43.16v-3.7h3.88v14.72c-.89.4-2.81.89-4.73.89-3.48,0-6.47-1.98-6.47-5.93s2.88-6.13,5.89-6.13ZM22.52,22.19c.36,0,.65-.07.94-.16v-5.42c-.29-.11-.58-.16-.96-.16-1.27,0-2.45.94-2.45,2.92s1.2,2.81,2.47,2.81ZM34.25,13.32c3.23,0,5.98,2.18,5.98,6.02s-2.74,6.02-5.98,6.02-6-2.18-6-6.02,2.72-6.02,6-6.02ZM34.25,22.13c1.11,0,2.14-.89,2.14-2.79s-1.03-2.79-2.14-2.79-2.12.89-2.12,2.79.96,2.79,2.12,2.79ZM41.16,9.78h3.9v3.7c.47-.09.96-.16,1.45-.16,3.03,0,5.84,1.98,5.84,5.86,0,4.1-2.99,6.18-6.53,6.18-1.52,0-3.46-.31-4.66-.87v-14.72ZM45.91,22.17c1.34,0,2.56-.96,2.56-2.94,0-1.85-1.2-2.72-2.5-2.72-.36,0-.65.04-.91.16v5.35c.22.09.51.16.85.16ZM58.97,13.32c2.92,0,5.6,1.87,5.6,5.64,0,.51-.02,1-.09,1.49h-7.27c.4,1.32,1.56,1.94,3.01,1.94,1.18,0,2.27-.29,3.5-.82v2.97c-1.14.58-2.5.82-3.9.82-3.7,0-6.58-2.23-6.58-6.02s2.61-6.02,5.73-6.02ZM60.93,18.02c-.2-1.27-1.05-1.78-1.92-1.78s-1.58.54-1.87,1.78h3.79Z"/></svg>',
company: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 133.5 118.1"><defs><style>.cls-1 {fill: #eb1000;}</style></defs><g><g><polygon class="cls-1" points="84.1 0 133.5 0 133.5 118.1 84.1 0"/><polygon class="cls-1" points="49.4 0 0 0 0 118.1 49.4 0"/><polygon class="cls-1" points="66.7 43.5 98.2 118.1 77.6 118.1 68.2 94.4 45.2 94.4 66.7 43.5"/></g></g></svg>',
search: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" focusable="false"><path d="M14 2A8 8 0 0 0 7.4 14.5L2.4 19.4a1.5 1.5 0 0 0 2.1 2.1L9.5 16.6A8 8 0 1 0 14 2Zm0 14.1A6.1 6.1 0 1 1 20.1 10 6.1 6.1 0 0 1 14 16.1Z"></path></svg>',
home: '<svg xmlns="http://www.w3.org/2000/svg" height="25" viewBox="0 0 18 18" width="25"><path fill="#6E6E6E" d="M17.666,10.125,9.375,1.834a.53151.53151,0,0,0-.75,0L.334,10.125a.53051.53051,0,0,0,0,.75l.979.9785A.5.5,0,0,0,1.6665,12H2v4.5a.5.5,0,0,0,.5.5h4a.5.5,0,0,0,.5-.5v-5a.5.5,0,0,1,.5-.5h3a.5.5,0,0,1,.5.5v5a.5.5,0,0,0,.5.5h4a.5.5,0,0,0,.5-.5V12h.3335a.5.5,0,0,0,.3535-.1465l.979-.9785A.53051.53051,0,0,0,17.666,10.125Z"/></svg>',
};

export const darkIcons = {
...icons,
brand: '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 64.57 35"><defs><style>.cls-1{fill: #fff;}</style></defs><path class="cls-1" d="M6.27,10.22h4.39l6.2,14.94h-4.64l-3.92-9.92-2.59,6.51h3.08l1.23,3.41H0l6.27-14.94ZM22.03,13.32c.45,0,.94.04,1.43.16v-3.7h3.88v14.72c-.89.4-2.81.89-4.73.89-3.48,0-6.47-1.98-6.47-5.93s2.88-6.13,5.89-6.13h0ZM22.52,22.19c.36,0,.65-.07.94-.16v-5.42c-.29-.11-.58-.16-.96-.16-1.27,0-2.45.94-2.45,2.92s1.2,2.81,2.47,2.81h0ZM34.25,13.32c3.23,0,5.98,2.18,5.98,6.02s-2.74,6.02-5.98,6.02-6-2.18-6-6.02,2.72-6.02,6-6.02ZM34.25,22.13c1.11,0,2.14-.89,2.14-2.79s-1.03-2.79-2.14-2.79-2.12.89-2.12,2.79.96,2.79,2.12,2.79ZM41.16,9.78h3.9v3.7c.47-.09.96-.16,1.45-.16,3.03,0,5.84,1.98,5.84,5.86,0,4.1-2.99,6.18-6.53,6.18-1.52,0-3.46-.31-4.66-.87v-14.72h0ZM45.91,22.17c1.34,0,2.56-.96,2.56-2.94,0-1.85-1.2-2.72-2.5-2.72-.36,0-.65.04-.91.16v5.35c.22.09.51.16.85.16h0ZM58.97,13.32c2.92,0,5.6,1.87,5.6,5.64,0,.51-.02,1-.09,1.49h-7.27c.4,1.32,1.56,1.94,3.01,1.94,1.18,0,2.27-.29,3.5-.82v2.97c-1.14.58-2.5.82-3.9.82-3.7,0-6.58-2.23-6.58-6.02s2.61-6.02,5.73-6.02ZM60.93,18.02c-.2-1.27-1.05-1.78-1.92-1.78s-1.58.54-1.87,1.78c0,0,3.79,0,3.79,0Z"/></svg>',
company: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 133.5 118.1"><defs><style>.cls-1 {fill: currentColor;}</style></defs><g><g><polygon class="cls-1" points="84.1 0 133.5 0 133.5 118.1 84.1 0"/><polygon class="cls-1" points="49.4 0 0 0 0 118.1 49.4 0"/><polygon class="cls-1" points="66.7 43.5 98.2 118.1 77.6 118.1 68.2 94.4 45.2 94.4 66.7 43.5"/></g></g></svg>',
};

Expand Down

0 comments on commit 8db9c32

Please sign in to comment.