Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces BpkTextV2, a new text component that extends the existing BpkText functionality with prefix and suffix icon support using the compound components pattern. The original BpkText component remains unchanged to maintain backward compatibility.
Changes:
- Added compound components API (
BpkText.LeadingIcon,BpkText.TrailingIcon,BpkText.Content) for icon integration - Implemented fixed 0.5rem spacing between icons and text with automatic RTL support
- Added icon-only mode with accessibility label support
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/bpk-component-text/src/BpkTextV2/BpkText.tsx |
Main component implementation with Context API for icon coordination |
packages/bpk-component-text/src/BpkTextV2/BpkText.module.scss |
Styles for icon spacing, flexbox layout, and text variants |
packages/bpk-component-text/src/BpkTextV2/index.ts |
Export file for component and types |
packages/bpk-component-text/src/BpkTextV2/BpkText-test.tsx |
Unit tests covering icon rendering and functionality |
packages/bpk-component-text/src/BpkTextV2/accessibility-test.tsx |
Accessibility tests using jest-axe |
packages/bpk-component-text/src/BpkTextV2/README.md |
Documentation for V2 features and migration guide |
examples/bpk-component-text-v2/examples.tsx |
Example implementations of the new component |
examples/bpk-component-text-v2/stories.tsx |
Storybook stories for visual testing |
examples/bpk-component-text-v2/examples.module.scss |
Styles for example components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import ChevronDownIconSm from '../../packages/bpk-component-icon/sm/chevron-down'; | ||
| import CloseIconSm from '../../packages/bpk-component-icon/sm/close-circle'; | ||
| import BpkText, { TEXT_COLORS, TEXT_STYLES } from '../../packages/bpk-component-text/src/BpkTextV2/BpkText'; | ||
| import { withDefaultProps , cssModules } from '../../packages/bpk-react-utils'; |
There was a problem hiding this comment.
Extra space before comma in import statement. Should be 'withDefaultProps,' instead of 'withDefaultProps ,'.
| import { withDefaultProps , cssModules } from '../../packages/bpk-react-utils'; | |
| import { withDefaultProps, cssModules } from '../../packages/bpk-react-utils'; |
|
Visit https://backpack.github.io/storybook-prs/4150 to see this build running in a browser. |
Browser supportIf this is a visual change, make sure you've tested it in multiple browsers. |
[BpkTextV2] Add Icon Support with Compound Components Pattern
🎯 Summary
This PR introduces BpkTextV2, a new version of the BpkText component that adds prefix and suffix icon support using the compound components pattern (similar to Ark UI). The original BpkText component remains unchanged to maintain backward compatibility.
✨ Features
New Compound Components API
BpkTextV2 introduces three new sub-components:
BpkText.LeadingIcon- Prefix icon supportBpkText.TrailingIcon- Suffix icon supportBpkText.Content- Optional explicit content wrapperKey Capabilities
bpk-spacing-md()tokenaccessibilityLabelprop for screen readersmargin-inline-start/end)fill: currentColor📝 Usage Examples
Basic Icon Support
Icon-Only Mode
🏗️ Technical Implementation
Architecture
useStatehooks in sub-componentsinline-flexwithalign-items: centerfor alignment<span>elements with appropriate classesrole="img"for icon-only span elementsCSS Classes
📦 Files Added
Component Implementation
packages/bpk-component-text/src/BpkTextV2/BpkText.tsxpackages/bpk-component-text/src/BpkTextV2/BpkText.module.scsspackages/bpk-component-text/src/BpkTextV2/index.tspackages/bpk-component-text/src/BpkTextV2/README.mdTesting
packages/bpk-component-text/src/BpkTextV2/BpkText-test.tsx(37 tests)packages/bpk-component-text/src/BpkTextV2/accessibility-test.tsx(5 tests)Examples & Documentation
examples/bpk-component-text-v2/examples.tsxexamples/bpk-component-text-v2/stories.tsxexamples/bpk-component-text-v2/examples.module.scss✅ Testing
Test Coverage
✅ 37 unit tests - All passing
✅ 5 accessibility tests - All passing with jest-axe
✅ Storybook stories - 4 new icon-specific stories
Manual Testing Checklist
🔄 Backward Compatibility
Important: The original BpkText component is completely unchanged and all existing usages will continue to work. BpkTextV2 is a separate implementation that can be adopted gradually.
Original BpkText
Migration Path
Users can gradually migrate to V2 when they need icon support:
🎨 Design Decisions
Why Compound Components?
User explicitly requested the compound components pattern (like Ark UI) over the props-based approach used in BpkChip because:
Why Not Props-Based?
While BpkChip uses
leadingAccessoryView/trailingAccessoryViewprops, compound components provide:📊 Bundle Impact
🚀 Next Steps
After this PR merges:
📸 Screenshots
See Storybook stories for visual examples:
bpk-component-text-v2/WithLeadingIconbpk-component-text-v2/WithTrailingIconbpk-component-text-v2/WithBothIconsbpk-component-text-v2/IconOnly🤖 Generated with Claude Code