diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index dd599acfe6fb5df175ca794d48a3407f4aebb9e1..3d94edafcdfc1d9acec5328cade996459547996b 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -366,7 +366,7 @@ } }, { - "context": "PromptLibrary", + "context": "RulesLibrary", "bindings": { "new": "rules_library::NewRule", "ctrl-n": "rules_library::NewRule", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index a3cc5e6c6bce709c0ddc7b4a8437847dbdce9ed9..6c3f47cb45909c1e014e76c9d414b68f23632a14 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -423,7 +423,7 @@ } }, { - "context": "PromptLibrary", + "context": "RulesLibrary", "use_key_equivalents": true, "bindings": { "cmd-n": "rules_library::NewRule", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 3507bfd2f0b6e10147fad728228fae55d99c9157..5b96d20633b573d939e49a3ea60c4afc5d7ca721 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -375,7 +375,7 @@ } }, { - "context": "PromptLibrary", + "context": "RulesLibrary", "use_key_equivalents": true, "bindings": { "ctrl-n": "rules_library::NewRule", diff --git a/crates/rules_library/src/rules_library.rs b/crates/rules_library/src/rules_library.rs index 3de1786f4c747d162d554d34b06424ec6102fcd4..207a9841e41bf35e1f63bb00b0c62073c1cf0224 100644 --- a/crates/rules_library/src/rules_library.rs +++ b/crates/rules_library/src/rules_library.rs @@ -1102,23 +1102,42 @@ impl RulesLibrary { .w_64() .overflow_x_hidden() .bg(cx.theme().colors().panel_background) - .child( - h_flex() - .p(DynamicSpacing::Base04.rems(cx)) - .h_9() - .w_full() - .flex_none() - .justify_end() - .child( - IconButton::new("new-rule", IconName::Plus) - .tooltip(move |_window, cx| { - Tooltip::for_action("New Rule", &NewRule, cx) - }) - .on_click(|_, window, cx| { - window.dispatch_action(Box::new(NewRule), cx); - }), - ), - ) + .map(|this| { + if cfg!(target_os = "macos") { + this.child( + h_flex() + .p(DynamicSpacing::Base04.rems(cx)) + .h_9() + .w_full() + .flex_none() + .justify_end() + .child( + IconButton::new("new-rule", IconName::Plus) + .tooltip(move |_window, cx| { + Tooltip::for_action("New Rule", &NewRule, cx) + }) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(NewRule), cx); + }), + ), + ) + } else { + this.child( + h_flex().p_1().w_full().child( + Button::new("new-rule", "New Rule") + .full_width() + .style(ButtonStyle::Outlined) + .icon(IconName::Plus) + .icon_size(IconSize::Small) + .icon_position(IconPosition::Start) + .icon_color(Color::Muted) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(NewRule), cx); + }), + ), + ) + } + }) .child(div().flex_grow().child(self.picker.clone())) } @@ -1348,9 +1367,8 @@ impl Render for RulesLibrary { client_side_decorations( v_flex() - .bg(theme.colors().background) .id("rules-library") - .key_context("PromptLibrary") + .key_context("RulesLibrary") .on_action(cx.listener(|this, &NewRule, window, cx| this.new_rule(window, cx))) .on_action( cx.listener(|this, &DeleteRule, window, cx| { @@ -1368,60 +1386,33 @@ impl Render for RulesLibrary { .font(ui_font) .text_color(theme.colors().text) .children(self.title_bar.clone()) + .bg(theme.colors().background) .child( h_flex() .flex_1() + .when(!cfg!(target_os = "macos"), |this| { + this.border_t_1().border_color(cx.theme().colors().border) + }) .child(self.render_rule_list(cx)) .map(|el| { if self.store.read(cx).prompt_count() == 0 { el.child( v_flex() - .w_2_3() .h_full() + .flex_1() .items_center() .justify_center() - .gap_4() + .border_l_1() + .border_color(cx.theme().colors().border) .bg(cx.theme().colors().editor_background) .child( - h_flex() - .gap_2() - .child( - Icon::new(IconName::Book) - .size(IconSize::Medium) - .color(Color::Muted), - ) - .child( - Label::new("No rules yet") - .size(LabelSize::Large) - .color(Color::Muted), - ), - ) - .child( - h_flex() - .child(h_flex()) - .child( - v_flex() - .gap_1() - .child(Label::new( - "Create your first rule:", - )) - .child( - Button::new("create-rule", "New Rule") - .full_width() - .key_binding( - KeyBinding::for_action( - &NewRule, cx, - ), - ) - .on_click(|_, window, cx| { - window.dispatch_action( - NewRule.boxed_clone(), - cx, - ) - }), - ), - ) - .child(h_flex()), + Button::new("create-rule", "New Rule") + .style(ButtonStyle::Outlined) + .key_binding(KeyBinding::for_action(&NewRule, cx)) + .on_click(|_, window, cx| { + window + .dispatch_action(NewRule.boxed_clone(), cx) + }), ), ) } else {