Skip to content

Commit b4e734e

Browse files
committed
improve global alert configurability and turn it red
1 parent c07f340 commit b4e734e

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ use web::page::GlobalAlert;
6060
pub(crate) static GLOBAL_ALERT: Option<GlobalAlert> = Some(GlobalAlert {
6161
url: "https://blog.rust-lang.org/2019/09/18/upcoming-docsrs-changes.html",
6262
text: "Upcoming docs.rs breaking changes!",
63+
css_class: "error",
64+
fa_icon: "warning",
6365
});
6466

6567

src/web/page.rs

+4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ use handlebars_iron::Template;
1010
pub(crate) struct GlobalAlert {
1111
pub(crate) url: &'static str,
1212
pub(crate) text: &'static str,
13+
pub(crate) css_class: &'static str,
14+
pub(crate) fa_icon: &'static str,
1315
}
1416

1517
impl ToJson for GlobalAlert {
1618
fn to_json(&self) -> Json {
1719
let mut map = BTreeMap::new();
1820
map.insert("url".to_string(), self.url.to_json());
1921
map.insert("text".to_string(), self.text.to_json());
22+
map.insert("css_class".to_string(), self.css_class.to_json());
23+
map.insert("fa_icon".to_string(), self.fa_icon.to_json());
2024
Json::Object(map)
2125
}
2226
}

templates/navigation_global_alert.hbs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{{#if ../has_global_alert}}
22
<li class="pure-menu-item">
3-
<a href="{{../global_alert.url}}" class="pure-menu-link warn">
4-
<i class="fa fa-fw fa-warning"></i>
3+
<a href="{{../global_alert.url}}" class="pure-menu-link {{../global_alert.css_class}}">
4+
<i class="fa fa-fw fa-{{../global_alert.fa_icon}}"></i>
55
{{../global_alert.text}}
6-
<i class="fa fa-fw fa-warning"></i>
76
</a>
87
</li>
98
{{/if}}

templates/style.scss

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ $color-lifetime-incode: #B76514; // orangish
1919
$color-comment-in-code: #8E908C; // light gray
2020
$color-background-code: #F5F5F5; // lighter gray
2121
$color-border: #ddd; // gray
22+
$color-red: #d93d3d; // red
2223
$top-navbar-height: 32px; // height of the floating top navbar
2324

2425

@@ -214,6 +215,15 @@ div.nav-container {
214215
color: darken($color-type, 10%);
215216
}
216217

218+
// used for global alerts
219+
.error {
220+
color: $color-red;
221+
222+
&:hover {
223+
color: darken($color-red, 10%);
224+
}
225+
}
226+
217227
div.rustdoc-navigation {
218228
span.title {
219229
display: none;

0 commit comments

Comments
 (0)