summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-08-08 16:32:21 -0600
committerColin Reeder <colin@vpzom.click>2020-08-08 16:32:21 -0600
commit649d33ca68889669d62817765bf8d6a3441b6949 (patch)
tree2c6ef5db952b3a08112a3e62320ad502324250b3 /src
parent643eb3ca33122b094c30d4503b20e8e4d7069345 (diff)
Use SVG icons instead of emoji
Diffstat (limited to 'src')
-rw-r--r--src/components/mod.rs23
-rw-r--r--src/routes/static.rs9
2 files changed, 29 insertions, 3 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index e3cd604..9527972 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -226,11 +226,18 @@ pub fn HTPage<'a, Children: render::Render>(
<>
<a
href={"/notifications"}
- class={if login.user.has_unread_notifications { "notification-indicator unread" } else { "notification-indicator" }}
>
- {"🔔︎"}
+ {
+ if login.user.has_unread_notifications {
+ hitide_icons::NOTIFICATIONS_SOME.img()
+ } else {
+ hitide_icons::NOTIFICATIONS.img()
+ }
+ }
+ </a>
+ <a href={format!("/users/{}", login.user.id)}>
+ {hitide_icons::PERSON.img()}
</a>
- <a href={format!("/users/{}", login.user.id)}>{"👤︎"}</a>
</>
})
} else {
@@ -501,3 +508,13 @@ impl<'a> render::Render for NotificationItem<'a> {
write!(writer, "</li>")
}
}
+
+trait IconExt {
+ fn img(&self) -> render::SimpleElement<()>;
+}
+
+impl IconExt for hitide_icons::Icon {
+ fn img(&self) -> render::SimpleElement<()> {
+ render::rsx! { <img src={format!("/static/{}", self.path)} class={"icon"} /> }
+ }
+}
diff --git a/src/routes/static.rs b/src/routes/static.rs
index 60a0084..d319efe 100644
--- a/src/routes/static.rs
+++ b/src/routes/static.rs
@@ -1,3 +1,4 @@
+use hitide_icons::ICONS_MAP;
use std::sync::Arc;
const FILE_MAIN_CSS: &[u8] = include_bytes!("../../res/main.css");
@@ -20,6 +21,14 @@ async fn handler_static_get(
);
Ok(resp)
+ } else if let Some(icon) = ICONS_MAP.get(params.0.as_str()) {
+ let mut resp = hyper::Response::new(icon.content.into());
+ resp.headers_mut().insert(
+ hyper::header::CONTENT_TYPE,
+ hyper::header::HeaderValue::from_static("image/svg+xml"),
+ );
+
+ Ok(resp)
} else {
Err(crate::Error::RoutingError(trout::RoutingFailure::NotFound))
}