feat: 新增 style.radius 数组表达式#7690
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a parseRadius helper function to parse corner radius values (supporting both numbers and arrays) and applies it across rect, Color, and Funnel interval shapes to consistently resolve corner-specific radii. Unit tests for parseRadius are also added. The review feedback highlights two key improvements: adding function overloads to parseRadius to safely handle undefined inputs under strict TypeScript checks, and utilizing parseRadius in the polar coordinate path generator to safely resolve the corner radius and avoid potential undefined values from empty arrays.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR adds support for using an array value for style.radius (interpreted as per-corner radii) in interval-related shapes, and centralizes the radius parsing logic to be reused across shapes.
Changes:
- Introduced
parseRadiusto normalizeradiusas[topLeft, topRight, bottomRight, bottomLeft]. - Updated
intervalcolor/rect rendering andfunnelshape rendering to derive per-corner radii fromstyle.radius(including array input). - Added unit tests for
parseRadius.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/shape/interval/funnel.ts |
Uses parseRadius(radius) to support array-based corner radii for funnel paths. |
src/shape/interval/color.ts |
Adds parseRadius and applies parsed per-corner radii in cartesian rect rendering; adjusts polar cornerRadius handling. |
__tests__/unit/shape/interval-color.spec.ts |
Adds unit coverage for parseRadius behavior on numbers and arrays. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -74,10 +75,10 @@ export const Funnel: SC<FunnelOptions> = (options, context) => { | |||
| const { | |||
| adjustPoints = getFunnelPoints, | |||
| radius, | |||
| const path = arc() | ||
| .cornerRadius(radius as number) | ||
| .cornerRadius(Array.isArray(radius) ? radius[0] : (radius as number)) | ||
| .padAngle((inset * Math.PI) / 180); |
| expect(20 ?? tl).toBe(20); // explicit override | ||
| expect(undefined ?? tr).toBe(10); // fallback to parsed value | ||
| expect(undefined ?? br).toBe(4); | ||
| expect(undefined ?? bl).toBe(4); |
Checklist
npm testpassesDescription of change