From 9c4411ff2be268199f8b5460e5e38e601bf82d28 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sun, 1 Sep 2024 00:36:51 +0800 Subject: [PATCH] date_picker: Reduce DatePicker popup position. (#195) --- crates/app/src/story_workspace.rs | 37 +++++++++++++++---------------- crates/ui/src/time/date_picker.rs | 2 +- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index 5f219400..c6792033 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -15,8 +15,7 @@ use ui::{ drawer::Drawer, h_flex, modal::Modal, - popover::Popover, - popup_menu::PopupMenu, + popup_menu::PopupMenuExt, theme::{ActiveTheme, Theme}, ContextModal, IconName, Root, Sizable, }; @@ -430,23 +429,23 @@ impl Render for LocaleSelector { .track_focus(&focus_handle) .on_action(cx.listener(Self::on_select_locale)) .child( - Popover::new("locale-selector") - .anchor(AnchorCorner::TopRight) - .trigger(Button::new("btn", cx).small().ghost().icon(IconName::Globe)) - .content(move |cx| { - PopupMenu::build(cx, |this, _cx| { - this.menu_with_check( - "English", - locale == "en", - Box::new(SelectLocale("en".into())), - ) - .menu_with_check( - "简体中文", - locale == "zh-CN", - Box::new(SelectLocale("zh-CN".into())), - ) - }) - }), + Button::new("btn", cx) + .small() + .ghost() + .icon(IconName::Globe) + .popup_menu(move |this, _| { + this.menu_with_check( + "English", + locale == "en", + Box::new(SelectLocale("en".into())), + ) + .menu_with_check( + "简体中文", + locale == "zh-CN", + Box::new(SelectLocale("zh-CN".into())), + ) + }) + .anchor(AnchorCorner::TopRight), ) } } diff --git a/crates/ui/src/time/date_picker.rs b/crates/ui/src/time/date_picker.rs index 1a256f7f..7d0a50b8 100644 --- a/crates/ui/src/time/date_picker.rs +++ b/crates/ui/src/time/date_picker.rs @@ -219,7 +219,7 @@ impl Render for DatePicker { .track_focus(&self.focus_handle) .occlude() .absolute() - .mt_2() + .mt_1p5() .overflow_hidden() .rounded_lg() .p_3()