Yumush logo (a y whose tail runs on as the line) in the sidebar header, collapsed rail and tray icon, one path source in logo.rs
Browse files at this commit4a7cb7f558dbb86fe1b5be59d62696db589a4340Parent: 612c234- feat
- yumush logo (a y whose tail runs on as the line) in the sidebar header, collapsed rail and tray icon, one path source in logo.rs
- 💄 collapsed rail just fits the avatar
- 🐛 wordmark no longer replays its flip when the sidebar re-expands, community pictures rounded in sidebar and header
7 changed files +125 -31
- crates/client/Cargo.toml +1 -0
- crates/client/src/gui.rs +3 -1
- crates/client/src/gui/sidebar.rs +32 -10
- crates/client/src/lib.rs +1 -0
- crates/client/src/logo.rs +40 -0
- crates/client/src/main.rs +3 -3
- crates/client/src/tray.rs +45 -17
crates/client/Cargo.tomlmodified+1 -0
| @@ -37,6 +37,7 @@ rustls-platform-verifier = "0.7.1" | |||
| 37 | sysinfo = { version = "0.40.4", default-features = false, features = ["system"] } | 37 | sysinfo = { version = "0.40.4", default-features = false, features = ["system"] } |
| 38 | flate2 = "1.1.11" | 38 | flate2 = "1.1.11" |
| 39 | emojis = "0.9.1" | 39 | emojis = "0.9.1" |
| 40 | +resvg = "0.50.0" | ||
| 40 | 41 | ||
| 41 | [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] | 42 | [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] |
| 42 | nokhwa = { version = "0.10.11", default-features = false, features = ["input-native"] } | 43 | nokhwa = { version = "0.10.11", default-features = false, features = ["input-native"] } |
crates/client/src/gui.rsmodified+3 -1
| @@ -336,7 +336,7 @@ pub fn community_icon( | |||
| 336 | .flex_shrink_0() | 336 | .flex_shrink_0() |
| 337 | .rounded(px(radius::SM)) | 337 | .rounded(px(radius::SM)) |
| 338 | .overflow_hidden() | 338 | .overflow_hidden() |
| 339 | - .child(img(image.clone()).size_full()), | 339 | + .child(img(image.clone()).size_full().rounded(px(radius::SM))), |
| 340 | None => { | 340 | None => { |
| 341 | badge(palette, community.id, &community.name, size, font).rounded(px(radius::SM)) | 341 | badge(palette, community.id, &community.name, size, font).rounded(px(radius::SM)) |
| 342 | } | 342 | } |
| @@ -611,6 +611,7 @@ pub struct Yumush { | |||
| 611 | share_apps_seen: std::cell::Cell<Instant>, | 611 | share_apps_seen: std::cell::Cell<Instant>, |
| 612 | share_apps_task: Option<gpui_kit::Task<()>>, | 612 | share_apps_task: Option<gpui_kit::Task<()>>, |
| 613 | wordmark_flips: u32, | 613 | wordmark_flips: u32, |
| 614 | + wordmark_flipped: Option<Instant>, | ||
| 614 | zoom: Option<Rc<Zoom>>, | 615 | zoom: Option<Rc<Zoom>>, |
| 615 | emoji_group: usize, | 616 | emoji_group: usize, |
| 616 | share_tab: common::share::Kind, | 617 | share_tab: common::share::Kind, |
| @@ -683,6 +684,7 @@ impl Yumush { | |||
| 683 | share_apps_seen: std::cell::Cell::new(Instant::now()), | 684 | share_apps_seen: std::cell::Cell::new(Instant::now()), |
| 684 | share_apps_task: None, | 685 | share_apps_task: None, |
| 685 | wordmark_flips: 0, | 686 | wordmark_flips: 0, |
| 687 | + wordmark_flipped: None, | ||
| 686 | zoom: None, | 688 | zoom: None, |
| 687 | emoji_group: 0, | 689 | emoji_group: 0, |
| 688 | share_tab: common::share::Kind::Screen, | 690 | share_tab: common::share::Kind::Screen, |
crates/client/src/gui/sidebar.rsmodified+32 -10
| @@ -32,13 +32,15 @@ use super::{ | |||
| 32 | widget::{bare_input, compact_frame, icon_button}, | 32 | widget::{bare_input, compact_frame, icon_button}, |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | +const RAIL: f32 = size::AVATAR + space::XS * 2.; | ||
| 36 | + | ||
| 35 | impl Yumush { | 37 | impl Yumush { |
| 36 | pub(super) fn sidebar(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement { | 38 | pub(super) fn sidebar(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement { |
| 37 | let collapsed = self.chat.sidebar_collapsed; | 39 | let collapsed = self.chat.sidebar_collapsed; |
| 38 | let (from, to, id) = if collapsed { | 40 | let (from, to, id) = if collapsed { |
| 39 | - (size::SIDEBAR, size::ROW, "sidebar_collapsing") | 41 | + (size::SIDEBAR, RAIL, "sidebar_collapsing") |
| 40 | } else { | 42 | } else { |
| 41 | - (size::ROW, size::SIDEBAR, "sidebar_expanding") | 43 | + (RAIL, size::SIDEBAR, "sidebar_expanding") |
| 42 | }; | 44 | }; |
| 43 | let content = if collapsed { | 45 | let content = if collapsed { |
| 44 | self.collapsed_sidebar(entity, palette).into_any_element() | 46 | self.collapsed_sidebar(entity, palette).into_any_element() |
| @@ -64,13 +66,21 @@ impl Yumush { | |||
| 64 | fn collapsed_sidebar(&self, entity: &Entity<Self>, palette: Palette) -> Div { | 66 | fn collapsed_sidebar(&self, entity: &Entity<Self>, palette: Palette) -> Div { |
| 65 | div() | 67 | div() |
| 66 | .h_full() | 68 | .h_full() |
| 67 | - .w(px(size::ROW)) | 69 | + .w(px(RAIL)) |
| 68 | .flex() | 70 | .flex() |
| 69 | .flex_col() | 71 | .flex_col() |
| 70 | .items_center() | 72 | .items_center() |
| 71 | .justify_between() | 73 | .justify_between() |
| 72 | .py(px(space::MD)) | 74 | .py(px(space::MD)) |
| 73 | - .child(self.collapse_button(entity, palette)) | 75 | + .child( |
| 76 | + div() | ||
| 77 | + .flex() | ||
| 78 | + .flex_col() | ||
| 79 | + .items_center() | ||
| 80 | + .gap(px(space::MD)) | ||
| 81 | + .child(logo_mark(palette)) | ||
| 82 | + .child(self.collapse_button(entity, palette)), | ||
| 83 | + ) | ||
| 74 | .child( | 84 | .child( |
| 75 | div() | 85 | div() |
| 76 | .flex() | 86 | .flex() |
| @@ -119,13 +129,16 @@ impl Yumush { | |||
| 119 | move |_, _, cx| { | 129 | move |_, _, cx| { |
| 120 | entity.update(cx, |yumush, cx| { | 130 | entity.update(cx, |yumush, cx| { |
| 121 | yumush.wordmark_flips += 1; | 131 | yumush.wordmark_flips += 1; |
| 132 | + yumush.wordmark_flipped = Some(std::time::Instant::now()); | ||
| 122 | cx.notify(); | 133 | cx.notify(); |
| 123 | }) | 134 | }) |
| 124 | } | 135 | } |
| 125 | }) | 136 | }) |
| 126 | .flex() | 137 | .flex() |
| 138 | + .items_center() | ||
| 139 | + .child(logo_mark(palette).mr(px(space::XXS))) | ||
| 127 | .child("yumu") | 140 | .child("yumu") |
| 128 | - .child(wordmark_tail(self.wordmark_flips)), | 141 | + .child(wordmark_tail(self.wordmark_flips, self.wordmark_flipped)), |
| 129 | ) | 142 | ) |
| 130 | .child(self.collapse_button(entity, palette)) | 143 | .child(self.collapse_button(entity, palette)) |
| 131 | .child(icon_button( | 144 | .child(icon_button( |
| @@ -1337,7 +1350,15 @@ const CEDILLA_DROP: f32 = 0.45; | |||
| 1337 | const H_SHRINK: f32 = 0.6; | 1350 | const H_SHRINK: f32 = 0.6; |
| 1338 | const MORPH: std::time::Duration = std::time::Duration::from_millis(420); | 1351 | const MORPH: std::time::Duration = std::time::Duration::from_millis(420); |
| 1339 | 1352 | ||
| 1340 | -fn wordmark_tail(flips: u32) -> AnyElement { | 1353 | +fn logo_mark(palette: Palette) -> gpui_kit::Svg { |
| 1354 | + gpui_kit::svg() | ||
| 1355 | + .path(crate::logo::PATH) | ||
| 1356 | + .size(px(size::CHIP)) | ||
| 1357 | + .flex_none() | ||
| 1358 | + .text_color(palette.text) | ||
| 1359 | +} | ||
| 1360 | + | ||
| 1361 | +fn wordmark_tail(flips: u32, flipped: Option<std::time::Instant>) -> AnyElement { | ||
| 1341 | let em = super::style::text::TITLE / super::style::text::UI; | 1362 | let em = super::style::text::TITLE / super::style::text::UI; |
| 1342 | let turkish = flips % 2 == 1; | 1363 | let turkish = flips % 2 == 1; |
| 1343 | let progress = move |delta: f32| if turkish { delta } else { 1. - delta }; | 1364 | let progress = move |delta: f32| if turkish { delta } else { 1. - delta }; |
| @@ -1353,11 +1374,12 @@ fn wordmark_tail(flips: u32) -> AnyElement { | |||
| 1353 | .child("h") | 1374 | .child("h") |
| 1354 | }; | 1375 | }; |
| 1355 | let tail = div().relative(); | 1376 | let tail = div().relative(); |
| 1356 | - if flips == 0 { | 1377 | + if !flipped.is_some_and(|at| at.elapsed() < MORPH) { |
| 1378 | + let p = if turkish { 1. } else { 0. }; | ||
| 1357 | return tail | 1379 | return tail |
| 1358 | - .child(s(0.)) | 1380 | + .child(s(p)) |
| 1359 | - .child(cedilla(0.)) | 1381 | + .child(cedilla(p)) |
| 1360 | - .child(h(0.)) | 1382 | + .child(h(p)) |
| 1361 | .into_any_element(); | 1383 | .into_any_element(); |
| 1362 | } | 1384 | } |
| 1363 | let animation = || gpui_kit::Animation::new(MORPH).with_easing(gpui_kit::ease_in_out); | 1385 | let animation = || gpui_kit::Animation::new(MORPH).with_easing(gpui_kit::ease_in_out); |
crates/client/src/lib.rsmodified+1 -0
| @@ -8,6 +8,7 @@ pub mod avatar; | |||
| 8 | pub mod embed; | 8 | pub mod embed; |
| 9 | pub mod emoji; | 9 | pub mod emoji; |
| 10 | pub mod gui; | 10 | pub mod gui; |
| 11 | +pub mod logo; | ||
| 11 | pub mod marks; | 12 | pub mod marks; |
| 12 | pub mod media; | 13 | pub mod media; |
| 13 | pub mod net; | 14 | pub mod net; |
crates/client/src/logo.rsadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +use std::borrow::Cow; | ||
| 2 | + | ||
| 3 | +use gpui_kit::{AssetSource, SharedString, assets::AllAssets}; | ||
| 4 | + | ||
| 5 | +pub const PATH: &str = "yumush/logo.svg"; | ||
| 6 | + | ||
| 7 | +const MARK: &str = | ||
| 8 | + r#"<path d="M9 6 V12 Q9 18 15 18 Q21 18 21 12 V6"/><path d="M21 12 V21 Q21 27 15 27 H5"/>"#; | ||
| 9 | + | ||
| 10 | +fn svg(background: &str, ink: &str) -> String { | ||
| 11 | + format!( | ||
| 12 | + r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">{background}<g fill="none" stroke="{ink}" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round">{MARK}</g></svg>"# | ||
| 13 | + ) | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +pub fn mark() -> String { | ||
| 17 | + svg("", "#000") | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +pub fn icon() -> String { | ||
| 21 | + svg( | ||
| 22 | + r##"<rect width="32" height="32" rx="8" fill="#121527"/>"##, | ||
| 23 | + "#ece5d8", | ||
| 24 | + ) | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +pub struct Assets; | ||
| 28 | + | ||
| 29 | +impl AssetSource for Assets { | ||
| 30 | + fn load(&self, path: &str) -> gpui_kit::Result<Option<Cow<'static, [u8]>>> { | ||
| 31 | + if path == PATH { | ||
| 32 | + return Ok(Some(Cow::Owned(mark().into_bytes()))); | ||
| 33 | + } | ||
| 34 | + AllAssets.load(path) | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + fn list(&self, path: &str) -> gpui_kit::Result<Vec<SharedString>> { | ||
| 38 | + AllAssets.list(path) | ||
| 39 | + } | ||
| 40 | +} | ||
crates/client/src/main.rsmodified+3 -3
| @@ -11,7 +11,7 @@ use client::{ | |||
| 11 | }; | 11 | }; |
| 12 | use gpui_kit::{ | 12 | use gpui_kit::{ |
| 13 | App, AppContext, Bounds, Entity, QuitMode, TitlebarOptions, Window, WindowBounds, | 13 | App, AppContext, Bounds, Entity, QuitMode, TitlebarOptions, Window, WindowBounds, |
| 14 | - WindowOptions, application, assets::AllAssets, component::Root, px, size, | 14 | + WindowOptions, application, component::Root, px, size, |
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | use tracing::Level; | 17 | use tracing::Level; |
| @@ -45,7 +45,7 @@ fn main() { | |||
| 45 | let (network_handle, network_event_receiver) = net::start(Server::load()); | 45 | let (network_handle, network_event_receiver) = net::start(Server::load()); |
| 46 | 46 | ||
| 47 | application() | 47 | application() |
| 48 | - .with_assets(AllAssets) | 48 | + .with_assets(client::logo::Assets) |
| 49 | .with_quit_mode(QuitMode::Explicit) | 49 | .with_quit_mode(QuitMode::Explicit) |
| 50 | .run(move |cx: &mut App| { | 50 | .run(move |cx: &mut App| { |
| 51 | gui::init(cx); | 51 | gui::init(cx); |
| @@ -95,7 +95,7 @@ fn gallery(spec: String) { | |||
| 95 | return; | 95 | return; |
| 96 | }; | 96 | }; |
| 97 | application() | 97 | application() |
| 98 | - .with_assets(AllAssets) | 98 | + .with_assets(client::logo::Assets) |
| 99 | .run(move |cx: &mut App| { | 99 | .run(move |cx: &mut App| { |
| 100 | gui::init(cx); | 100 | gui::init(cx); |
| 101 | settings::apply(state.theme(), state.font_size(), cx); | 101 | settings::apply(state.theme(), state.font_size(), cx); |
crates/client/src/tray.rsmodified+45 -17
| @@ -67,10 +67,6 @@ impl TrayState { | |||
| 67 | #[cfg(any(target_os = "linux", target_os = "windows"))] | 67 | #[cfg(any(target_os = "linux", target_os = "windows"))] |
| 68 | const ICON_SIZE: i32 = 32; | 68 | const ICON_SIZE: i32 = 32; |
| 69 | #[cfg(any(target_os = "linux", target_os = "windows"))] | 69 | #[cfg(any(target_os = "linux", target_os = "windows"))] |
| 70 | -const ICON_COLOR: [u8; 3] = [0x7c, 0x6c, 0xf2]; | ||
| 71 | -#[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| 72 | -const ICON_DROPS: [(f32, f32, f32); 2] = [(13.0, 18.0, 11.0), (24.0, 9.0, 6.0)]; | ||
| 73 | -#[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| 74 | const BADGE: (f32, f32, f32) = (25.0, 25.0, 7.0); | 70 | const BADGE: (f32, f32, f32) = (25.0, 25.0, 7.0); |
| 75 | #[cfg(any(target_os = "linux", target_os = "windows"))] | 71 | #[cfg(any(target_os = "linux", target_os = "windows"))] |
| 76 | const UNREAD_COLOR: [u8; 3] = [0xe6, 0xe6, 0xe6]; | 72 | const UNREAD_COLOR: [u8; 3] = [0xe6, 0xe6, 0xe6]; |
| @@ -83,6 +79,27 @@ fn coverage(x: f32, y: f32, (cx, cy, radius): (f32, f32, f32)) -> f32 { | |||
| 83 | (radius - distance + 0.5).clamp(0.0, 1.0) | 79 | (radius - distance + 0.5).clamp(0.0, 1.0) |
| 84 | } | 80 | } |
| 85 | 81 | ||
| 82 | +#[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| 83 | +fn logo() -> Vec<([u8; 3], u8)> { | ||
| 84 | + let tree = | ||
| 85 | + resvg::usvg::Tree::from_str(&crate::logo::icon(), &Default::default()).expect("logo svg"); | ||
| 86 | + let mut pixmap = | ||
| 87 | + resvg::tiny_skia::Pixmap::new(ICON_SIZE as u32, ICON_SIZE as u32).expect("icon size"); | ||
| 88 | + resvg::render( | ||
| 89 | + &tree, | ||
| 90 | + resvg::tiny_skia::Transform::default(), | ||
| 91 | + &mut pixmap.as_mut(), | ||
| 92 | + ); | ||
| 93 | + pixmap | ||
| 94 | + .pixels() | ||
| 95 | + .iter() | ||
| 96 | + .map(|pixel| { | ||
| 97 | + let color = pixel.demultiply(); | ||
| 98 | + ([color.red(), color.green(), color.blue()], color.alpha()) | ||
| 99 | + }) | ||
| 100 | + .collect() | ||
| 101 | +} | ||
| 102 | + | ||
| 86 | #[cfg(any(target_os = "linux", target_os = "windows"))] | 103 | #[cfg(any(target_os = "linux", target_os = "windows"))] |
| 87 | fn pixels(badge: Badge) -> impl Iterator<Item = ([u8; 3], u8)> { | 104 | fn pixels(badge: Badge) -> impl Iterator<Item = ([u8; 3], u8)> { |
| 88 | let dot = match badge { | 105 | let dot = match badge { |
| @@ -90,19 +107,16 @@ fn pixels(badge: Badge) -> impl Iterator<Item = ([u8; 3], u8)> { | |||
| 90 | Badge::Unread => Some(UNREAD_COLOR), | 107 | Badge::Unread => Some(UNREAD_COLOR), |
| 91 | Badge::Mention => Some(MENTION_COLOR), | 108 | Badge::Mention => Some(MENTION_COLOR), |
| 92 | }; | 109 | }; |
| 93 | - (0..ICON_SIZE * ICON_SIZE).map(move |index| { | 110 | + logo().into_iter().enumerate().map(move |(index, base)| { |
| 94 | - let x = (index % ICON_SIZE) as f32 + 0.5; | 111 | + let x = (index as i32 % ICON_SIZE) as f32 + 0.5; |
| 95 | - let y = (index / ICON_SIZE) as f32 + 0.5; | 112 | + let y = (index as i32 / ICON_SIZE) as f32 + 0.5; |
| 96 | - let base = ICON_DROPS | 113 | + match dot { |
| 97 | - .iter() | 114 | + Some(color) if coverage(x, y, BADGE) > 0.0 => { |
| 98 | - .map(|drop| coverage(x, y, *drop)) | 115 | + (color, (coverage(x, y, BADGE) * 255.0) as u8) |
| 99 | - .fold(0.0, f32::max); | 116 | + } |
| 100 | - let (color, alpha) = match dot { | 117 | + Some(_) if coverage(x, y, (BADGE.0, BADGE.1, BADGE.2 + 2.0)) > 0.0 => (base.0, 0), |
| 101 | - Some(color) if coverage(x, y, BADGE) > 0.0 => (color, coverage(x, y, BADGE)), | 118 | + _ => base, |
| 102 | - Some(_) if coverage(x, y, (BADGE.0, BADGE.1, BADGE.2 + 2.0)) > 0.0 => (ICON_COLOR, 0.0), | 119 | + } |
| 103 | - _ => (ICON_COLOR, base), | ||
| 104 | - }; | ||
| 105 | - (color, (alpha * 255.0) as u8) | ||
| 106 | }) | 120 | }) |
| 107 | } | 121 | } |
| 108 | 122 | ||
| @@ -294,3 +308,17 @@ mod windows { | |||
| 294 | (receiver, handle) | 308 | (receiver, handle) |
| 295 | } | 309 | } |
| 296 | } | 310 | } |
| 311 | + | ||
| 312 | +#[cfg(all(test, any(target_os = "linux", target_os = "windows")))] | ||
| 313 | +mod tests { | ||
| 314 | + #[test] | ||
| 315 | + fn logo_renders() { | ||
| 316 | + let pixels = super::logo(); | ||
| 317 | + assert_eq!(pixels.len(), (super::ICON_SIZE * super::ICON_SIZE) as usize); | ||
| 318 | + assert!( | ||
| 319 | + pixels | ||
| 320 | + .iter() | ||
| 321 | + .any(|(color, alpha)| *alpha == 255 && color[0] > 200) | ||
| 322 | + ); | ||
| 323 | + } | ||
| 324 | +} | ||