Skip to content

Commit b3b302d

Browse files
committed
navbar adjusted
1 parent d1c69d4 commit b3b302d

3 files changed

Lines changed: 124 additions & 3 deletions

File tree

assets/css/cross-page.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ table tbody td {
221221
background-color: #010101;
222222
}
223223

224+
arm-top-navigation.lp-top-navigation {
225+
--arm-green: var(--lp-accent-secondary);
226+
--arm-web-safe-green: var(--lp-accent-secondary);
227+
--ads-ui-green-65: var(--lp-accent-secondary);
228+
--ads-ui-green-70: var(--lp-accent-secondary);
229+
--ads-ui-green-80: var(--lp-accent-secondary);
230+
}
231+
224232

225233
/* Fix Masthead Height */
226234
#expanded-masthead {

themes/arm-design-system-hugo-theme/layouts/partials/header/nav-masthead.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- No masthead on homepage, as that has a special gradient look/feel -->
99
{{ if .IsHome }}
1010
<div id="global-nav-height-fixer" class="nav-black">
11-
<arm-top-navigation observe="#breadcrumb-element"></arm-top-navigation> <!-- to set to all black all the time: observe="head" -->
11+
<arm-top-navigation class="lp-top-navigation" observe="#breadcrumb-element"></arm-top-navigation> <!-- to set to all black all the time: observe="head" -->
1212
</div>
1313
<div id="only-breadcrumb-masthead">
1414
<div class="is-responsive-width">
@@ -20,7 +20,7 @@
2020
<div id="nav-masthead-breadcrumbs">
2121
<!-- Global Nav -->
2222
<div id="global-nav-height-fixer" class="nav-transparent">
23-
<arm-top-navigation observe="#breadcrumb-element"></arm-top-navigation>
23+
<arm-top-navigation class="lp-top-navigation" observe="#breadcrumb-element"></arm-top-navigation>
2424
</div>
2525
<!-- Masthead -->
2626
<div id="expanded-masthead">

themes/arm-design-system-hugo-theme/static/js/authentication.js

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,105 @@ function renderAuthInTopNav() {
243243

244244
}
245245

246+
function applyTopNavHighlightColor() {
247+
const topnav = document.querySelector("arm-top-navigation");
248+
const shadowRoot = topnav?.shadowRoot;
249+
if (!shadowRoot) return;
250+
251+
const highlightColor = "#D1BAFC";
252+
const isArmGreen = (color) => {
253+
const normalizedColor = (color || "").trim().toLowerCase();
254+
if (["#95d600", "#a4da00", "#b8e600"].includes(normalizedColor)) return true;
255+
256+
const rgbMatch = normalizedColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
257+
if (!rgbMatch) return false;
258+
259+
const red = Number(rgbMatch[1]);
260+
const green = Number(rgbMatch[2]);
261+
const blue = Number(rgbMatch[3]);
262+
return green >= 180 && red >= 90 && red <= 190 && blue <= 90 && green > red;
263+
};
264+
265+
const styleId = "learning-paths-top-nav-highlight-color";
266+
if (!shadowRoot.getElementById(styleId)) {
267+
const style = document.createElement("style");
268+
style.id = styleId;
269+
style.textContent = `
270+
:host {
271+
--arm-green: ${highlightColor};
272+
--arm-web-safe-green: ${highlightColor};
273+
--ads-ui-green-65: ${highlightColor};
274+
--ads-ui-green-70: ${highlightColor};
275+
--ads-ui-green-80: ${highlightColor};
276+
}
277+
278+
a:hover,
279+
button:hover,
280+
[role="button"]:hover,
281+
[role="link"]:hover,
282+
[role="menuitem"]:hover,
283+
a:hover *,
284+
button:hover *,
285+
[role="button"]:hover *,
286+
[role="link"]:hover *,
287+
[role="menuitem"]:hover *,
288+
a:focus-visible,
289+
button:focus-visible,
290+
[role="button"]:focus-visible,
291+
[role="link"]:focus-visible,
292+
[role="menuitem"]:focus-visible,
293+
a:focus-visible *,
294+
button:focus-visible *,
295+
[role="button"]:focus-visible *,
296+
[role="link"]:focus-visible *,
297+
[role="menuitem"]:focus-visible * {
298+
color: ${highlightColor} !important;
299+
-webkit-text-fill-color: ${highlightColor} !important;
300+
-webkit-text-stroke-color: ${highlightColor} !important;
301+
fill: ${highlightColor} !important;
302+
stroke: ${highlightColor} !important;
303+
}
304+
305+
a:hover::before,
306+
a:hover::after,
307+
button:hover::before,
308+
button:hover::after,
309+
[role="button"]:hover::before,
310+
[role="button"]:hover::after,
311+
[role="link"]:hover::before,
312+
[role="link"]:hover::after,
313+
[role="menuitem"]:hover::before,
314+
[role="menuitem"]:hover::after {
315+
background-color: ${highlightColor} !important;
316+
border-color: ${highlightColor} !important;
317+
}
318+
`;
319+
shadowRoot.appendChild(style);
320+
}
321+
322+
shadowRoot.querySelectorAll("*").forEach((element) => {
323+
const styles = window.getComputedStyle(element);
324+
if (
325+
isArmGreen(styles.color) ||
326+
isArmGreen(styles.webkitTextFillColor) ||
327+
isArmGreen(styles.fill) ||
328+
isArmGreen(styles.stroke)
329+
) {
330+
element.style.setProperty("color", highlightColor, "important");
331+
element.style.setProperty("-webkit-text-fill-color", highlightColor, "important");
332+
element.style.setProperty("-webkit-text-stroke-color", highlightColor, "important");
333+
element.style.setProperty("fill", highlightColor, "important");
334+
element.style.setProperty("stroke", highlightColor, "important");
335+
}
336+
});
337+
338+
if (!topnav.learningPathsHighlightListenersAttached) {
339+
topnav.addEventListener("mouseover", () => window.requestAnimationFrame(applyTopNavHighlightColor));
340+
topnav.addEventListener("focusin", () => window.requestAnimationFrame(applyTopNavHighlightColor));
341+
topnav.learningPathsHighlightListenersAttached = true;
342+
}
343+
}
344+
246345

247346

248347

@@ -298,9 +397,23 @@ document.addEventListener("arm-top-navigation-ready", function (e) {
298397
const htmlElement = document.documentElement;
299398
htmlElement.setAttribute("theme", "dark");
300399

400+
window.requestAnimationFrame(applyTopNavHighlightColor);
401+
window.setTimeout(applyTopNavHighlightColor, 250);
301402
renderAuthInTopNav();
302403
});
303404

405+
function scheduleTopNavHighlightColor() {
406+
[0, 250, 1000].forEach((delay) => {
407+
window.setTimeout(applyTopNavHighlightColor, delay);
408+
});
409+
}
410+
411+
if (document.readyState === "loading") {
412+
document.addEventListener("DOMContentLoaded", scheduleTopNavHighlightColor);
413+
} else {
414+
scheduleTopNavHighlightColor();
415+
}
416+
304417

305418

306419
// ----------------------------------------------------------------------
@@ -309,4 +422,4 @@ document.addEventListener("arm-top-navigation-ready", function (e) {
309422
(async () => {
310423
await initAuth(); // IMPORTANT: await this before user clicks anything
311424

312-
})();
425+
})();

0 commit comments

Comments
 (0)