1use gpui::{App, IntoElement, Modifiers, RenderOnce, Window};
2use ui::{prelude::*, render_modifiers};
3
4#[derive(IntoElement)]
5pub struct HoldForDefault {
6 is_default: bool,
7}
8
9impl HoldForDefault {
10 pub fn new(is_default: bool) -> Self {
11 Self { is_default }
12 }
13}
14
15impl RenderOnce for HoldForDefault {
16 fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
17 h_flex()
18 .pt_1()
19 .border_t_1()
20 .border_color(cx.theme().colors().border_variant)
21 .gap_0p5()
22 .text_sm()
23 .text_color(Color::Muted.color(cx))
24 .child("Hold")
25 .child(h_flex().flex_shrink_0().children(render_modifiers(
26 &Modifiers::secondary_key(),
27 PlatformStyle::platform(),
28 None,
29 Some(TextSize::Default.rems(cx).into()),
30 true,
31 )))
32 .child(div().map(|this| {
33 if self.is_default {
34 this.child("to unset as default")
35 } else {
36 this.child("to set as default")
37 }
38 }))
39 }
40}