Add styles for project name/git menu

This commit is contained in:
Piotr Osiewicz 2023-06-30 20:07:44 +02:00
parent a5d9a10d7b
commit cec884b5a5
2 changed files with 38 additions and 34 deletions

View File

@ -220,29 +220,17 @@ impl CollabTitlebarItem {
let branch_prepended = entry let branch_prepended = entry
.as_ref() .as_ref()
.and_then(RepositoryEntry::branch) .and_then(RepositoryEntry::branch)
.map(|branch| { .map(|branch| util::truncate_and_trailoff(&branch, MAX_BRANCH_NAME_LENGTH));
format!( let project_style = theme.titlebar.title.clone();
"/{}", let git_style = theme.titlebar.git_branch.clone();
util::truncate_and_trailoff(&branch, MAX_BRANCH_NAME_LENGTH) let divider_style = theme.titlebar.project_name_divider.clone();
)
});
let text_style = theme.titlebar.title.clone();
let item_spacing = theme.titlebar.item_spacing; let item_spacing = theme.titlebar.item_spacing;
let mut highlight = text_style.clone();
highlight.color = theme.titlebar.highlight_color;
let style = LabelStyle {
text: text_style,
highlight_text: Some(highlight),
};
let highlights = (0..name.len()).into_iter().collect();
let mut ret = Flex::row().with_child( let mut ret = Flex::row().with_child(
Stack::new() Stack::new()
.with_child( .with_child(
MouseEventHandler::<ToggleProjectMenu, Self>::new(0, cx, |_, _| { MouseEventHandler::<ToggleProjectMenu, Self>::new(0, cx, |_, _| {
Label::new(name, style.clone()) Label::new(name, project_style.text.clone())
.with_highlights(highlights)
.contained() .contained()
.aligned() .aligned()
.left() .left()
@ -251,16 +239,27 @@ impl CollabTitlebarItem {
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, this, cx| { .on_click(MouseButton::Left, move |_, this, cx| {
this.toggle_project_menu(&Default::default(), cx) this.toggle_project_menu(&Default::default(), cx)
}), })
.contained()
.with_style(project_style.container),
) )
.with_children(self.render_project_popover_host(&theme.titlebar, cx)), .with_children(self.render_project_popover_host(&theme.titlebar, cx)),
); );
if let Some(git_branch) = branch_prepended { if let Some(git_branch) = branch_prepended {
ret = ret.with_child( ret = ret.with_child(
Flex::row()
.with_child(
Label::new("/", divider_style.text)
.contained()
.with_style(divider_style.container)
.aligned()
.left(),
)
.with_child(
Stack::new() Stack::new()
.with_child( .with_child(
MouseEventHandler::<ToggleVcsMenu, Self>::new(0, cx, |_, _| { MouseEventHandler::<ToggleVcsMenu, Self>::new(0, cx, |_, _| {
Label::new(git_branch, style) Label::new(git_branch, git_style.text)
.contained() .contained()
.with_margin_right(item_spacing) .with_margin_right(item_spacing)
.aligned() .aligned()
@ -268,11 +267,15 @@ impl CollabTitlebarItem {
.into_any_named("title-project-branch") .into_any_named("title-project-branch")
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, this, cx| { .on_click(
MouseButton::Left,
move |_, this, cx| {
this.toggle_vcs_menu(&Default::default(), cx) this.toggle_vcs_menu(&Default::default(), cx)
}), },
),
) )
.with_children(self.render_branches_popover_host(&theme.titlebar, cx)), .with_children(self.render_branches_popover_host(&theme.titlebar, cx)),
),
) )
} }
ret.into_any() ret.into_any()

View File

@ -173,8 +173,9 @@ export function titlebar(theme: ColorScheme): any {
}, },
// Project // Project
title: text(theme.lowest, "sans", "variant"), title: text(theme.lowest, "sans", "active"),
highlight_color: text(theme.lowest, "sans", "active").color, project_name_divider: text(theme.lowest, "sans", "variant"),
git_branch: text(theme.lowest, "sans", "variant"),
// Collaborators // Collaborators
leader_avatar: { leader_avatar: {