Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally render divider between button groups in the status bar #24114

Conversation

ksweetie
Copy link
Contributor

@ksweetie ksweetie commented Feb 3, 2025

In the left hand status bar, there are two groups of buttons. There was a border between the two hardcoded on the first button of the second group, however, if all buttons in the first group are hidden, the border doesn't need to be rendered.

(Not handled in this PR) A potentially better approach would be to change StatusBar's definition from left_items and right_items to left_groups and right_groups, and render dividers between each group of items. That seemed like a bigger refactor than I wanted to handle for now, but is an option for the future.

If you use these settings on main, the border will show, but with nothing to the left of it.

{
  "collaboration_panel": {
    "button": false
  },
  "outline_panel": {
    "button": false
  },
  "project_panel": {
    "button": false,
  },
}

Screenshots:

Before:
Screenshot 2025-02-02 at 6 19 24 PM
Screenshot 2025-02-02 at 6 20 12 PM

After:
Screenshot 2025-02-02 at 6 19 58 PM
Screenshot 2025-02-02 at 6 20 20 PM

Release Notes:

  • Conditionally render divider in status bar

In the left hand status bar, there are two groups of buttons. There was a border between the two hardcoded on the first button of the second group, however, if all buttons in the first group are hidden, the border doesn't need to be rendered.

I think a better approach would be to change StatusBar's definition from `left_items` and `right_items` to `left_groups` and `right_groups`, and render dividers between each group of items. That seemed like a bigger refactor than I wanted to handle for now, but is an option for the future.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 3, 2025
Comment on lines -89 to -91
.pl_1()
.border_l_1()
.border_color(cx.theme().colors().border)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This border looks slightly darker or thicker than the default Divider. We could either:

  1. Use this 1px border instead of Divider.
  2. Modify Divider to have a darker/thicker border.

I'm assuming that the default divider is good for this use case, but happy to iterate.

.children(buttons)
.when(has_buttons, |this| {
this.h_flex().gap_1().child(Divider::vertical())
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Rust is very bad, so there's likely a better way to handle this diff. I wanted to inline !buttons.is_empty(), but ran into an error about moving buttons that I couldn't figure out. If anything here could be more idiomatic, please let me know!

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thank you!

@danilo-leal danilo-leal enabled auto-merge (squash) February 3, 2025 04:03
@danilo-leal danilo-leal merged commit f14ef40 into zed-industries:main Feb 3, 2025
12 checks passed
@ksweetie ksweetie deleted the hide-diagnostic-item-border-when-no-buttons-to-the-left branch February 3, 2025 04:14
danilo-leal added a commit that referenced this pull request Feb 4, 2025
Follow up to #24114

Just fixing the UI so that the divider only shows for the
left-positioned items.

Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants