agent_panel_onboarding_card.rs

 1use gpui::{AnyElement, IntoElement, ParentElement, linear_color_stop, linear_gradient};
 2use smallvec::SmallVec;
 3use ui::prelude::*;
 4
 5#[derive(IntoElement)]
 6pub struct AgentPanelOnboardingCard {
 7    children: SmallVec<[AnyElement; 2]>,
 8}
 9
10impl AgentPanelOnboardingCard {
11    pub fn new() -> Self {
12        Self {
13            children: SmallVec::new(),
14        }
15    }
16}
17
18impl ParentElement for AgentPanelOnboardingCard {
19    fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
20        self.children.extend(elements)
21    }
22}
23
24impl RenderOnce for AgentPanelOnboardingCard {
25    fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
26        let color = cx.theme().colors();
27
28        div().min_w_0().p_2p5().bg(color.editor_background).child(
29            div()
30                .min_w_0()
31                .p(px(3.))
32                .rounded_lg()
33                .elevation_2(cx)
34                .bg(color.background.opacity(0.5))
35                .child(
36                    v_flex()
37                        .relative()
38                        .size_full()
39                        .min_w_0()
40                        .px_4()
41                        .py_3()
42                        .gap_2()
43                        .border_1()
44                        .rounded(px(5.))
45                        .border_color(color.text.opacity(0.1))
46                        .bg(color.panel_background)
47                        .overflow_hidden()
48                        .child(
49                            div()
50                                .absolute()
51                                .inset_0()
52                                .size_full()
53                                .rounded_md()
54                                .overflow_hidden()
55                                .bg(linear_gradient(
56                                    360.,
57                                    linear_color_stop(color.panel_background, 1.0),
58                                    linear_color_stop(color.editor_background, 0.45),
59                                )),
60                        )
61                        .children(self.children),
62                ),
63        )
64    }
65}