Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] - Recharts issue 3113 filterProps #4127

Conversation

BuddhikaGeasman
Copy link

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

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:

  • 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 added tests to cover my changes.
  • I have added a storybook story or extended an existing story to show my changes
  • All new and existing tests passed.

Copy link
Member

@ckifer ckifer left a comment

Choose a reason for hiding this comment

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

Some questions. I don't think we need to do any camel case transformation...

src/util/svgUtils/types.ts Show resolved Hide resolved
@@ -0,0 +1,99 @@
export type SVGElementAttributeTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

This list should directly reflect https://developer.mozilla.org/en-US/docs/Web/SVG/Element. If there are things that are no longer on that list we can probably clean the list up a bit

Copy link
Author

Choose a reason for hiding this comment

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

Yes i would clean it, i was planning to do an update after i received some feedback!

) => {
/**
* If the svg element type is explicitly included, check against the filtered element key map
* to determine if there are attributes that should only exist on that element type.
* @todo Add an internal cjs version of https://github.com/wooorm/svg-element-attributes for full coverage.
*/
const matchingElementTypeKeys = FilteredElementKeyMap?.[svgElementType] ?? [];
const svgElementAttributesInCamelCase = getSVGElementAttributesInCamelCase(svgElementAttributes);
Copy link
Member

Choose a reason for hiding this comment

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

the props we accept are also in camel case for the same reason (react), why do we need to do any transformation here?

Copy link
Author

Choose a reason for hiding this comment

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

I created the getSVGElementAttributesInCamelCase cause the svgElementAttributes object structured as follows. I should have simply create the util to return the converted object without having to do the conversion multiple times.

circle: [
    'alignment-baseline',
    'baseline-shift',
    'clip',
    'clip-path',
    'clip-rule',
    'color',
    ...
    ]
    ```

Copy link
Member

Choose a reason for hiding this comment

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

You can probably do the conversion and once and keep it stored as camel case, we don't need to do it at runtime

const svgElementAttributesInCamelCase = getSVGElementAttributesInCamelCase(svgElementAttributes);
const matchingElementTypeKeys = svgElementAttributesInCamelCase?.[svgElementType] ?? [];

const { polygon, polyline, svg, ...rest } = svgElementAttributesInCamelCase;
Copy link
Member

Choose a reason for hiding this comment

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

why do these three need to be extracted out?

Copy link
Author

Choose a reason for hiding this comment

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

this was me, messing with things!

@ckifer
Copy link
Member

ckifer commented May 2, 2024

Going to close this for now since follow ups haven't been addressed. Can re-open later

@ckifer ckifer closed this May 2, 2024
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.

None yet

2 participants