feat: Redesign New Chat (#31)

* make subject is optional

* redesign

* search

* fix

* adjust
This commit is contained in:
reya
2025-05-12 20:46:01 +07:00
committed by GitHub
parent 2f83b5091e
commit 4e24061817
32 changed files with 580 additions and 367 deletions

View File

@@ -308,9 +308,15 @@ impl RenderOnce for Button {
// Normal Button
match self.size {
Size::Size(size) => this.px(size * 0.2),
Size::XSmall => this.h_6().px_1p5(),
Size::Small => this.h_7().px_2(),
Size::Large => this.h_10().px_3(),
Size::XSmall => this.h_6().px_2(),
Size::Small => {
if self.icon.is_some() {
this.h_7().pl_2().pr_3()
} else {
this.h_7().px_3()
}
}
Size::Large => this.h_10().px_4(),
_ => this.h_9().px_2(),
}
}

View File

@@ -24,12 +24,12 @@ impl_internal_actions!(emoji, [EmitEmoji]);
pub struct EmojiPicker {
icon: Option<Icon>,
anchor: Option<Corner>,
input: WeakEntity<TextInput>,
target_input: WeakEntity<TextInput>,
emojis: Rc<Vec<SharedString>>,
}
impl EmojiPicker {
pub fn new(input: WeakEntity<TextInput>) -> Self {
pub fn new(target_input: WeakEntity<TextInput>) -> Self {
let mut emojis: Vec<SharedString> = vec![];
emojis.extend(
@@ -39,15 +39,8 @@ impl EmojiPicker {
.collect::<Vec<SharedString>>(),
);
emojis.extend(
emojis::Group::Symbols
.emojis()
.map(|e| SharedString::from(e.as_str()))
.collect::<Vec<SharedString>>(),
);
Self {
input,
target_input,
emojis: emojis.into(),
anchor: None,
icon: None,
@@ -82,7 +75,7 @@ impl RenderOnce for EmojiPicker {
)
.content(move |window, cx| {
let emojis = self.emojis.clone();
let input = self.input.clone();
let input = self.target_input.clone();
cx.new(|cx| {
PopoverContent::new(window, cx, move |_window, cx| {

View File

@@ -54,6 +54,7 @@ pub enum IconName {
PanelRightClose,
PanelRightOpen,
Plus,
PlusFill,
PlusCircleFill,
Relays,
ResizeCorner,
@@ -124,6 +125,7 @@ impl IconName {
Self::PanelRightClose => "icons/panel-right-close.svg",
Self::PanelRightOpen => "icons/panel-right-open.svg",
Self::Plus => "icons/plus.svg",
Self::PlusFill => "icons/plus-fill.svg",
Self::PlusCircleFill => "icons/plus-circle-fill.svg",
Self::Relays => "icons/relays.svg",
Self::ResizeCorner => "icons/resize-corner.svg",

View File

@@ -464,13 +464,13 @@ impl TextInput {
}
/// Set the disabled state of the input field.
pub fn set_disabled(&mut self, disabled: bool, _window: &mut Window, cx: &mut Context<Self>) {
pub fn set_disabled(&mut self, disabled: bool, cx: &mut Context<Self>) {
self.disabled = disabled;
cx.notify();
}
/// Set the masked state of the input field.
pub fn set_masked(&mut self, masked: bool, _window: &mut Window, cx: &mut Context<Self>) {
pub fn set_masked(&mut self, masked: bool, cx: &mut Context<Self>) {
self.masked = masked;
cx.notify();
}
@@ -576,7 +576,7 @@ impl TextInput {
}
/// Set true to show indicator at the input right.
pub fn set_loading(&mut self, loading: bool, _window: &mut Window, cx: &mut Context<Self>) {
pub fn set_loading(&mut self, loading: bool, cx: &mut Context<Self>) {
self.loading = loading;
cx.notify();
}

View File

@@ -286,10 +286,10 @@ where
}
}
fn set_loading(&mut self, loading: bool, window: &mut Window, cx: &mut Context<Self>) {
fn set_loading(&mut self, loading: bool, _window: &mut Window, cx: &mut Context<Self>) {
self.loading = loading;
if let Some(input) = &self.query_input {
input.update(cx, |input, cx| input.set_loading(loading, window, cx))
input.update(cx, |input, cx| input.set_loading(loading, cx))
}
cx.notify();
}

View File

@@ -130,7 +130,7 @@ impl RenderOnce for ListItem {
let is_active = self.selected || self.confirmed;
self.base
.text_color(cx.theme().text_muted)
.text_color(cx.theme().text)
.relative()
.items_center()
.justify_between()
@@ -147,7 +147,7 @@ impl RenderOnce for ListItem {
})
.when(is_active, |this| this.bg(cx.theme().element_active))
.when(!is_active && !self.disabled, |this| {
this.hover(|this| this.bg(cx.theme().surface_background))
this.hover(|this| this.bg(cx.theme().elevated_surface_background))
})
// Mouse enter
.when_some(self.on_mouse_enter, |this, on_mouse_enter| {

View File

@@ -590,7 +590,7 @@ impl Render for PopupMenu {
.h(px(1.))
.mx_neg_1()
.my_0p5()
.bg(cx.theme().border_variant),
.bg(cx.theme().border_disabled),
)
}
PopupMenuItem::ElementItem { render, .. } => this

View File

@@ -35,7 +35,7 @@ impl RenderOnce for Skeleton {
fn render(self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl IntoElement {
div().child(
self.base
.bg(cx.theme().ghost_element_disabled)
.bg(cx.theme().ghost_element_active)
.with_animation(
"skeleton",
Animation::new(Duration::from_secs(2))

View File

@@ -23,11 +23,11 @@ impl Render for Tooltip {
.p_2()
.border_1()
.border_color(cx.theme().border)
.bg(cx.theme().surface_background)
.shadow_lg()
.bg(cx.theme().background)
.shadow_md()
.rounded_lg()
.text_sm()
.text_color(cx.theme().text_muted)
.text_color(cx.theme().text)
.line_height(relative(1.25))
.child(self.text.clone()),
)