-
Notifications
You must be signed in to change notification settings - Fork 224
Add base for alert support #3300
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| (function() { | ||
| const alertCheckbox = document.getElementById("docsrs-alert-input"); | ||
| alertCheckbox.onchange = () => { | ||
| // If the user clicks on the "close button", we save this info in their local storage. | ||
| window.localStorage.setItem("hide-alert-id", alertCheckbox.getAttribute("data-id")); | ||
| }; | ||
|
|
||
| const info = window.localStorage.getItem("hide-alert-id"); | ||
| if (info !== null) { | ||
| const alertId = alertCheckbox.getAttribute("data-id"); | ||
| // If the user already "closed" the alert, we don't show it anymore. | ||
| if (alertId === info) { | ||
| alertCheckbox.checked = true; | ||
| } | ||
| } | ||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,3 +123,15 @@ | |
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {%- if let Some((alert, alert_id)) = crate::get_alert() -%} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO: many people reach docs.rs via search, or crates.io right now I can only see the alert on the homepage. I would expect it to show on all pages?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's on all pages for me. Did you close it by any chance? |
||
| <input type="checkbox" id="docsrs-alert-input" data-id={{alert_id|safe}}> | ||
| <label id="docsrs-alert-hide" for="docsrs-alert-input" title="Close alert message"> | ||
| {{- crate::icons::IconXmark.render_solid(false, false, "") -}} | ||
| </label> | ||
| <div id="docsrs-alert"> | ||
| {{- crate::icons::IconCircleInfo.render_solid(false, false, "") -}} | ||
| <span class="alert-text">{{- alert|safe -}}</span> | ||
| </div> | ||
| <script type="text/javascript">{%- include "alert.js" -%}</script> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we probably should expose <script async src="/-/static/menu.js?{{ build_slug }}"></script> |
||
| {%- endif -%} | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi:
I prepared parts of #3274 so we can include the alerts in that caching pipeline. When #3274 is merged etc I'm happy to update this PR to do it.
View changes since the review