-
Notifications
You must be signed in to change notification settings - Fork 12
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
Notification: allow theming #368
Comments
Hi @Cadair 👋🏼 . We don't currently support any other customization of the addons besides the ones that can be done using the WebUI from the new dashboard (https://app.readthedocs.org), under the project's settings and some CSS variables to change the size of it, like We've discussed this topic a lot in #51 and other internal conversations, but we haven't reach to an agreement about how to build it in a way that users can easily customize the web components we expose to users and we can maintain that customization over time without being blocked on adding improvements/features to them. Currently, the only way to to implement the notification addons with a custom position and style to match the style and layout of your theme is implementing the notification by yourself using the data exposed by Read the Docs. This data can be consumed by subscribing to the This is just a quick, dirty and untested example of what I'm describing: document.addEventListener("readthedocs-addons-data-ready", function(event) {
const config = event.detail.data();
let notification;
if (config.versions.current.slug === "latest") {
notification = `
<div>
<div class="title">
This is the <span>latest development version</span>
</div>
<div class="content">
Some features may not yet be available in the published stable version.
Read the <a href="/en/stable/">stable version of this documentation</a>.
</div>
</div>
`;
}
// Inject the generated flyout into the body HTML element.
document.querySelector("[role=main]").insertAdjacentHTML("afterbegin", notification);
}); Let me know your thoughts about this and if this information is useful to you. I'd really appreciate your feedback on this. |
Hi @humitos thanks so much for your response. That approach makes sense, but how would it interact with the default one? Would users of my theme have to disable the original one in RTD settings? I am both looking at dealing with this upstream in pydata and also just quickly in my own theme, so I am trying to figure out the best solutions from all perspectives. I did read through #51 but will have another look with the extra context. |
Yes. Users should be able to decide whether to use the default notification from Read the Docs (unchecking a setting in the WebUI) or the customized one from the theme (e.g. using a theme config like We did this for our own theme and the flyout where we created a |
ok, that makes sense, and reading back through #51 I see how and why it's like that. It feels kind of unsatisfying from the theme developers perspective to have to reimplement the addon, and also from the users perspective to have to config the theme and the addon through the webui. That last point is particularly interesting for SunPy where we have a number of subprojects in RTD and these are all configured via a template, however, we can't template the addons settings so it's on one of us to go into the web ui for everything rather than put it the RTD config file for example. I shall have a crack at writing some js in the pydata theme to display the version notification and see how it feels. Thanks! |
Hello,
I was looking into how I could best integrate the new version notification with our theme (a sub-theme of pydata) and was hoping you could help me, my js skills are not the sharpest.
What options exist for customising the html or the css for the notification popup? Because of the whole shadow DOM setup, it wasn't clear to me the best way to inject my own styling from the "outside", any pointers to get me going would be appreciated.
The text was updated successfully, but these errors were encountered: