-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Adding announcement banners (#722)
Co-authored-by: Daniel McCloy <dan@mccloy.info>
- Loading branch information
Showing
9 changed files
with
109 additions
and
10 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
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
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
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
36 changes: 36 additions & 0 deletions
36
src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss
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,36 @@ | ||
$announcement-height: 3rem; | ||
.bd-header-announcement { | ||
height: $announcement-height; | ||
width: 100%; | ||
display: flex; | ||
position: relative; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 0.5rem 12.5%; // Horizontal padding so the width is 75% | ||
@include media-breakpoint-down(md) { | ||
// Announcements can take a bit more width on mobile | ||
padding: 0.5rem 2%; | ||
} | ||
|
||
p { | ||
font-weight: bold; | ||
margin: 0; | ||
} | ||
|
||
// The same background color transparency hack we use in admonitions | ||
&:after { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
left: 0; | ||
top: 0; | ||
background-color: var(--pst-color-info); | ||
opacity: 0.2; | ||
content: ""; | ||
z-index: -1; // So it doesn't hover over the content | ||
} | ||
|
||
&:empty { | ||
display: none; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.navbar { | ||
position: fixed; | ||
position: sticky; | ||
min-height: var(--pst-header-height); | ||
width: 100%; | ||
padding: 0; | ||
|
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
26 changes: 24 additions & 2 deletions
26
src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html
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 |
---|---|---|
@@ -1,2 +1,24 @@ | ||
{# A banner with an alert. #} | ||
{# Note that this hasn't been optimized yet so may not behave as expected. #} | ||
{%- if theme_announcement -%} | ||
|
||
{% set is_remote=theme_announcement.startswith("http") %} | ||
|
||
{# If we are remote, add a script to make an HTTP request for the value on page load #} | ||
{%- if is_remote %} | ||
<script> | ||
$.get("{{ theme_announcement }}", success=(data)=>{ | ||
$("#header-announcement").html(`<div class="bd-header-announcement__content">${data}</div>`); | ||
}).fail(() => { | ||
console.log("[PST]: Failed to load announcement at: {{ theme_announcement }}") | ||
}); | ||
|
||
</script> | ||
{% endif %} | ||
|
||
<div class="bd-header-announcement container-fluid" id="header-announcement"> | ||
{#- if announcement text is not remote, populate announcement w/ local content -#} | ||
{%- if not is_remote %} | ||
<div class="bd-header-announcement__content">{{ theme_announcement }}</div> | ||
{%- endif -%} | ||
</div> | ||
|
||
{%- endif %} |
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