-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Comments
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. |
yes, also think this would be useful. |
We have an ugly workaround, posting here in case someone else might need it. demo at https://oi-wiki.org |
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:
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. |
I kinda abused the hero feature for that |
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?
A few remarks:
|
@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 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. |
I think I've found a good way to implement this feature. The header is now positioned with Demo: 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. |
I like it! I think I switched my header to sticky in my fork as well |
This looks great 🙂 |
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: mkdocs-material/src/overrides/home.html Lines 25 to 27 in 7798748
|
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.
The text was updated successfully, but these errors were encountered: