Skip to content

feat: 新增 style.radius 数组表达式#7690

Open
lxfu1 wants to merge 2 commits into
v5from
feat/radius-support-array-expression
Open

feat: 新增 style.radius 数组表达式#7690
lxfu1 wants to merge 2 commits into
v5from
feat/radius-support-array-expression

Conversation

@lxfu1

@lxfu1 lxfu1 commented Jun 18, 2026

Copy link
Copy Markdown
Member
Checklist
  • npm test passes
  • benchmarks are included
  • commit message follows commit guidelines
  • documents are updated
Description of change

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/shape/interval/color.ts
Comment thread src/shape/interval/color.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 parseRadius to normalize radius as [topLeft, topRight, bottomRight, bottomLeft].
  • Updated interval color/rect rendering and funnel shape rendering to derive per-corner radii from style.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,
Comment on lines 124 to 126
const path = arc()
.cornerRadius(radius as number)
.cornerRadius(Array.isArray(radius) ? radius[0] : (radius as number))
.padAngle((inset * Math.PI) / 180);
Comment on lines +34 to +37
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);
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.

2 participants