|
| 1 | +document.addEventListener('DOMContentLoaded', function() { |
| 2 | + |
| 3 | + // Setup CSS for the wrapper and the banner |
| 4 | + var styleTag = document.createElement('style'); |
| 5 | + styleTag.innerHTML = ` |
| 6 | + .td-navbar .dropdown-menu { |
| 7 | + z-index: 9999 !important; |
| 8 | + } |
| 9 | +
|
| 10 | + .theme-banner-wrapper { |
| 11 | + position: sticky; |
| 12 | + z-index: 20; |
| 13 | + padding-top: 15px; /* This is your gap! */ |
| 14 | + padding-bottom: 5px; /* Breathing room below the banner */ |
| 15 | + /* Uses Bootstrap's native body background variable, with white as fallback */ |
| 16 | + background-color: var(--bs-body-bg, #ffffff); |
| 17 | + } |
| 18 | +
|
| 19 | + .theme-migration-banner { |
| 20 | + background-color: #ebf3fc; |
| 21 | + border: 1px solid #80a7e9; |
| 22 | + color: #1c3a6b; |
| 23 | + border-radius: 4px; |
| 24 | + padding: 15px; |
| 25 | + text-align: center; |
| 26 | + width: 100%; |
| 27 | + box-shadow: 0 4px 6px rgba(0,0,0,0.05); |
| 28 | + } |
| 29 | +
|
| 30 | + .theme-migration-banner a { |
| 31 | + color: #4484f4; |
| 32 | + text-decoration: underline; |
| 33 | + font-weight: bold; |
| 34 | + } |
| 35 | +
|
| 36 | + /* DARK MODE STYLING */ |
| 37 | + html[data-bs-theme="dark"] .theme-banner-wrapper, |
| 38 | + body.dark .theme-banner-wrapper, |
| 39 | + html.dark-mode .theme-banner-wrapper { |
| 40 | + /* Uses Docsy's dark mode background fallback if var fails */ |
| 41 | + background-color: var(--bs-body-bg, #20252b); |
| 42 | + } |
| 43 | +
|
| 44 | + html[data-bs-theme="dark"] .theme-migration-banner, |
| 45 | + body.dark .theme-migration-banner, |
| 46 | + html.dark-mode .theme-migration-banner { |
| 47 | + background-color: #1a273b; |
| 48 | + color: #e6efff; |
| 49 | + box-shadow: 0 4px 6px rgba(0,0,0,0.3); |
| 50 | + } |
| 51 | +
|
| 52 | + html[data-bs-theme="dark"] .theme-migration-banner a, |
| 53 | + body.dark .theme-migration-banner a, |
| 54 | + html.dark-mode .theme-migration-banner a { |
| 55 | + color: #80a7e9; |
| 56 | + } |
| 57 | +
|
| 58 | + /* Fallback for OS-level dark mode */ |
| 59 | + @media (prefers-color-scheme: dark) { |
| 60 | + html:not([data-bs-theme="light"]):not(.light) .theme-banner-wrapper { |
| 61 | + background-color: var(--bs-body-bg, #20252b); |
| 62 | + } |
| 63 | + html:not([data-bs-theme="light"]):not(.light) .theme-migration-banner { |
| 64 | + background-color: #1a273b; |
| 65 | + color: #e6efff; |
| 66 | + box-shadow: 0 4px 6px rgba(0,0,0,0.3); |
| 67 | + } |
| 68 | + html:not([data-bs-theme="light"]):not(.light) .theme-migration-banner a { |
| 69 | + color: #80a7e9; |
| 70 | + } |
| 71 | + } |
| 72 | + `; |
| 73 | + document.head.appendChild(styleTag); |
| 74 | + |
| 75 | + // Create the Wrapper |
| 76 | + var wrapper = document.createElement('div'); |
| 77 | + wrapper.id = 'migration-banner-wrapper'; |
| 78 | + wrapper.className = 'theme-banner-wrapper'; |
| 79 | + |
| 80 | + // Create the Banner |
| 81 | + var banner = document.createElement('div'); |
| 82 | + banner.className = 'theme-migration-banner'; |
| 83 | + banner.innerHTML = '⚠️ <strong>Archived Docs:</strong> Visit <a href="https://mcp-toolbox.dev/">mcp-toolbox.dev</a> for the latest version.'; |
| 84 | + wrapper.appendChild(banner); |
| 85 | + |
| 86 | + // Inject the wrapper into the center information column |
| 87 | + var contentArea = document.querySelector('.td-content') || document.querySelector('main'); |
| 88 | + if (contentArea) { |
| 89 | + contentArea.prepend(wrapper); |
| 90 | + } else { |
| 91 | + console.warn("Could not find the main content column to inject the banner."); |
| 92 | + } |
| 93 | + |
| 94 | + // Calculate navbar height synchronously to correctly offset the sticky wrapper |
| 95 | + var navbar = document.querySelector('.td-navbar'); |
| 96 | + var navbarHeight = navbar ? navbar.offsetHeight : 64; |
| 97 | + wrapper.style.top = navbarHeight + 'px'; |
| 98 | +}); |
0 commit comments