Skip to content

Conversation

@richiepreece
Copy link
Contributor

@richiepreece richiepreece commented Apr 24, 2024

Description

Adding hasSquareCorners prop to allow bar charts to render with square tops.

Related Issue

Adobe Jira ticket AN-338678

Motivation and Context

This is needed to allow square tops for an Adobe Product Analytics feature called "Forked Funnel"

How Has This Been Tested?

Tested in unit tests in this request

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@github-actions
Copy link

1 similar comment
@github-actions
Copy link


// Square radius should have values of 0
expect(squareRadius).toEqual(
expect.objectContaining({
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know about expect.objectContaining. Very cool. The more you know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good way to only check about the properties you care about, regardless of the rest of the object shape.

Comment on lines +183 to +184
const { type, lineWidth, metric, hasSquareCorners } = props;
const value = hasSquareCorners ? 0 : Math.max(1, CORNER_RADIUS - getLineWidthPixelsFromLineWidth(lineWidth) / 2);
Copy link
Member

Choose a reason for hiding this comment

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

Clean and simple

@marshallpete
Copy link
Member

Can you add one thing? In specBuilderTypes.ts ~line 89, there is a type called BarPropsWithDefaults. Can you add hasSquareCorners to the union of props with defaults? You will probably need to add hasSquareCorners: false to a few test files. Run yarn ts after updating `specBuilderTypes to know everywhere that you'll need to add that to.

@marshallpete
Copy link
Member

All of our props that have default values, we update the type so these are no longer optional when used within our code. That way you never have to check if something exists, you know it will. I realize for a boolean prop it's less critical but for consistency it's nice even on boolean props.

@marshallpete
Copy link
Member

Lastly can you update the prop table in the docs: https://github.com/adobe/react-spectrum-charts/wiki/Bar. Just add in the new prop. Simple update.

@sonarqubecloud
Copy link

@github-actions
Copy link

@richiepreece richiepreece merged commit 561991a into main Apr 24, 2024
@richiepreece richiepreece deleted the adobe/AN-338678/hasSquareCorner branch April 24, 2024 21:55
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.

3 participants