mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
rules library: Improve empty state & fix quirks on Windows (#41064)
Just got a new Windows machine and realized that the rules library empty state was completly busted. Ended up also adding some little UI tweaks to make it better for both Windows and Linux. Release Notes: - N/A
This commit is contained in:
parent
fe730e9129
commit
5aa82887ec
4 changed files with 54 additions and 63 deletions
|
|
@ -366,7 +366,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "PromptLibrary",
|
"context": "RulesLibrary",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"new": "rules_library::NewRule",
|
"new": "rules_library::NewRule",
|
||||||
"ctrl-n": "rules_library::NewRule",
|
"ctrl-n": "rules_library::NewRule",
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "PromptLibrary",
|
"context": "RulesLibrary",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-n": "rules_library::NewRule",
|
"cmd-n": "rules_library::NewRule",
|
||||||
|
|
|
||||||
|
|
@ -375,7 +375,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "PromptLibrary",
|
"context": "RulesLibrary",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-n": "rules_library::NewRule",
|
"ctrl-n": "rules_library::NewRule",
|
||||||
|
|
|
||||||
|
|
@ -1102,23 +1102,42 @@ impl RulesLibrary {
|
||||||
.w_64()
|
.w_64()
|
||||||
.overflow_x_hidden()
|
.overflow_x_hidden()
|
||||||
.bg(cx.theme().colors().panel_background)
|
.bg(cx.theme().colors().panel_background)
|
||||||
.child(
|
.map(|this| {
|
||||||
h_flex()
|
if cfg!(target_os = "macos") {
|
||||||
.p(DynamicSpacing::Base04.rems(cx))
|
this.child(
|
||||||
.h_9()
|
h_flex()
|
||||||
.w_full()
|
.p(DynamicSpacing::Base04.rems(cx))
|
||||||
.flex_none()
|
.h_9()
|
||||||
.justify_end()
|
.w_full()
|
||||||
.child(
|
.flex_none()
|
||||||
IconButton::new("new-rule", IconName::Plus)
|
.justify_end()
|
||||||
.tooltip(move |_window, cx| {
|
.child(
|
||||||
Tooltip::for_action("New Rule", &NewRule, cx)
|
IconButton::new("new-rule", IconName::Plus)
|
||||||
})
|
.tooltip(move |_window, cx| {
|
||||||
.on_click(|_, window, cx| {
|
Tooltip::for_action("New Rule", &NewRule, cx)
|
||||||
window.dispatch_action(Box::new(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()))
|
.child(div().flex_grow().child(self.picker.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1348,9 +1367,8 @@ impl Render for RulesLibrary {
|
||||||
|
|
||||||
client_side_decorations(
|
client_side_decorations(
|
||||||
v_flex()
|
v_flex()
|
||||||
.bg(theme.colors().background)
|
|
||||||
.id("rules-library")
|
.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, &NewRule, window, cx| this.new_rule(window, cx)))
|
||||||
.on_action(
|
.on_action(
|
||||||
cx.listener(|this, &DeleteRule, window, cx| {
|
cx.listener(|this, &DeleteRule, window, cx| {
|
||||||
|
|
@ -1368,60 +1386,33 @@ impl Render for RulesLibrary {
|
||||||
.font(ui_font)
|
.font(ui_font)
|
||||||
.text_color(theme.colors().text)
|
.text_color(theme.colors().text)
|
||||||
.children(self.title_bar.clone())
|
.children(self.title_bar.clone())
|
||||||
|
.bg(theme.colors().background)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
|
.when(!cfg!(target_os = "macos"), |this| {
|
||||||
|
this.border_t_1().border_color(cx.theme().colors().border)
|
||||||
|
})
|
||||||
.child(self.render_rule_list(cx))
|
.child(self.render_rule_list(cx))
|
||||||
.map(|el| {
|
.map(|el| {
|
||||||
if self.store.read(cx).prompt_count() == 0 {
|
if self.store.read(cx).prompt_count() == 0 {
|
||||||
el.child(
|
el.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.w_2_3()
|
|
||||||
.h_full()
|
.h_full()
|
||||||
|
.flex_1()
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.gap_4()
|
.border_l_1()
|
||||||
|
.border_color(cx.theme().colors().border)
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
Button::new("create-rule", "New Rule")
|
||||||
.gap_2()
|
.style(ButtonStyle::Outlined)
|
||||||
.child(
|
.key_binding(KeyBinding::for_action(&NewRule, cx))
|
||||||
Icon::new(IconName::Book)
|
.on_click(|_, window, cx| {
|
||||||
.size(IconSize::Medium)
|
window
|
||||||
.color(Color::Muted),
|
.dispatch_action(NewRule.boxed_clone(), cx)
|
||||||
)
|
}),
|
||||||
.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()),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue