commit
2e00da5a79
24 changed files with 874 additions and 1098 deletions
|
@ -1,6 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use gpui::{img, Div, Hsla, ImageData, ImageSource, Img, IntoElement, Styled};
|
||||
use std::sync::Arc;
|
||||
use gpui::{img, Div, Hsla, ImageSource, Img, IntoElement, Styled};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Clone)]
|
||||
pub enum Shape {
|
||||
|
@ -58,16 +57,8 @@ impl RenderOnce for Avatar {
|
|||
}
|
||||
|
||||
impl Avatar {
|
||||
pub fn uri(src: impl Into<SharedString>) -> Self {
|
||||
Self::source(src.into().into())
|
||||
}
|
||||
|
||||
pub fn data(src: Arc<ImageData>) -> Self {
|
||||
Self::source(src.into())
|
||||
}
|
||||
|
||||
pub fn source(src: ImageSource) -> Self {
|
||||
Self {
|
||||
pub fn new(src: impl Into<ImageSource>) -> Self {
|
||||
Avatar {
|
||||
image: img(src),
|
||||
is_available: None,
|
||||
border_color: None,
|
||||
|
|
|
@ -111,7 +111,7 @@ impl ListItem {
|
|||
}
|
||||
|
||||
pub fn left_avatar(mut self, left_avatar: impl Into<ImageSource>) -> Self {
|
||||
self.left_slot = Some(Avatar::source(left_avatar.into()).into_any_element());
|
||||
self.left_slot = Some(Avatar::new(left_avatar).into_any_element());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,18 @@ impl Render for AvatarStory {
|
|||
Story::container()
|
||||
.child(Story::title_for::<Avatar>())
|
||||
.child(Story::label("Default"))
|
||||
.child(Avatar::uri(
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||
))
|
||||
.child(Avatar::uri(
|
||||
.child(Avatar::new(
|
||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||
))
|
||||
.child(
|
||||
Avatar::uri("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.availability_indicator(true),
|
||||
)
|
||||
.child(
|
||||
Avatar::uri("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
Avatar::new("https://avatars.githubusercontent.com/u/326587?v=4")
|
||||
.availability_indicator(false),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue