Skip to content

Commit

Permalink
feat/export responsive bar props
Browse files Browse the repository at this point in the history
People can use them, if it's not just an inline Omit type
  • Loading branch information
Sam Jones committed Jul 21, 2023
1 parent 2250a31 commit 573ee8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/bar/src/ResponsiveBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import { Bar } from './Bar'
import { BarDatum, BarSvgProps } from './types'
import { ResponsiveWrapper } from '@nivo/core'

export type ResponsiveBarSvgProps<RawDatum extends BarDatum> = Omit<
BarSvgProps<RawDatum>,
'height' | 'width'
>

export const ResponsiveBar = <RawDatum extends BarDatum>(
props: Omit<BarSvgProps<RawDatum>, 'height' | 'width'>
props: ResponsiveBarSvgProps<RawDatum>
) => (
<ResponsiveWrapper>
{({ width, height }) => <Bar<RawDatum> width={width} height={height} {...props} />}
Expand Down
7 changes: 6 additions & 1 deletion packages/bar/src/ResponsiveBarCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { BarCanvas } from './BarCanvas'
import { ForwardedRef, forwardRef } from 'react'
import { ResponsiveWrapper } from '@nivo/core'

export type ResponsiveBarCanvasProps<RawDatum extends BarDatum> = Omit<
BarCanvasProps<RawDatum>,
'height' | 'width'
>

export const ResponsiveBarCanvas = forwardRef(function ResponsiveBarCanvas<
RawDatum extends BarDatum
>(props: Omit<BarCanvasProps<RawDatum>, 'height' | 'width'>, ref: ForwardedRef<HTMLCanvasElement>) {
>(props: ResponsiveBarCanvasProps<RawDatum>, ref: ForwardedRef<HTMLCanvasElement>) {
return (
<ResponsiveWrapper>
{({ width, height }) => (
Expand Down

0 comments on commit 573ee8c

Please sign in to comment.