- Fix color picker hover preview color to shrink_0.
- Fix Divider display.
This commit is contained in:
Jason Lee 2024-09-09 22:05:02 +08:00 committed by GitHub
parent 840a54850a
commit 74abc339b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 17 deletions

View file

@ -297,15 +297,17 @@ impl Render for StoryContainer {
.overflow_scroll() .overflow_scroll()
.track_focus(&self.focus_handle) .track_focus(&self.focus_handle)
.on_action(cx.listener(Self::on_action_panel_info)) .on_action(cx.listener(Self::on_action_panel_info))
.child( .when(self.description.len() > 0, |this| {
div() this.child(
.flex() div()
.flex_col() .flex()
.gap_4() .flex_col()
.p_4() .gap_4()
.child(Label::new(self.description.clone()).text_size(px(16.0))) .p_4()
.child(Divider::horizontal().label("This is a divider")), .child(Label::new(self.description.clone()).text_size(px(16.0)))
) .child(Divider::horizontal().label("This is a divider")),
)
})
.when_some(self.story.clone(), |this, story| { .when_some(self.story.clone(), |this, story| {
this.child( this.child(
v_flex() v_flex()

View file

@ -248,6 +248,7 @@ impl ColorPicker {
.child( .child(
div() div()
.bg(hovered_color) .bg(hovered_color)
.flex_shrink_0()
.border_1() .border_1()
.border_color(hovered_color.darken(0.2)) .border_color(hovered_color.darken(0.2))
.size_5() .size_5()

View file

@ -1,8 +1,9 @@
use gpui::{div, prelude::FluentBuilder as _, RenderOnce}; use gpui::{
use gpui::{Axis, Div, IntoElement, ParentElement, SharedString, Styled}; div, prelude::FluentBuilder as _, px, Axis, Div, IntoElement, ParentElement, RenderOnce,
SharedString, Styled,
};
use crate::theme::ActiveTheme; use crate::theme::ActiveTheme;
use crate::StyledExt as _;
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct Divider { pub struct Divider {
@ -45,18 +46,22 @@ impl RenderOnce for Divider {
let theme = cx.theme(); let theme = cx.theme();
self.base self.base
.flex()
.flex_shrink_0()
.items_center()
.justify_center()
.map(|this| match self.axis { .map(|this| match self.axis {
Axis::Vertical => this.flex().flex_row().items_center().h_full(), Axis::Vertical => this.h_full(),
Axis::Horizontal => this.h_flex().w_full(), Axis::Horizontal => this.w_full(),
}) })
.child( .child(
div() div()
.absolute() .absolute()
.map(|this| match self.axis { .map(|this| match self.axis {
Axis::Vertical => this.v_flex().w_0().h_full().border_l_1(), Axis::Vertical => this.w(px(1.)).h_full(),
Axis::Horizontal => this.h_flex().h_0().w_full().border_b_1(), Axis::Horizontal => this.h(px(1.)).w_full(),
}) })
.border_color(cx.theme().border), .bg(cx.theme().border),
) )
.when_some(self.label, |this, label| { .when_some(self.label, |this, label| {
this.child( this.child(