From fac029b80867a65bf2c45fbf6025b2780b7a91e3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 30 Nov 2023 12:08:00 +0100 Subject: [PATCH] Fix errors in theme2 --- crates/gpui2/src/elements/img.rs | 12 +++ crates/theme2/src/styles/stories/players.rs | 92 ++++++++++++--------- 2 files changed, 63 insertions(+), 41 deletions(-) diff --git a/crates/gpui2/src/elements/img.rs b/crates/gpui2/src/elements/img.rs index e519a93e64d5205bd70b2c5f08458ab5a5180c28..f6aae2de66aebb7bc894bd63a8d9a85a6e74e089 100644 --- a/crates/gpui2/src/elements/img.rs +++ b/crates/gpui2/src/elements/img.rs @@ -23,6 +23,18 @@ impl From for ImageSource { } } +impl From<&'static str> for ImageSource { + fn from(uri: &'static str) -> Self { + Self::Uri(uri.into()) + } +} + +impl From for ImageSource { + fn from(uri: String) -> Self { + Self::Uri(uri.into()) + } +} + impl From> for ImageSource { fn from(value: Arc) -> Self { Self::Data(value) diff --git a/crates/theme2/src/styles/stories/players.rs b/crates/theme2/src/styles/stories/players.rs index d189d3bfb07bb0efc4691ca14abac4d94948d620..237f2f10817872ea07c0f7fafa5745ee8722cf13 100644 --- a/crates/theme2/src/styles/stories/players.rs +++ b/crates/theme2/src/styles/stories/players.rs @@ -55,9 +55,8 @@ impl Render for PlayerStory { .border_2() .border_color(player.cursor) .child( - img() + img("https://avatars.githubusercontent.com/u/1714999?v=4") .rounded_full() - .uri("https://avatars.githubusercontent.com/u/1714999?v=4") .size_6() .bg(gpui::red()), ) @@ -67,51 +66,62 @@ impl Render for PlayerStory { .child(div().flex().gap_1().children( cx.theme().players().0.clone().iter_mut().map(|player| { div() - .my_1() - .rounded_xl() - .flex() - .items_center() - .h_8() - .py_0p5() - .px_1p5() - .bg(player.background) - .child( - div().relative().neg_mx_1().rounded_full().z_index(3) + .my_1() + .rounded_xl() + .flex() + .items_center() + .h_8() + .py_0p5() + .px_1p5() + .bg(player.background) + .child( + div() + .relative() + .neg_mx_1() + .rounded_full() + .z_index(3) .border_2() .border_color(player.background) .size(px(28.)) .child( - img() - .rounded_full() - .uri("https://avatars.githubusercontent.com/u/1714999?v=4") - .size(px(24.)) - .bg(gpui::red()), - ), - ).child( - div().relative().neg_mx_1().rounded_full().z_index(2) - .border_2() - .border_color(player.background) - .size(px(28.)) - .child( - img() + img("https://avatars.githubusercontent.com/u/1714999?v=4") + .rounded_full() + .size(px(24.)) + .bg(gpui::red()), + ), + ) + .child( + div() + .relative() + .neg_mx_1() .rounded_full() - .uri("https://avatars.githubusercontent.com/u/1714999?v=4") - .size(px(24.)) - .bg(gpui::red()), - ), - ).child( - div().relative().neg_mx_1().rounded_full().z_index(1) - .border_2() - .border_color(player.background) - .size(px(28.)) + .z_index(2) + .border_2() + .border_color(player.background) + .size(px(28.)) + .child( + img("https://avatars.githubusercontent.com/u/1714999?v=4") + .rounded_full() + .size(px(24.)) + .bg(gpui::red()), + ), + ) .child( - img() - .rounded_full() - .uri("https://avatars.githubusercontent.com/u/1714999?v=4") - .size(px(24.)) - .bg(gpui::red()), - ), - ) + div() + .relative() + .neg_mx_1() + .rounded_full() + .z_index(1) + .border_2() + .border_color(player.background) + .size(px(28.)) + .child( + img("https://avatars.githubusercontent.com/u/1714999?v=4") + .rounded_full() + .size(px(24.)) + .bg(gpui::red()), + ), + ) }), )) .child(Story::label("Player Selections"))