Remove additional wrapping elements in the chat panel (#14013)

This PR removes some wrapping elements that were used inside of the chat
panel.

To facilitate this, the `Label` component now has a `weight` method to
change the font weight.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-09 15:27:37 -04:00 committed by GitHub
parent df935df5a3
commit c6b9f1920f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 26 deletions

View file

@ -1,6 +1,6 @@
use std::ops::Range;
use gpui::{HighlightStyle, StyledText};
use gpui::{FontWeight, HighlightStyle, StyledText};
use crate::{prelude::*, LabelCommon, LabelLike, LabelSize, LineHeightStyle};
@ -29,6 +29,11 @@ impl LabelCommon for HighlightedLabel {
self
}
fn weight(mut self, weight: FontWeight) -> Self {
self.base = self.base.weight(weight);
self
}
fn line_height_style(mut self, line_height_style: LineHeightStyle) -> Self {
self.base = self.base.line_height_style(line_height_style);
self

View file

@ -85,6 +85,11 @@ impl LabelCommon for Label {
self
}
fn weight(mut self, weight: gpui::FontWeight) -> Self {
self.base = self.base.weight(weight);
self
}
/// Sets the line height style of the label using a [`LineHeightStyle`].
///
/// # Examples

View file

@ -1,4 +1,4 @@
use gpui::{relative, AnyElement, Styled};
use gpui::{relative, AnyElement, FontWeight, Styled};
use smallvec::SmallVec;
use crate::prelude::*;
@ -25,6 +25,9 @@ pub trait LabelCommon {
/// Sets the size of the label using a [`LabelSize`].
fn size(self, size: LabelSize) -> Self;
/// Sets the font weight of the label.
fn weight(self, weight: FontWeight) -> Self;
/// Sets the line height style of the label using a [`LineHeightStyle`].
fn line_height_style(self, line_height_style: LineHeightStyle) -> Self;
@ -41,6 +44,7 @@ pub trait LabelCommon {
#[derive(IntoElement)]
pub struct LabelLike {
size: LabelSize,
weight: FontWeight,
line_height_style: LineHeightStyle,
pub(crate) color: Color,
strikethrough: bool,
@ -52,6 +56,7 @@ impl LabelLike {
pub fn new() -> Self {
Self {
size: LabelSize::Default,
weight: FontWeight::default(),
line_height_style: LineHeightStyle::default(),
color: Color::Default,
strikethrough: false,
@ -67,6 +72,11 @@ impl LabelCommon for LabelLike {
self
}
fn weight(mut self, weight: FontWeight) -> Self {
self.weight = weight;
self
}
fn line_height_style(mut self, line_height_style: LineHeightStyle) -> Self {
self.line_height_style = line_height_style;
self
@ -118,6 +128,7 @@ impl RenderOnce for LabelLike {
})
.when(self.italic, |this| this.italic())
.text_color(self.color.color(cx))
.font_weight(self.weight)
.children(self.children)
}
}