Compare commits

..

3 Commits

Author SHA1 Message Date
e7cbf9cc45 shared: remove debug logging 2024-09-19 13:54:47 -07:00
5108213af5 web: use shared compute_color 2024-09-19 13:49:24 -07:00
d148f625ac shared: add compute_color 2024-09-19 13:48:56 -07:00
2 changed files with 8 additions and 6 deletions

View File

@ -1,3 +1,5 @@
use std::hash::{DefaultHasher, Hash, Hasher};
use build_info::{BuildInfo, VersionControl}; use build_info::{BuildInfo, VersionControl};
use notmuch::SearchSummary; use notmuch::SearchSummary;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -49,3 +51,8 @@ pub fn build_version(bi: fn() -> &'static BuildInfo) -> String {
format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string() format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string()
} }
pub fn compute_color(data: &str) -> String {
let mut hasher = DefaultHasher::new();
data.hash(&mut hasher);
format!("#{:06x}", hasher.finish() % (1 << 24))
}

View File

@ -9,6 +9,7 @@ use itertools::Itertools;
use log::{debug, error, info}; use log::{debug, error, info};
use seed::{prelude::*, *}; use seed::{prelude::*, *};
use seed_hooks::{state_access::CloneState, topo, use_state}; use seed_hooks::{state_access::CloneState, topo, use_state};
use shared::compute_color;
use web_sys::HtmlElement; use web_sys::HtmlElement;
use crate::{ use crate::{
@ -29,12 +30,6 @@ fn set_title(title: &str) {
seed::document().set_title(&format!("lb: {}", title)); seed::document().set_title(&format!("lb: {}", title));
} }
fn compute_color(data: &str) -> String {
let mut hasher = DefaultHasher::new();
data.hash(&mut hasher);
format!("#{:06x}", hasher.finish() % (1 << 24))
}
fn tags_chiclet(tags: &[String], is_mobile: bool) -> impl Iterator<Item = Node<Msg>> + '_ { fn tags_chiclet(tags: &[String], is_mobile: bool) -> impl Iterator<Item = Node<Msg>> + '_ {
tags.iter().map(move |tag| { tags.iter().map(move |tag| {
let hex = compute_color(tag); let hex = compute_color(tag);