@@ -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 ( / r g b a ? \( ( \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