Skip to content

fix(button): review Button component#8511

Open
trp1119 wants to merge 1 commit intovueComponent:feat/vaporfrom
trp1119:review/button
Open

fix(button): review Button component#8511
trp1119 wants to merge 1 commit intovueComponent:feat/vaporfrom
trp1119:review/button

Conversation

@trp1119
Copy link
Copy Markdown

@trp1119 trp1119 commented Mar 26, 2026

Summary

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: #8497

Changes

🎨 Style — Visual Parity with Old Component

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

🔌 API Compatibility

packages/ui/src/components/button/types.ts

  • Add legacy typevariant mapping (primary→solid, default→outlined, etc.)
  • Fix default variant to outlined when no type/variant specified
  • Add legacy size mapping including defaultmd
  • 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

📝 Demos

  • 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

✅ Tests (43 → 85 cases, +42 new)

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.

🐛 Related Fix

packages/ui/src/components/radio/style/index.css

  • Fix Radio.Button checked state left border artifact in group

Review Checklist

  • Correctness — Visual rendering matches old ant-design-vue component
  • API compatibility — Legacy type/size props mapped, icon/title added
  • Accessibilityaria-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

Made with Cursor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant