Make selectors stylable via theme

* input editor container style
* "no matches" message style

Co-Authored-By: Nate Butler <nate@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-09-07 14:42:19 -07:00
co-authored by Nate Butler
parent 36fb559c03
commit d2bfae5fe1
5 changed files with 30 additions and 17 deletions
+1 -1
View File
@@ -258,7 +258,7 @@ impl ChatPanel {
fn render_input_box(&self) -> ElementBox {
let theme = &self.settings.borrow().theme;
Container::new(ChildView::new(self.input_editor.id()).boxed())
.with_style(&theme.chat_panel.input_editor_container)
.with_style(&theme.chat_panel.input_editor.container)
.boxed()
}
+11 -3
View File
@@ -86,7 +86,11 @@ impl View for FileFinder {
ConstrainedBox::new(
Container::new(
Flex::new(Axis::Vertical)
.with_child(ChildView::new(self.query_editor.id()).boxed())
.with_child(
Container::new(ChildView::new(self.query_editor.id()).boxed())
.with_style(&settings.theme.selector.input_editor.container)
.boxed(),
)
.with_child(Flexible::new(1.0, self.render_matches()).boxed())
.boxed(),
)
@@ -117,9 +121,13 @@ impl FileFinder {
if self.matches.is_empty() {
let settings = self.settings.borrow();
return Container::new(
Label::new("No matches".into(), settings.theme.selector.label.clone()).boxed(),
Label::new(
"No matches".into(),
settings.theme.selector.empty.label.clone(),
)
.boxed(),
)
.with_margin_top(6.0)
.with_style(&settings.theme.selector.empty.container)
.named("empty matches");
}
+7 -6
View File
@@ -75,7 +75,6 @@ pub struct ChatPanel {
pub container: ContainerStyle,
pub message: ChatMessage,
pub channel_select: ChannelSelect,
pub input_editor_container: ContainerStyle,
pub input_editor: InputEditorStyle,
pub sign_in_prompt: TextStyle,
pub hovered_sign_in_prompt: TextStyle,
@@ -114,9 +113,7 @@ pub struct ChannelName {
pub struct Selector {
#[serde(flatten)]
pub container: ContainerStyle,
#[serde(flatten)]
pub label: LabelStyle,
pub empty: ContainedLabel,
pub input_editor: InputEditorStyle,
pub item: ContainedLabel,
pub active_item: ContainedLabel,
@@ -154,9 +151,10 @@ pub struct EditorStyle {
#[derive(Clone, Deserialize)]
pub struct InputEditorStyle {
#[serde(flatten)]
pub container: ContainerStyle,
pub text: HighlightStyle,
pub placeholder_text: HighlightStyle,
pub background: Color,
pub selection: SelectionStyle,
}
@@ -212,7 +210,10 @@ impl InputEditorStyle {
EditorStyle {
text: self.text.clone(),
placeholder_text: self.placeholder_text.clone(),
background: self.background,
background: self
.container
.background_color
.unwrap_or(Color::transparent_black()),
selection: self.selection,
..Default::default()
}
+6 -2
View File
@@ -208,9 +208,13 @@ impl ThemeSelector {
if self.matches.is_empty() {
let settings = self.settings.borrow();
return Container::new(
Label::new("No matches".into(), settings.theme.selector.label.clone()).boxed(),
Label::new(
"No matches".into(),
settings.theme.selector.empty.label.clone(),
)
.boxed(),
)
.with_margin_top(6.0)
.with_style(&settings.theme.selector.empty.container)
.named("empty matches");
}