Add icon-only dropdown menu triggers

- Infer a square icon-only trigger when no label is set.
- Omit the chevron and horizontal padding in that mode.
- Demonstrate it with the gallery's More menu.
- Assert the icon-only trigger renders at 32x32.
This commit is contained in:
2026-11-16 19:23:24 +07:00
parent 21faea00c5
commit 51a23aa526
3 changed files with 36 additions and 9 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
#![cfg(feature = "button")]
#![cfg(all(feature = "button", feature = "dropdown_menu"))]
use gpui::{
Context, IntoElement, ParentElement as _, Render, Styled as _, TestAppContext,
@@ -6,6 +6,9 @@ use gpui::{
};
use gpui_native_core::button::Button;
use gpui_native_core::common::Sizable as _;
use gpui_native_core::dropdown_menu::DropdownMenu;
use gpui_native_core::menu::MenuItem;
use gpui_native_icons::IconRole;
use gpui_native_theme::Theme;
struct Harness;
@@ -28,6 +31,12 @@ impl Render for Harness {
.xsmall()
.debug_selector(|| "xsmall-height-probe".to_string()),
)
.child(
DropdownMenu::new("icon-only-dropdown")
.icon(IconRole::More)
.accessibility_label("More actions")
.items(|_, _| vec![MenuItem::new("One")]),
)
}
}
@@ -42,7 +51,11 @@ fn buttons_render_at_their_token_heights(cx: &mut TestAppContext) {
let xsmall = cx
.debug_bounds("xsmall-height-probe")
.expect("xsmall button laid out");
let icon_only = cx
.debug_bounds("icon-only-dropdown-trigger")
.expect("icon-only dropdown laid out");
assert_eq!(medium.size.height, px(32.0));
assert_eq!(xsmall.size.height, px(20.0));
assert_eq!(icon_only.size, size(px(32.0), px(32.0)));
}