forked from catherinedevlin/ipython-sql
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4f1ea8
commit 6b21303
Showing
3 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.bd-header-announcement { | ||
color: white; | ||
padding: 8px; | ||
position: sticky; | ||
top: 0; | ||
z-index: 1000; | ||
} | ||
|
||
.bd-header-announcement a { | ||
color: white; | ||
font-weight: bold; | ||
text-decoration: underline; | ||
animation: pulse 4s infinite; | ||
} | ||
|
||
@keyframes pulse { | ||
0% { | ||
opacity: 1; | ||
} | ||
|
||
50% { | ||
opacity: 0.5; | ||
} | ||
|
||
100% { | ||
opacity: 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
document.addEventListener("DOMContentLoaded", (event) => { | ||
options = [ | ||
{ | ||
text: "Deploy Streamlit apps for free on ", | ||
link: "Ploomber Cloud!", | ||
url: "https://platform.ploomber.io/register/?utm_medium=readthedocs&utm_source=jupysql", | ||
}, | ||
{ | ||
text: "Deploy Shiny apps for free on ", | ||
link: "Ploomber Cloud!", | ||
url: "https://platform.ploomber.io/register/?utm_medium=readthedocs&utm_source=jupysql", | ||
}, | ||
{ | ||
text: "Deploy Dash apps for free on ", | ||
link: "Ploomber Cloud!", | ||
url: "https://platform.ploomber.io/register/?utm_medium=readthedocs&utm_source=jupysql", | ||
}, | ||
{ | ||
text: "Try our new Streamlit ", | ||
link: "AI Editor!", | ||
url: "https://editor.ploomber.io/?utm_medium=readthedocs&utm_source=jupysql", | ||
} | ||
] | ||
const announcementElement = document.querySelector("#ploomber-top-announcement"); | ||
if (announcementElement) { | ||
const updateAnnouncement = (firstTime = false) => { | ||
let randomIndex; | ||
let currentContent = announcementElement.textContent; | ||
|
||
// Keep selecting a new random index until we get a different announcement | ||
do { | ||
randomIndex = Math.floor(Math.random() * options.length); | ||
} while (options[randomIndex].text + options[randomIndex].link === currentContent); | ||
|
||
const option = options[randomIndex]; | ||
|
||
if (firstTime) { | ||
// First time - just set content without transition | ||
announcementElement.innerHTML = `${option.text}<a href="${option.url}" target="_blank" rel="noopener noreferrer">${option.link}</a>`; | ||
} else { | ||
// Subsequent updates - use transition | ||
announcementElement.style.opacity = 0; | ||
announcementElement.style.transition = 'opacity 0.5s ease'; | ||
|
||
setTimeout(() => { | ||
announcementElement.innerHTML = `${option.text}<a href="${option.url}" target="_blank" rel="noopener noreferrer">${option.link}</a>`; | ||
announcementElement.style.opacity = 1; | ||
}, 500); | ||
} | ||
}; | ||
|
||
// Set initial content without transition | ||
updateAnnouncement(true); | ||
|
||
// Update every 5 seconds with transition | ||
setInterval(() => updateAnnouncement(false), 5000); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters