Add styles to git menu
This commit is contained in:
parent
3be8977ee8
commit
b699e5c142
4 changed files with 51 additions and 22 deletions
|
@ -2,7 +2,7 @@ use anyhow::{anyhow, bail};
|
|||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use gpui::{elements::*, AppContext, MouseState, Task, ViewContext, ViewHandle};
|
||||
use picker::{Picker, PickerDelegate, PickerEvent};
|
||||
use std::sync::Arc;
|
||||
use std::{ops::Not, sync::Arc};
|
||||
use util::ResultExt;
|
||||
use workspace::{Toast, Workspace};
|
||||
|
||||
|
@ -212,7 +212,7 @@ impl PickerDelegate for BranchListDelegate {
|
|||
}
|
||||
fn render_header(&self, cx: &AppContext) -> Option<AnyElement<Picker<Self>>> {
|
||||
let theme = &theme::current(cx);
|
||||
let style = theme.picker.no_matches.label.clone();
|
||||
let style = theme.picker.header.clone();
|
||||
if self.last_query.is_empty() {
|
||||
Some(
|
||||
Flex::row()
|
||||
|
@ -221,28 +221,24 @@ impl PickerDelegate for BranchListDelegate {
|
|||
)
|
||||
} else {
|
||||
Some(
|
||||
Flex::row()
|
||||
.with_child(Label::new("Branches", style))
|
||||
Stack::new()
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(Label::new("Branches", style.clone()).aligned().left()),
|
||||
)
|
||||
.with_children(self.matches.is_empty().not().then(|| {
|
||||
let suffix = if self.matches.len() == 1 { "" } else { "es" };
|
||||
Flex::row()
|
||||
.align_children_center()
|
||||
.with_child(Label::new(
|
||||
format!("{} match{}", self.matches.len(), suffix),
|
||||
style,
|
||||
))
|
||||
.aligned()
|
||||
.right()
|
||||
}))
|
||||
.into_any(),
|
||||
)
|
||||
}
|
||||
}
|
||||
fn render_footer(&self, cx: &AppContext) -> Option<AnyElement<Picker<Self>>> {
|
||||
if !self.last_query.is_empty() && !self.matches.is_empty() {
|
||||
let theme = &theme::current(cx);
|
||||
let style = theme.picker.no_matches.label.clone();
|
||||
// Render "1 match" and "0 matches", "42 matches"etc.
|
||||
let suffix = if self.matches.len() == 1 { "" } else { "es" };
|
||||
Some(
|
||||
Flex::row()
|
||||
.with_child(Label::new(
|
||||
format!("{} match{}", self.matches.len(), suffix),
|
||||
style,
|
||||
))
|
||||
.into_any(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,6 +585,8 @@ pub struct Picker {
|
|||
pub empty_input_editor: FieldEditor,
|
||||
pub no_matches: ContainedLabel,
|
||||
pub item: Toggleable<Interactive<ContainedLabel>>,
|
||||
pub header: LabelStyle,
|
||||
pub footer: LabelStyle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
|
||||
|
|
|
@ -44,6 +44,8 @@ export default function contact_finder(theme: ColorScheme): any {
|
|||
no_matches: picker_style.no_matches,
|
||||
input_editor: picker_input,
|
||||
empty_input_editor: picker_input,
|
||||
header: picker_style.header,
|
||||
footer: picker_style.footer,
|
||||
},
|
||||
row_height: 28,
|
||||
contact_avatar: {
|
||||
|
|
|
@ -108,5 +108,34 @@ export default function picker(theme: ColorScheme): any {
|
|||
top: 8,
|
||||
},
|
||||
},
|
||||
header: {
|
||||
text: text(theme.lowest, "sans", "variant", { size: "xs" }),
|
||||
padding: {
|
||||
bottom: 4,
|
||||
left: 12,
|
||||
right: 12,
|
||||
top: 4,
|
||||
},
|
||||
margin: {
|
||||
top: 1,
|
||||
left: 4,
|
||||
right: 4,
|
||||
},
|
||||
},
|
||||
footer: {
|
||||
text: text(theme.lowest, "sans", "variant", { size: "xs" }),
|
||||
padding: {
|
||||
bottom: 4,
|
||||
left: 12,
|
||||
right: 12,
|
||||
top: 4,
|
||||
},
|
||||
margin: {
|
||||
top: 1,
|
||||
left: 4,
|
||||
right: 4,
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue