From a579ef17d7cb5b50da80535293683d273a9acc9d Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 9 Jan 2024 16:21:27 -0500 Subject: [PATCH] Rename `Shape` to `AvatarShape` (#3986) This PR renames the `Shape` enum to `AvatarShape`, since it seems pretty specific to `Avatar`s. Release Notes: - N/A --- crates/ui/src/components/avatar.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/ui/src/components/avatar.rs b/crates/ui/src/components/avatar.rs index 98a48de6863af8cfd171dd67cee2604b395261f2..cd85d179951339371faa389b76494ff593b88070 100644 --- a/crates/ui/src/components/avatar.rs +++ b/crates/ui/src/components/avatar.rs @@ -1,10 +1,13 @@ use crate::prelude::*; use gpui::{img, Hsla, ImageSource, Img, IntoElement, Styled}; +/// The shape of an [`Avatar`]. #[derive(Debug, Default, PartialEq, Clone)] -pub enum Shape { +pub enum AvatarShape { + /// The avatar is shown in a circle. #[default] Circle, + /// The avatar is shown in a rectangle with rounded corners. RoundedRectangle, } @@ -14,7 +17,7 @@ pub enum Shape { /// /// ``` /// Avatar::new("path/to/image.png") -/// .shape(Shape::Circle) +/// .shape(AvatarShape::Circle) /// .grayscale(true) /// .border_color(cx.theme().colors().border) /// ``` @@ -28,7 +31,7 @@ pub struct Avatar { impl RenderOnce for Avatar { fn render(mut self, cx: &mut WindowContext) -> impl IntoElement { if self.image.style().corner_radii.top_left.is_none() { - self = self.shape(Shape::Circle); + self = self.shape(AvatarShape::Circle); } let size = cx.rem_size(); @@ -84,12 +87,12 @@ impl Avatar { /// # Examples /// /// ``` - /// Avatar::new("path/to/image.png").shape(Shape::Circle); + /// Avatar::new("path/to/image.png").shape(AvatarShape::Circle); /// ``` - pub fn shape(mut self, shape: Shape) -> Self { + pub fn shape(mut self, shape: AvatarShape) -> Self { self.image = match shape { - Shape::Circle => self.image.rounded_full(), - Shape::RoundedRectangle => self.image.rounded_md(), + AvatarShape::Circle => self.image.rounded_full(), + AvatarShape::RoundedRectangle => self.image.rounded_md(), }; self }