-
Notifications
You must be signed in to change notification settings - Fork 406
feat: custom header for SidebarGroup #1813
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
base: main
Are you sure you want to change the base?
feat: custom header for SidebarGroup #1813
Conversation
+ header methods - Removed `new_with_header` and `new_with_spaced_header` constructors. - Introduced single `new(label)` constructor combined with chainable methods: - `header()` for a fully custom header - `spaced_header()` for left/right aligned header - `with_header_style()` to override default header styling - Rationale: simplifies API, avoids duplicating label/header information, and aligns with GPUI/shadcn-ui builder patterns. - Maintains backward compatibility: simple label usage still works with `new()`.
|
The Sidebar is allowing to add any elements ( I have read the API that you added. It's looks like not common for most case, more like for some little use case. I don't think those APIs may not necessary. |
crates/ui/src/sidebar/group.rs
Outdated
| /// Convenience method for aligning content at the left and right of the header. | ||
| /// | ||
| /// **Warning:** This replaces the label from [`SidebarGroup::new`]. | ||
| pub fn spaced_header(self, left: impl IntoElement, right: impl IntoElement) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API is not reasonable to as a basic API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it from SidebarGroup
crates/ui/src/sidebar/group.rs
Outdated
| /// | ||
| /// The closure receives the default [`Div`] used for the header and should return a | ||
| /// customized [`Div`]. This allows changing padding, color, rounding, height, etc. | ||
| pub fn with_header_style<F>(mut self, f: F) -> Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fn header can handle the style refine totally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it from SidebarGroup
huacnlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To change the label as option, to allows SidebarGroup to more flexible, is reasonable. If the API is good, it can be merged.
But, your current design not good enough, please do more consider the API, and read the exists components in this project and reference some other UI library (like Shadcn), then make change.
|
I followed your first suggestion and decided to go with a new group type for the sidebar instead of extending the existing API. I’m now building a dedicated Does this approach fit better with what you had in mind? |
|
I'm sorry, there are many changes that look not good, I can't review to give suggestion. We need to have a good API design, not only added some feature directly. By your original feature request, why you are changed so many APIs?
|
Original NeedMy original feature request was to have a sidebar group with a custom header (with action buttons) instead of just a text label. Following your suggestion, I created a new However, this introduced a type incompatibility problem: What I Added & Why
Detailed Documentation1.
|
Closes #1812