Repository navigation
button: carry the caller's alignment to the content row - #3
Merged
Merged
Conversation
A Button draws its content in an h_flex that fills the root (size_full) and centers its children (items_center, justify_center). Styles set on the Button, justify_start() or items_start(), refined only the root, where they have nothing left to place because the content row already fills it. The row itself was refined only by the crate-internal content_style. So a row-shaped button, ghost().w_full().justify_start(), still centered its label and children, and a list of such rows rendered staggered, each centered at its own width. The content row now repeats the caller's justify_content and align_items after content_style. A Button asked for nothing keeps its centered content, and a dropdown caret still spreads the row with justify_between. Found in the Codewhale native golden-path walk (app source 3ff67bb, kit pin 60eeba2): the My work "Connected work" rows rendered centered and staggered under a left-aligned header. - Test: button::button::tests:: full_width_button_places_content_by_its_alignment. A 400px justify_start button puts its child at the leading padding; the same button asked for nothing keeps the child centered (equal margins); an items_start button 60px tall puts its child at the top edge. - Docs: Button "Content Alignment" example, en and zh-CN. - Other kit callers: two story rows (collapsible, combobox) asked for justify_start and now get it. The base showcase buttons are gpui_base::Button and do not pass through this code. Evidence (local, macOS arm64, cargowhale governor), on e3dfda2 plus this change: - cargo test -p gpui-component --lib: 530 passed, 0 failed, 0 ignored - cargo clippy -p gpui-component --lib --tests -- --deny warnings: clean - cargo fmt --all -- --check: clean - script/check-ai docs: PASS (9 published recipe fragments) Not run locally: typos (not installed), other crates' tests, other platforms. The new test was not run against the pre-fix Button; the Codewhale app's own guard fails on the old pin and is recorded there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation preserves defaults and dropdown behavior while providing adequate regression coverage and synchronized documentation.
Review effort: Balanced
Findings: None
What changed in this PR
Propagates caller-defined alignment from Button to its full-size content row.
Changes:
- Applies horizontal and vertical alignment to button content.
- Adds regression coverage for start, center, and top alignment.
- Documents alignment behavior in English and Chinese.
| File | Description |
|---|---|
crates/component/src/button/button.rs |
Propagates alignment and adds tests. |
website/component/button.md |
Documents content alignment. |
website/zh-CN/component/button.md |
Adds synchronized Chinese documentation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
Buttondraws its content in anh_flexthat fills the root (size_full) and centers its children. Alignment set on the Button (justify_start(),items_start()) refined only the root, where it had nothing left to place, because the content row already fills it. So a row-shaped button,ghost().w_full().justify_start(), still centered its label and children, and a list of such rows rendered staggered, each centered at its own width.The content row now repeats the caller's
justify_contentandalign_itemsafter the crate-internalcontent_style.Found in the Codewhale native golden-path walk (app source
3ff67bb, kit pin60eeba2c): the My work "Connected work" rows rendered centered and staggered under a left-aligned header.Behavior change
No API change. A Button that sets
justify_*oritems_*on itself now gets that alignment for its content:Button::new("row").ghost().w_full().justify_start().label("Row") - // label centered in the full-width button + // label at the leading paddingUnchanged:
justify_between.gpui_base::Buttonis not touched.In this repo two story rows (collapsible, combobox) asked for
justify_startand now get it.Testing
Local, macOS arm64, on
e3dfda2fplus this change:cargo test -p gpui-component --lib: 530 passed, 0 failed, 0 ignored. This includes the newbutton::button::tests::full_width_button_places_content_by_its_alignment:justify_startbutton puts its child at the leading padding;items_startbutton 60px tall puts its child at the top edge.cargo clippy -p gpui-component --lib --tests -- --deny warnings: cleancargo fmt --all -- --check: cleanscript/check-ai docs: PASSNot run locally:
typos, other crates' tests, other platforms. The new test was not run against the pre-fix Button. The Codewhale app's own guard test fails on the old pin (60eeba2c): its first row's content sits centered at x=481 in a row starting at x=195.5.Docs
Button "Content Alignment" example, in en and zh-CN.
The change, test and docs were written with Claude Code.
🤖 Generated with Claude Code