Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add announcement banner to the docs website #127

Merged
merged 3 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/napari_sphinx_theme/assets/scss/components/app-bar.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import '@/scss/utils';

.navbar {
height: 64px;

&,
&-light {
@apply tw-shadow-none;
Expand Down Expand Up @@ -52,7 +54,7 @@

@media (min-width: 960px) {
a {
padding: 0 to-rem(17px) to-rem(20px) !important;
padding: 0 to-rem(17px) to-rem(10px) !important;
margin-top: to-rem(20px) !important;
border-bottom: to-rem(3px) solid transparent;
}
Expand Down
2 changes: 1 addition & 1 deletion src/napari_sphinx_theme/assets/scss/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body {
}

.napari-page {
@apply tw-grid tw-justify-center tw-gap-6 tw-pt-32 tw-flex-auto;
@apply tw-grid tw-justify-center tw-gap-6 tw-pt-12 tw-flex-auto;

grid-template-columns: 1fr;

Expand Down
17 changes: 17 additions & 0 deletions src/napari_sphinx_theme/assets/styles/_announcement.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.bd-header-announcement {
align-items: center;
background: theme('colors.hub-primary.200') !important;
display: flex;
font-weight: bold;
justify-content: center;
margin-top: 64px;
padding: 16px;
position: relative;
text-align: center;
width: 100%;

font-size: 11px;
@screen screen-495 {
font-size: 14px;
}
}
1 change: 1 addition & 0 deletions src/napari_sphinx_theme/assets/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $grid-breakpoints: (
@import "./api";
@import "./markdown";
@import "./versionmodified";
@import "./announcement";

// Custom css, TODO: to be refactored in different partials
// GitHub blockquote style
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{%- 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 %}
6 changes: 3 additions & 3 deletions src/napari_sphinx_theme/theme/napari_sphinx_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
<body>
{%- endblock %}
{%- block content %}
{# Added to support a banner with an alert #}
<div class="container-fluid" id="banner"></div>

{% block docs_navbar %}
<nav class="navbar navbar-light navbar-expand-lg bg-light fixed-top bd-navbar" id="navbar-main">
{%- include "docs-navbar.html" %}
</nav>
{% endblock %}

{# Added to support a banner with an alert #}
{%- include "announcement.html" -%}

<div class="napari-page">
{% block docs_sidebar %}
{% if sidebars %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ left_sidebar_end = sidebar-ethical-ads.html
footer_items = napari-footer-links.html, napari-copyright.html
page_sidebar_items = page-toc.html, edit-this-page.html
switcher =
announcement =
16 changes: 16 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ module.exports = {
'napari-error': colors.error,
'napari-gray': colors.gray,
'napari-dark-gray': colors.darkGray,

'hub-gray': {
100: '#f7f7f7',
200: '#eaeaea',
300: '#cccccc',
400: '#999999',
500: '#686868',
},

'hub-primary': {
100: '#ecf8ff',
200: '#d2efff',
400: '#80d1ff',
500: '#68c8ff',
600: '#009BF2',
},
},

width: (theme) => ({
Expand Down