Merge branch 'main' into completions-styles

This commit is contained in:
Nate Butler
2023-11-27 19:22:07 -05:00
47 changed files with 1167 additions and 666 deletions
+12 -4
View File
@@ -1,5 +1,7 @@
use std::sync::Arc;
use crate::prelude::*;
use gpui::{img, Img, IntoElement};
use gpui::{img, ImageData, ImageSource, Img, IntoElement};
#[derive(Debug, Default, PartialEq, Clone)]
pub enum Shape {
@@ -10,7 +12,7 @@ pub enum Shape {
#[derive(IntoElement)]
pub struct Avatar {
src: SharedString,
src: ImageSource,
shape: Shape,
}
@@ -26,7 +28,7 @@ impl RenderOnce for Avatar {
img = img.rounded_md();
}
img.uri(self.src.clone())
img.source(self.src.clone())
.size_4()
// todo!(Pull the avatar fallback background from the theme.)
.bg(gpui::red())
@@ -34,7 +36,13 @@ impl RenderOnce for Avatar {
}
impl Avatar {
pub fn new(src: impl Into<SharedString>) -> Self {
pub fn uri(src: impl Into<SharedString>) -> Self {
Self {
src: src.into().into(),
shape: Shape::Circle,
}
}
pub fn data(src: Arc<ImageData>) -> Self {
Self {
src: src.into(),
shape: Shape::Circle,
+2 -2
View File
@@ -323,8 +323,8 @@ impl RenderOnce for ListItem {
.color(Color::Muted),
),
),
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
Some(GraphicSlot::PublicActor(src)) => Some(h_stack().child(Avatar::new(src))),
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::uri(src))),
Some(GraphicSlot::PublicActor(src)) => Some(h_stack().child(Avatar::uri(src))),
None => None,
};
+2
View File
@@ -6,6 +6,7 @@ mod icon;
mod input;
mod keybinding;
mod label;
mod list_item;
pub use avatar::*;
pub use button::*;
@@ -15,3 +16,4 @@ pub use icon::*;
pub use input::*;
pub use keybinding::*;
pub use label::*;
pub use list_item::*;
+2 -2
View File
@@ -13,10 +13,10 @@ impl Render for AvatarStory {
Story::container()
.child(Story::title_for::<Avatar>())
.child(Story::label("Default"))
.child(Avatar::new(
.child(Avatar::uri(
"https://avatars.githubusercontent.com/u/1714999?v=4",
))
.child(Avatar::new(
.child(Avatar::uri(
"https://avatars.githubusercontent.com/u/326587?v=4",
))
}
@@ -0,0 +1,26 @@
use gpui::{Div, Render};
use story::Story;
use crate::prelude::*;
use crate::ListItem;
pub struct ListItemStory;
impl Render for ListItemStory {
type Element = Div;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container()
.child(Story::title_for::<ListItem>())
.child(Story::label("Default"))
.child(ListItem::new("hello_world").child("Hello, world!"))
.child(Story::label("With `on_click`"))
.child(
ListItem::new("with_on_click")
.child("Click me")
.on_click(|_event, _cx| {
println!("Clicked!");
}),
)
}
}