Skip to content

Commit

Permalink
improve global alert configurability and turn it red
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Sep 16, 2019
1 parent c07f340 commit b4e734e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ use web::page::GlobalAlert;
pub(crate) static GLOBAL_ALERT: Option<GlobalAlert> = Some(GlobalAlert {
url: "https://blog.rust-lang.org/2019/09/18/upcoming-docsrs-changes.html",
text: "Upcoming docs.rs breaking changes!",
css_class: "error",
fa_icon: "warning",
});


Expand Down
4 changes: 4 additions & 0 deletions src/web/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ use handlebars_iron::Template;
pub(crate) struct GlobalAlert {
pub(crate) url: &'static str,
pub(crate) text: &'static str,
pub(crate) css_class: &'static str,
pub(crate) fa_icon: &'static str,
}

impl ToJson for GlobalAlert {
fn to_json(&self) -> Json {
let mut map = BTreeMap::new();
map.insert("url".to_string(), self.url.to_json());
map.insert("text".to_string(), self.text.to_json());
map.insert("css_class".to_string(), self.css_class.to_json());
map.insert("fa_icon".to_string(), self.fa_icon.to_json());
Json::Object(map)
}
}
Expand Down
5 changes: 2 additions & 3 deletions templates/navigation_global_alert.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{{#if ../has_global_alert}}
<li class="pure-menu-item">
<a href="{{../global_alert.url}}" class="pure-menu-link warn">
<i class="fa fa-fw fa-warning"></i>
<a href="{{../global_alert.url}}" class="pure-menu-link {{../global_alert.css_class}}">
<i class="fa fa-fw fa-{{../global_alert.fa_icon}}"></i>
{{../global_alert.text}}
<i class="fa fa-fw fa-warning"></i>
</a>
</li>
{{/if}}
Expand Down
10 changes: 10 additions & 0 deletions templates/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $color-lifetime-incode: #B76514; // orangish
$color-comment-in-code: #8E908C; // light gray
$color-background-code: #F5F5F5; // lighter gray
$color-border: #ddd; // gray
$color-red: #d93d3d; // red
$top-navbar-height: 32px; // height of the floating top navbar


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

// used for global alerts
.error {
color: $color-red;

&:hover {
color: darken($color-red, 10%);
}
}

div.rustdoc-navigation {
span.title {
display: none;
Expand Down

0 comments on commit b4e734e

Please sign in to comment.