1use cloud_api_types::Plan;
2use ui::{Chip, prelude::*};
3
4/// A [`Chip`] that displays a [`Plan`].
5#[derive(IntoElement)]
6pub struct PlanChip {
7 plan: Plan,
8}
9
10impl PlanChip {
11 pub fn new(plan: Plan) -> Self {
12 Self { plan }
13 }
14}
15
16impl RenderOnce for PlanChip {
17 fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
18 let free_chip_bg = cx
19 .theme()
20 .colors()
21 .editor_background
22 .opacity(0.5)
23 .blend(cx.theme().colors().text_accent.opacity(0.05));
24
25 let pro_chip_bg = cx
26 .theme()
27 .colors()
28 .editor_background
29 .opacity(0.5)
30 .blend(cx.theme().colors().text_accent.opacity(0.2));
31
32 let (plan_name, label_color, bg_color) = match self.plan {
33 Plan::ZedFree => ("Free", Color::Default, free_chip_bg),
34 Plan::ZedProTrial => ("Pro Trial", Color::Accent, pro_chip_bg),
35 Plan::ZedPro => ("Pro", Color::Accent, pro_chip_bg),
36 Plan::ZedStudent => ("Student", Color::Accent, pro_chip_bg),
37 };
38
39 Chip::new(plan_name.to_string())
40 .bg_color(bg_color)
41 .label_color(label_color)
42 }
43}