Skip to content

Storybook: Add story for Cross#3539

Merged
nikolasrieble merged 3 commits into
recharts:masterfrom
nikolasrieble:nikolas.storybook.api.shapes
Apr 18, 2023
Merged

Storybook: Add story for Cross#3539
nikolasrieble merged 3 commits into
recharts:masterfrom
nikolasrieble:nikolas.storybook.api.shapes

Conversation

@nikolasrieble

Copy link
Copy Markdown
Contributor

Description

Strangely I could not get the cross to work without the Customized wrapper, although I do not even use what Customized provides, namely access to chart content.

Either way, this does work, all props are usable controls, and it documents the Cross component, lets iterate.

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.
  • All new and existing tests passed.

@nikolasrieble
nikolasrieble requested a review from Yilun-Sun April 17, 2023 20:30
@nikolasrieble

Copy link
Copy Markdown
Contributor Author

@akamfoad Have a look at this example. After this is merged, when can see whether the component behaves the same after refactoring in storybook. Also, please do review this PR. I could not get the Cross to work without the Customized wrapper.

@Yilun-Sun

Copy link
Copy Markdown
Member

I think you can only use shapes like Cross in Customized, since the chart only accept components of:
image

Comment thread storybook/stories/API/shapes/Cross.mdx Outdated

# Cross

TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The parent component would be Customzied and no child support.

@Yilun-Sun Yilun-Sun added the storybook Issues that require updating or creating stories in the storybook label Apr 18, 2023
Comment thread storybook/stories/API/shapes/Cross.mdx Outdated

# Cross

TODO

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.

Suggested change
TODO
## Parent Component
The Cross can be used in combination with `<Customized />` to render inside all charts that Customized can be used. Rendering `Cross` directly inside charts doesn't have any effect.
You can use Cross with Customized like below: (please remove the `\` I added it to escape GitHub automatic matching)
\```jsx
<Customized component={<Cross {...crossProps} />}>
\```
## Child component
The Cross component is a leaf component, it doesn't render anything as its child.
## Properties
Properties in the groups Other and Internal are not recommended to be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Strictly speaking, Customised also is not a parent component.

Example

<LineChart>
    <Line/>
</LineChart>

Here LineChart is a parent of Line.
But Cross can not be used as such with Customised.

Really all the shapes are helper components to customise anything.
Example: One can use Rectangles to create custom bar shapes.

So I would argue, Cross has neither child nor parent.

@akamfoad akamfoad Apr 18, 2023

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.

You're right, please feel free to dismiss the Parent components part.

Comment thread storybook/stories/API/shapes/Cross.stories.tsx Outdated
Comment thread storybook/stories/API/shapes/Cross.mdx Outdated
@nikolasrieble
nikolasrieble merged commit 1720700 into recharts:master Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storybook Issues that require updating or creating stories in the storybook

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants