|
1 |
| -<!-- Inline CSS to Hide Announcement Bar Initially --> |
2 | 1 | <style>
|
3 | 2 | .announcement-bar {
|
4 | 3 | display: none;
|
5 | 4 | height: 0;
|
6 | 5 | }
|
| 6 | + .bloblang-playground .banner-container { |
| 7 | + display: none; |
| 8 | + } |
7 | 9 | </style>
|
8 | 10 | <script>
|
9 | 11 | (function() {
|
10 | 12 | 'use strict';
|
11 |
| - function handleBanner(bannerId, sessionKey) { |
| 13 | + function handleBanner(bannerId, sessionKey, announcementType) { |
12 | 14 | const banner = document.getElementById(bannerId);
|
13 | 15 | if (!banner) return;
|
14 | 16 |
|
15 |
| - const hasSeenBanner = window.sessionStorage.getItem(sessionKey) || false; |
| 17 | + const storageKey = `${sessionKey}-${announcementType}`; // Use the announcement type to differentiate between different banners |
| 18 | + const hasSeenBanner = window.sessionStorage.getItem(storageKey) || false; |
16 | 19 | if (hasSeenBanner) {
|
| 20 | + if (announcementType !== 'bloblang') { |
| 21 | + document.documentElement.style.setProperty('--announcement-bar-height', '0px'); |
| 22 | + document.documentElement.style.setProperty('--announcement-bar-height--desktop', '0px'); |
| 23 | + } |
17 | 24 | banner.remove();
|
18 | 25 | } else {
|
| 26 | + if (announcementType !== 'bloblang') { |
| 27 | + document.documentElement.style.setProperty('--announcement-bar-height', '50px'); |
| 28 | + document.documentElement.style.setProperty('--announcement-bar-height--desktop', '30px'); |
| 29 | + } |
19 | 30 | banner.style.display = 'flex';
|
20 |
| - const closeButton = banner.querySelector('.close-button'); |
| 31 | + const closeButton = banner.querySelector('.close'); |
21 | 32 | if (closeButton) {
|
22 | 33 | closeButton.addEventListener('click', function () {
|
| 34 | + document.documentElement.style.setProperty('--announcement-bar-height', '0px'); |
| 35 | + document.documentElement.style.setProperty('--announcement-bar-height--desktop', '0px'); |
23 | 36 | banner.remove();
|
24 |
| - window.sessionStorage.setItem(sessionKey, 'true'); |
| 37 | + window.sessionStorage.setItem(storageKey, 'true'); |
25 | 38 | });
|
26 | 39 | }
|
27 | 40 | }
|
|
32 | 45 | (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
33 | 46 |
|
34 | 47 | document.documentElement.setAttribute('data-theme', initialTheme);
|
35 |
| -
|
36 |
| - document.addEventListener('DOMContentLoaded', function() { |
37 |
| - handleBanner('announcement', 'announcementClosed'); |
38 |
| - handleBanner('bloblang-banner', 'bloblangBannerDismissed'); |
39 |
| - }); |
40 | 48 | // This script and the styles must be in the head to avoid flashing when the default white background changes to dark https://github.com/redpanda-data/docs-ui/pull/174
|
41 | 49 | window.addEventListener('DOMContentLoaded', function() {
|
42 | 50 | const switchButton = document.getElementById('switch-theme');
|
43 | 51 | const announcementBar = document.getElementById('announcement');
|
| 52 | + let announcementLevel = ''; |
44 | 53 | if (switchButton) {
|
45 | 54 | setTheme(initialTheme); // Apply initial theme on load
|
46 | 55 | switchButton.addEventListener('click', function() {
|
|
51 | 60 | setTheme(newTheme);
|
52 | 61 | });
|
53 | 62 | }
|
54 |
| - if (!announcementBar) return; |
55 |
| - const hasSeenAnnouncement = window.sessionStorage.getItem('announcementClosed') || window.localStorage.getItem('announcementClosed') || false; |
56 |
| - if (!hasSeenAnnouncement) { |
57 |
| - document.documentElement.style.setProperty('--announcement-bar-height', '50px'); |
58 |
| - document.documentElement.style.setProperty('--announcement-bar-height--desktop', '30px'); |
59 |
| - announcementBar.style.display = 'flex'; |
60 |
| - } else { |
61 |
| - document.documentElement.style.setProperty('--announcement-bar-height', '0px'); |
62 |
| - document.documentElement.style.setProperty('--announcement-bar-height--desktop', '0px'); |
| 63 | + if (announcementBar) { |
| 64 | + announcementLevel = announcementBar.getAttribute('data-announcement-key'); |
| 65 | + handleBanner('announcement', 'announcementClosed', announcementLevel); |
63 | 66 | }
|
64 |
| - var closeButton = document.getElementById('close-announcement'); |
65 |
| - if (!closeButton) return; |
66 |
| - closeButton.addEventListener('click', function () { |
67 |
| - document.documentElement.style.setProperty('--announcement-bar-height', '0px'); |
68 |
| - document.documentElement.style.setProperty('--announcement-bar-height--desktop', '0px'); |
69 |
| - announcementBar.remove(); |
70 |
| - window.sessionStorage.setItem('announcementClosed', 'true'); |
71 |
| - }); |
| 67 | + handleBanner('bloblang-banner', 'bloblangBannerDismissed', 'bloblang'); |
72 | 68 | });
|
73 | 69 | function setTheme(theme) {
|
74 | 70 | const rapidocEl = document.getElementById('api');
|
|
0 commit comments