Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bump): allow extra props for Bump data series
- Loading branch information
Showing
14 changed files
with
368 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { createElement } from 'react' | ||
import { BumpDatum, BumpPoint, BumpPointComponent } from './types' | ||
import { BumpDatum, BumpPoint, BumpPointComponent, BumpSerieExtraProps } from './types' | ||
|
||
interface PointsProps<D extends BumpDatum> { | ||
points: BumpPoint<D>[] | ||
pointComponent: BumpPointComponent<D> | ||
interface PointsProps<Datum extends BumpDatum, ExtraProps extends BumpSerieExtraProps> { | ||
points: BumpPoint<Datum, ExtraProps>[] | ||
pointComponent: BumpPointComponent<Datum, ExtraProps> | ||
} | ||
|
||
export const Points = <D extends BumpDatum>({ points, pointComponent }: PointsProps<D>) => { | ||
return ( | ||
<> | ||
{points.map(point => | ||
createElement(pointComponent, { | ||
key: point.id, | ||
point, | ||
}) | ||
)} | ||
</> | ||
) | ||
} | ||
export const Points = <Datum extends BumpDatum, ExtraProps extends BumpSerieExtraProps>({ | ||
points, | ||
pointComponent, | ||
}: PointsProps<Datum, ExtraProps>) => ( | ||
<> | ||
{points.map(point => | ||
createElement(pointComponent, { | ||
key: point.id, | ||
point, | ||
}) | ||
)} | ||
</> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { ResponsiveWrapper } from '@nivo/core' | ||
import { BumpDatum, BumpSvgProps, DefaultBumpDatum } from './types' | ||
import { BumpDatum, BumpSerieExtraProps, BumpSvgProps, DefaultBumpDatum } from './types' | ||
import { Bump } from './Bump' | ||
|
||
export const ResponsiveBump = <D extends BumpDatum = DefaultBumpDatum>( | ||
props: Omit<BumpSvgProps<D>, 'width' | 'height'> | ||
export const ResponsiveBump = < | ||
Datum extends BumpDatum = DefaultBumpDatum, | ||
ExtraProps extends BumpSerieExtraProps = {} | ||
>( | ||
props: Omit<BumpSvgProps<Datum, ExtraProps>, 'width' | 'height'> | ||
) => ( | ||
<ResponsiveWrapper> | ||
{({ width, height }) => <Bump<D> width={width} height={height} {...props} />} | ||
{({ width, height }) => ( | ||
<Bump<Datum, ExtraProps> width={width} height={height} {...props} /> | ||
)} | ||
</ResponsiveWrapper> | ||
) |
Oops, something went wrong.