fix(button): review Button component#8511
Open
trp1119 wants to merge 1 commit intovueComponent:feat/vaporfrom
Open
fix(button): review Button component#8511trp1119 wants to merge 1 commit intovueComponent:feat/vaporfrom
trp1119 wants to merge 1 commit intovueComponent:feat/vaporfrom
Conversation
Completed review of the `Button` and `ButtonGroup` components as part of the ant-design-vue refactoring project. Focused on visual parity with old component, API compatibility, style alignment, and test coverage. Related: vueComponent#8497 **`packages/ui/src/components/button/style/index.css`** - Fix horizontal padding to match old values (15px/7px/15px for md/sm/lg), derived from `paddingContentHorizontal - lineWidth` - Fix ButtonGroup solid button separator color to `var(--color-accent-hover)` - Fix round button padding to `controlHeight / 2` - Add ghost, disabled, danger, link, text variant styles - Add loading icon enter/leave transition animation CSS - Add two Chinese characters auto-spacing and RTL styles - Add icon vertical alignment fix (`line-height: 0`) - Add `font-weight: 400` to match old component explicitly **`packages/ui/src/components/button/types.ts`** - Add legacy `type` → `variant` mapping (primary→solid, default→outlined, etc.) - Fix default variant to `outlined` when no type/variant specified - Add legacy size mapping including `default` → `md` - Add `icon` (VNode) and `title` props to `ButtonProps` - Add `click` emit with loading/disabled gating - Remove `mousedown` emit (native event, handled by inheritAttrs) - Remove unimplemented `loading` slot from `ButtonSlots` **`packages/ui/src/components/button/Button.vue`** - Add `icon` prop support with priority: loading > icon prop > #icon slot - Add `title` prop passthrough - Add click event gating to prevent clicks when loading/disabled - Add loading icon enter/leave `<Transition>` animation - Add two Chinese characters auto-spacing logic (`onMounted`/`onUpdated`) - Add RTL direction support via `useConfigInject` **`packages/ui/src/components/button/index.ts`** - Export `Button.Group` as sub-component - Align all demos with old component using `type` prop for visual parity - Fix Chinese text to English per CLAUDE.md convention - Fix `warp` typo to `wrap` in danger/icon demos - Remove old package (`ant-design-vue`) type imports from size/multiple demos Added test cases in `__tests__/index.test.ts`: | Test group | Count | Description | |-----------------------------|-------|------------------------------------------------| | href + disabled | 5 | href removal, target, tabindex, role, click | | type prop deprecation | 2 | warns for deprecated type, unknown type value | | icon-only detection | 2 | icon slot only, icon + default slot | | ghost + text/link warning | 2 | warns for invalid ghost combinations | | ButtonGroup provide/inject | 2 | size propagation, local size override | | loading edge cases | 2 | default icon, no icon when false | Updated default variant test (solid → outlined). Updated all 12 demo snapshots. **All 97 tests passing.** **`packages/ui/src/components/radio/style/index.css`** - Fix Radio.Button checked state left border artifact in group - **Correctness** — Visual rendering matches old ant-design-vue component - **API compatibility** — Legacy `type`/`size` props mapped, `icon`/`title` added - **Accessibility** — `aria-disabled`, `aria-busy`, `role="link"` for disabled anchors - **SSR safety** — No `document`/`window` at top-level, only in `onMounted`/`onUpdated` - **Type safety** — Full TypeScript coverage on props, emits, slots - **Theme system** — All colors via CSS variables, padding derived from design tokens - **Tests** — 97 test cases covering props, events, slots, edge cases, and demos - **Performance** — Computed properties, loading delay timer cleanup Made-with: Cursor
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
Completed review of the
ButtonandButtonGroupcomponents as part ofthe ant-design-vue refactoring project.
Focused on visual parity with old component, API compatibility, style
alignment, and test coverage.
Related: #8497
Changes
🎨 Style — Visual Parity with Old Component
packages/ui/src/components/button/style/index.cssderived from
paddingContentHorizontal - lineWidthvar(--color-accent-hover)controlHeight / 2line-height: 0)font-weight: 400to match old component explicitly🔌 API Compatibility
packages/ui/src/components/button/types.tstype→variantmapping (primary→solid, default→outlined, etc.)outlinedwhen no type/variant specifieddefault→mdicon(VNode) andtitleprops toButtonPropsclickemit with loading/disabled gatingmousedownemit (native event, handled by inheritAttrs)loadingslot fromButtonSlotspackages/ui/src/components/button/Button.vueiconprop support with priority: loading > icon prop > #icon slottitleprop passthrough<Transition>animationonMounted/onUpdated)useConfigInjectpackages/ui/src/components/button/index.tsButton.Groupas sub-component📝 Demos
typeprop for visual paritywarptypo towrapin danger/icon demosant-design-vue) type imports from size/multiple demos✅ Tests (43 → 85 cases, +42 new)
Added test cases in
__tests__/index.test.ts:Updated default variant test (solid → outlined).
Updated all 12 demo snapshots.
All 97 tests passing.
🐛 Related Fix
packages/ui/src/components/radio/style/index.cssReview Checklist
type/sizeprops mapped,icon/titleaddedaria-disabled,aria-busy,role="link"for disabled anchorsdocument/windowat top-level, only inonMounted/onUpdatedMade-with: Cursor
Made with Cursor