gpui_material_components/
ext.rs1#[cfg(feature = "feedback")]
2use gpui::ElementId;
3use gpui::{IntoElement, SharedString};
4
5use crate::Badge;
6#[cfg(feature = "feedback")]
7use crate::{Menu, MenuItem, Tooltip};
8
9pub trait MaterialElementExt: IntoElement + Sized {
12 fn badge_dot(self) -> Badge {
14 Badge::dot(self)
15 }
16
17 fn badge_label(self, text: impl Into<SharedString>) -> Badge {
19 Badge::label(self, text)
20 }
21
22 fn badge_count(self, count: usize, maximum: usize) -> Badge {
24 Badge::count(self, count, maximum)
25 }
26
27 #[cfg(feature = "feedback")]
29 fn tooltip(self, id: impl Into<ElementId>, text: impl Into<SharedString>) -> Tooltip {
30 Tooltip::plain(id, self, text)
31 }
32
33 #[cfg(feature = "feedback")]
35 fn context_menu(
36 self,
37 id: impl Into<ElementId>,
38 items: impl IntoIterator<Item = MenuItem>,
39 ) -> Menu {
40 Menu::new(id, self, items).context()
41 }
42}
43
44impl<T: IntoElement + Sized> MaterialElementExt for T {}