Skip to content

Conversation

@James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Nov 13, 2025

PR

image

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:
    --覆盖默认的button组件样式

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Refactor
    • Centralized Space spacing into theme-based styles and ensured the Space component loads those styles.
  • Style
    • Removed per-button inline margin; adjacent buttons now receive left spacing from a theme variable (default 0px), standardizing spacing across instances.

@github-actions github-actions bot added the bug Something isn't working label Nov 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Removed inline per-button margin attributes from demo Space examples and added a theme-level Space stylesheet and variables; the Vue Space entry now imports the new theme stylesheet, and theme index aggregates the Space styles.

Changes

Cohort / File(s) Summary
Demo components
examples/sites/demos/mobile-first/app/space/space-size.vue, examples/sites/demos/pc/app/space/space-size.vue
Removed inline style="margin: 0" from repeated TinyButton elements; iteration and keys unchanged.
Space theme styles
packages/theme/src/space/index.less
New stylesheet: imports custom/vars, invokes .inject-Space-vars(), defines .@{space-prefix-cls} and rule && .tiny-button + .tiny-button { margin-left: var(--tv-Space-margin); }.
Space vars
packages/theme/src/space/vars.less
New file: adds .inject-Space-vars() mixin that sets --tv-Space-margin: 0px.
Theme vars export
packages/theme/src/vars.less
Added import of ./space/vars.less to include Space variables.
Vue Space entry
packages/vue/src/space/index.ts
Added import of @opentiny/vue-theme/space/index.less so the Space theme stylesheet is loaded.
Theme index
packages/theme/src/index.less
Added import of space/index.less into theme aggregation.

Sequence Diagram(s)

(omitted — changes are styling and imports; no runtime control-flow change to diagram)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify --tv-Space-margin default and scope in packages/theme/src/space/vars.less.
  • Confirm selector specificity and intended targeting of && .tiny-button + .tiny-button in packages/theme/src/space/index.less.
  • Ensure @opentiny/vue-theme/space/index.less import in packages/vue/src/space/index.ts loads in the correct build order and does not create circular import issues.

Poem

🐰 Buttons lined up neat and trim,
Margins moved from each tiny limb.
Variables whisper, "space is right,"
Theme now sets the margin's flight. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing default spacing for button components in the Space component by removing inline margins and introducing CSS-based spacing rules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/theme/src/space/index.less (1)

20-20: TODO indicates incomplete solution - consider tracking.

The TODO comment mentions that button component spacing variables need to be unified in a future major version. This suggests the current implementation is a temporary workaround.

Consider creating a tracking issue for the future alignment work mentioned in the TODO. Would you like me to help draft an issue description for unifying Space and Button spacing in a future major version?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76dbda7 and 69c4d6c.

📒 Files selected for processing (6)
  • examples/sites/demos/mobile-first/app/space/space-size.vue (1 hunks)
  • examples/sites/demos/pc/app/space/space-size.vue (1 hunks)
  • packages/theme/src/space/index.less (1 hunks)
  • packages/theme/src/space/vars.less (1 hunks)
  • packages/theme/src/vars.less (1 hunks)
  • packages/vue/src/space/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-04T09:35:13.159Z
Learnt from: zzcr
Repo: opentiny/tiny-vue PR: 2481
File: packages/theme/src/time-range/vars.less:27-28
Timestamp: 2024-11-04T09:35:13.159Z
Learning: 在 `packages/theme/src/time-range/vars.less` 文件中,应使用 `var(--tv-TimeRange-header-height)` 作为 `--tv-TimeRange-header-line-height` 的值,以保持一致性。

Applied to files:

  • packages/theme/src/space/index.less
  • packages/theme/src/space/vars.less
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (6)
examples/sites/demos/mobile-first/app/space/space-size.vue (1)

18-18: LGTM - consistent with PC demo.

The removal of inline margin styling matches the changes in the PC demo and correctly delegates spacing control to the theme layer.

packages/theme/src/vars.less (1)

55-55: LGTM - correct alphabetical placement.

The import of ./space/vars.less is properly placed in alphabetical order between split and steps, consistent with the existing import pattern.

packages/vue/src/space/index.ts (1)

14-14: LGTM - necessary theme integration.

The import of the Space theme stylesheet ensures the new spacing styles are loaded when the component is used. The placement after the component import is appropriate.

packages/theme/src/space/index.less (1)

21-23: Rewrite the review comment: The && specificity boost and zero margin are intentional and documented.

The code uses && to override the button component's default & + & margin rule, setting it to 0px so the Space component's flexbox gap property can manage spacing instead. This is a temporary workaround documented in the TODO comment, which states it will be removed once the button component removes its default 8px margin in a future major version.

The implementation is not a specificity conflict but a known pattern: the Space component uses modern CSS flexbox gap for spacing, while this rule suppresses button margins that would otherwise apply. The approach correctly isolates the override to .tiny-button elements within Space contexts, with a clear plan for cleanup.

No changes needed.

packages/theme/src/space/vars.less (1)

13-15: The review comment is based on a misunderstanding of the code's purpose.

The --tv-Space-margin: 0px setting applies only to buttons within a Space container (per the CSS rule at packages/theme/src/space/index.less:21-23). It doesn't override Button component defaults; rather, it gives the Space component control over its children's spacing.

The TODO comment at packages/theme/src/space/index.less:20 explicitly documents this as temporary: spacing should be unified with Button in a future major version. The architectural intent is clear: Space should have its own spacing control separate from Button's adjacent-button margins (--tv-Button-margin-left-btn-to-btn-md).

Referencing Button spacing variables in Space margin would violate separation of concerns and is not necessary. The current design is sound and addresses the alignment concern through the documented TODO.

Likely an incorrect or invalid review comment.

examples/sites/demos/pc/app/space/space-size.vue (1)

18-18: Code structure is correct; recommend manual testing to confirm visual spacing.

The Space component correctly applies the class="tiny-space" from the demo, and the theme CSS rule && .tiny-button + .tiny-button { margin-left: var(--tv-Space-margin) } will properly target adjacent buttons. The --tv-Space-margin: 0px variable cancels default button spacing, while the Space component's inline gap style (from the :size prop) provides the actual spacing via flexbox.

Verify visually that buttons render with correct spacing when the demo's row/column sliders adjust the size values.

@zzcr zzcr merged commit e1dcb3d into opentiny:dev Nov 20, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants