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

Feature request: add an annoucement bar #1190

Closed
Ir1d opened this issue Jul 25, 2019 · 11 comments
Closed

Feature request: add an annoucement bar #1190

Ir1d opened this issue Jul 25, 2019 · 11 comments
Labels
change request Issue requests a new feature or improvement

Comments

@Ir1d
Copy link

Ir1d commented Jul 25, 2019

Sometimes you want to announce something in your website. For example: “We are looking to revamp our docs, please fill this survey”.

The announcement bar is dismissable and render above the nav bar.

Or maybe something like popups or alerts showing up at up-right corner might also be a good idea.

@squidfunk
Copy link
Owner

squidfunk commented Jul 25, 2019

That's a nice idea. It could theoretically be implemented with the metadata extension, but dismissing would need to be implemented with a cookie or local storage. If somebody wants to go ahead on this and implement a prototype, feel free to do so. If it works reasonably well, we can integrate it into Material. Unfortunately, I don't have any time for this at the moment.

@squidfunk squidfunk added the change request Issue requests a new feature or improvement label Jul 25, 2019
@urna
Copy link

urna commented Aug 27, 2019

yes, also think this would be useful.

@Ir1d
Copy link
Author

Ir1d commented Oct 4, 2019

We have an ugly workaround, posting here in case someone else might need it.

https://github.com/OI-wiki/mkdocs-material/compare/40794bbff7a27a563677274091ed8f706592cd18..24c05b4ba1eb5536bd7818913560394429d035ae

demo at https://oi-wiki.org

@squidfunk squidfunk mentioned this issue Oct 14, 2019
53 tasks
@squidfunk
Copy link
Owner

squidfunk commented Dec 19, 2019

In case somebody wants this feature, I could use some help here. A great starting point would be a proposal how this announcement bar should behave. Some questions to anwer:

  • Should it be above the header? Overlay the header?
  • What about mobile?
  • Is HTML content allowed?
  • Should it stretch?
  • Which color should it have? Accent? Primary?

Maybe also provide some mockups and some ideas how this could be integrated/used from a user perspective. I really want to release it as part of v5 as I think this is a nice feature.

@Stanzilla
Copy link
Contributor

I kinda abused the hero feature for that

@pawamoy
Copy link
Contributor

pawamoy commented Dec 31, 2019

You can get inspiration from the Django docs for example: on https://docs.djangoproject.com/en/dev/ and https://docs.djangoproject.com/en/1.7/. But maybe this is more a "banner" than an annoucement bar?

  • it is above the header (though having it below on this theme seems good as well)
  • it stretches

A few remarks:

  • it should be clearly visible as users may put important information in it, so not the same color as the header
  • the user should be able to pick the color, depending on the contents of the announcement (like admonitions? warning-yellow, danger-red, etc.)
  • it should not always be dismissible (or not at all dismissible from my point of view, but I understand the need for other use-cases)
  • being able to put at least links into it could be nice (example: link to another page with more detailed information about the announcement, external link to a survey, etc.), with HTML/Markdown, or simply text URLs that are made clickable
  • it should be configurable globally or per page
  • it should appear on mobile as well

@squidfunk
Copy link
Owner

@pawamoy thanks for your ideas.

My initial idea was to implement it with front matter which supports HTML content but we could also try and prototype something using template blocks. Defining an announcement bar would have to be done using theme extension but I guess that might be the best idea in order to cater to many use cases anyway. I'm unsure about the color customization, as I don't want to introduce more and more options to the mkdocs.yml, so maybe we just use the accent color as a default and make it easily overridable via CSS.

I'm also not quite sure whether the DX is gonna be good enough, as an announcement bar is kind of a cross-cutting piece of content. Some people may only want to have it on the front page, some on other pages, some think it should be dismissible (for how long?). We we're discussing a new section in the docs called "Recipes" (or something similar) where we could list some common theme extension use cases, so maybe the whole announcement bar story should go into there.

@squidfunk
Copy link
Owner

squidfunk commented Jan 25, 2020

I think I've found a good way to implement this feature. The header is now positioned with sticky instead of fixed which means it will lock into place when the announcement bar is scrolled past. Note that the bar is only visible at the top of the page. Personally, I think that's good UX, because it doesn't limit the available screen on mobile, and thus is rather unobtrusive.

Demo:

Announcement bar

It's implemented as a template block, so in order to set content the main template needs to be extended. Using theme extension gives ultimate flexibility, so users can put anything in there, buttons, links, etc. This is very simple:

{% extends "base.html" %}

{% block announcement %}
  The quick brown fox jumpy over the lazy dog
{% endblock %}

This is a POC implementation and thus an experimental feature, there's currently no possibility to dismiss the bar. The implementation is part of the refactoring branch and will be released with Material v5.

@Stanzilla
Copy link
Contributor

I like it! I think I switched my header to sticky in my fork as well

@pawamoy
Copy link
Contributor

pawamoy commented Jan 28, 2020

This looks great 🙂
Looking forward to try v5!

@squidfunk squidfunk mentioned this issue Feb 18, 2020
6 tasks
@squidfunk
Copy link
Owner

Material for MkDocs 5.0.0rc1 is out which fixes this issue 😀 Let's test and improve it together!

The announcement bar can be added with simple theme extension, see:

{% block announce %}
Material for MkDocs 5.0.0rc1
{% endblock %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement
Projects
None yet
Development

No branches or pull requests

5 participants