1use gpui::prelude::*;
4use gpui::{div, px, App, FontWeight, IntoElement, SharedString, Window};
5
6use crate::devtools::Probed;
7use crate::theme::{theme, ColorName, Size};
8
9#[derive(IntoElement)]
11pub struct Kbd {
12 key: SharedString,
13}
14
15impl Kbd {
16 pub fn new(key: impl Into<SharedString>) -> Self {
17 Kbd { key: key.into() }
18 }
19}
20
21impl RenderOnce for Kbd {
22 fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
23 let t = theme(cx);
24 let bg = t
25 .color(ColorName::Gray, if t.scheme.is_dark() { 7 } else { 0 })
26 .hsla();
27 let border = t
28 .color(ColorName::Gray, if t.scheme.is_dark() { 6 } else { 3 })
29 .hsla();
30
31 div()
32 .px(px(7.0))
33 .py(px(2.0))
34 .rounded(px(t.radius(Size::Sm)))
35 .border_1()
36 .border_color(border)
37 .bg(bg)
38 .text_color(t.text().hsla())
39 .text_size(px(t.font_size(Size::Xs)))
40 .font_weight(FontWeight::SEMIBOLD)
41 .child(self.key)
42 .probe("Kbd")
43 }
44}