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

Remove all references to react-motion #2324

Merged
merged 1 commit into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ pkgs-build: pkgs-types ##@1 packages build all packages
pkgs-types: ##@1 packages build all package types
@pnpm tsc --build ./tsconfig.monorepo.json

pkgs-types-clean: ##@1 packages clean all package types
@pnpm tsc --build --clean ./tsconfig.monorepo.json

pkg-types-%: ##@1 packages generate types for a specific package
@if [ "$${SKIP_TYPES}" != "TRUE" ]; \
then \
Expand Down
2 changes: 0 additions & 2 deletions packages/annotations/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ export const defaultProps = {
noteWidth: 120,
noteTextOffset: 8,
animate: true,
motionStiffness: 90,
motionDamping: 13,
}
4 changes: 2 additions & 2 deletions packages/bar/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CartesianMarkerProps,
Dimensions,
Margin,
ModernMotionProps,
MotionProps,
PropertyAccessor,
SvgDefsAndFill,
Theme,
Expand Down Expand Up @@ -266,7 +266,7 @@ export type BarSvgProps<RawDatum extends BarDatum> = Partial<BarCommonProps<RawD
BarHandlers<RawDatum, SVGRectElement> &
SvgDefsAndFill<ComputedBarDatum<RawDatum>> &
Dimensions &
ModernMotionProps &
MotionProps &
Partial<{
axisBottom: AxisProps | null
axisLeft: AxisProps | null
Expand Down
4 changes: 2 additions & 2 deletions packages/boxplot/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CartesianMarkerProps,
Dimensions,
Margin,
ModernMotionProps,
MotionProps,
PropertyAccessor,
SvgDefsAndFill,
Theme,
Expand Down Expand Up @@ -244,7 +244,7 @@ export type BoxPlotSvgProps<RawDatum extends BoxPlotDatum> = Partial<BoxPlotComm
BoxPlotHandlers<SVGRectElement> &
SvgDefsAndFill<ComputedBoxPlotSummary> &
Dimensions &
ModernMotionProps &
MotionProps &
Partial<{
axisBottom: AxisProps | null
axisLeft: AxisProps | null
Expand Down
6 changes: 3 additions & 3 deletions packages/bullet/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { Box, Dimensions, Theme, Colors, ModernMotionProps } from '@nivo/core'
import { Box, Dimensions, Theme, Colors, MotionProps } from '@nivo/core'
import { InheritedColorConfig } from '@nivo/colors'
import { ScaleLinear } from '@nivo/scales'
import { SpringValues } from '@react-spring/web'
Expand Down Expand Up @@ -91,7 +91,7 @@ export type BulletHandlers = {
export type BulletSvgProps = Partial<CommonBulletProps> &
Dimensions &
BulletHandlers &
ModernMotionProps & {
MotionProps & {
data: Datum[]
}

Expand Down Expand Up @@ -200,7 +200,7 @@ export type BulletItemProps = Omit<
> &
BulletHandlers &
EnhancedDatum &
ModernMotionProps &
MotionProps &
Point & {
measureHeight: number
markerHeight: number
Expand Down
4 changes: 2 additions & 2 deletions packages/bump/src/area-bump/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModernMotionProps, SvgDefsAndFill } from '@nivo/core'
import { MotionProps, SvgDefsAndFill } from '@nivo/core'
import { AreaBumpCommonProps, AreaBumpComputedSerie, DefaultAreaBumpDatum } from './types'
import { AreaTooltip } from './AreaTooltip'

Expand Down Expand Up @@ -54,7 +54,7 @@ const commonDefaultProps: Omit<
export const areaBumpSvgDefaultProps: typeof commonDefaultProps &
SvgDefsAndFill<AreaBumpComputedSerie<DefaultAreaBumpDatum, Record<string, unknown>>> & {
animate: boolean
motionConfig: ModernMotionProps['motionConfig']
motionConfig: MotionProps['motionConfig']
} = {
...commonDefaultProps,
defs: [],
Expand Down
11 changes: 2 additions & 9 deletions packages/bump/src/area-bump/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { FunctionComponent, MouseEvent } from 'react'
import { Area } from 'd3-shape'
import {
Box,
Theme,
Dimensions,
ModernMotionProps,
CssMixBlendMode,
SvgDefsAndFill,
} from '@nivo/core'
import { Box, Theme, Dimensions, MotionProps, CssMixBlendMode, SvgDefsAndFill } from '@nivo/core'
import { InheritedColorConfig, OrdinalColorScaleConfig } from '@nivo/colors'
import { AxisProps } from '@nivo/axes'
import { ScalePoint } from '@nivo/scales'
Expand Down Expand Up @@ -188,4 +181,4 @@ export type AreaBumpSvgProps<
AreaBumpDataProps<Datum, ExtraProps> &
SvgDefsAndFill<AreaBumpComputedSerie<Datum, ExtraProps>> &
Dimensions &
ModernMotionProps
MotionProps
4 changes: 2 additions & 2 deletions packages/bump/src/bump/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModernMotionProps } from '@nivo/core'
import { MotionProps } from '@nivo/core'
import { LineTooltip } from './LineTooltip'
import { Point } from './Point'
import { BumpCommonProps, BumpPointComponent, DefaultBumpDatum } from './types'
Expand Down Expand Up @@ -61,7 +61,7 @@ const commonDefaultProps: Omit<
export const bumpSvgDefaultProps: typeof commonDefaultProps & {
pointComponent: BumpPointComponent<DefaultBumpDatum, Record<string, unknown>>
animate: boolean
motionConfig: ModernMotionProps['motionConfig']
motionConfig: MotionProps['motionConfig']
} = {
...commonDefaultProps,
pointComponent: Point,
Expand Down
4 changes: 2 additions & 2 deletions packages/bump/src/bump/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FunctionComponent, MouseEvent } from 'react'
import { Line as D3Line } from 'd3-shape'
import { Theme, Box, Dimensions, ModernMotionProps } from '@nivo/core'
import { Theme, Box, Dimensions, MotionProps } from '@nivo/core'
import { OrdinalColorScaleConfig, InheritedColorConfig } from '@nivo/colors'
import { AxisProps } from '@nivo/axes'
import { ScalePoint } from '@nivo/scales'
Expand Down Expand Up @@ -181,4 +181,4 @@ export type BumpSvgProps<Datum extends BumpDatum, ExtraProps extends BumpSerieEx
BumpDataProps<Datum, ExtraProps> & {
pointComponent?: BumpPointComponent<Datum, ExtraProps>
} & Dimensions &
ModernMotionProps
MotionProps
4 changes: 2 additions & 2 deletions packages/chord/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Box,
Theme,
Dimensions,
ModernMotionProps,
MotionProps,
CssMixBlendMode,
PropertyAccessor,
ValueFormat,
Expand Down Expand Up @@ -150,7 +150,7 @@ export type ChordCommonProps = {
ariaLabel: AriaAttributes['aria-label']
ariaLabelledBy: AriaAttributes['aria-labelledby']
ariaDescribedBy: AriaAttributes['aria-describedby']
} & Required<ModernMotionProps>
} & Required<MotionProps>

export type ChordSvgProps = Partial<ChordCommonProps> &
ChordDataProps &
Expand Down
11 changes: 2 additions & 9 deletions packages/circle-packing/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import * as React from 'react'
import { Interpolation, SpringValue } from '@react-spring/web'
import {
Box,
ModernMotionProps,
Theme,
PropertyAccessor,
ValueFormat,
SvgDefsAndFill,
} from '@nivo/core'
import { Box, MotionProps, Theme, PropertyAccessor, ValueFormat, SvgDefsAndFill } from '@nivo/core'
import { InheritedColorConfig, OrdinalColorScaleConfig } from '@nivo/colors'

export interface ComputedDatum<RawDatum> {
Expand Down Expand Up @@ -82,7 +75,7 @@ export interface CirclePackingCommonProps<RawDatum> {
tooltip: (props: ComputedDatum<RawDatum>) => JSX.Element
zoomedId?: string | null
animate: boolean
motionConfig: ModernMotionProps['motionConfig']
motionConfig: MotionProps['motionConfig']
role: string
renderWrapper?: boolean
}
Expand Down
16 changes: 0 additions & 16 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,13 @@ export function useTheme(): CompleteTheme
export function usePartialTheme(theme?: Theme): CompleteTheme

export type MotionProps = Partial<{
animate: boolean
motionDamping: number
motionStiffness: number
}>

export type ModernMotionProps = Partial<{
animate: boolean
motionConfig: string | SpringConfig
}>

export function useMotionConfig(): {
animate: boolean
config: SpringConfig
springConfig: {
stiffness: number
damping: number
}
}

export type SvgFillMatcher<T> = (datum: T) => boolean
Expand Down Expand Up @@ -343,13 +333,9 @@ export function Defs(props: DefsProps): JSX.Element
// ------------------------------------------------------------------------

export const defaultAnimate = true
export const defaultMotionStiffness = 90
export const defaultMotionDamping = 15

type MotionDefaultProps = {
animate: true
stiffness: 90
damping: 15
config: 'default'
}
export const motionDefaultProps: MotionDefaultProps
Expand Down Expand Up @@ -409,8 +395,6 @@ interface ContainerProps {
renderWrapper?: boolean
isInteractive?: boolean
animate?: boolean
motionStiffness?: number
motionDamping?: number
motionConfig?: string | SpringConfig
}
type ContainerType = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
Expand Down
19 changes: 1 addition & 18 deletions packages/core/src/components/Container.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { useRef } from 'react'
import PropTypes from 'prop-types'
import { TooltipProvider, Tooltip } from '@nivo/tooltip'
Expand All @@ -23,20 +15,13 @@ export const Container = ({
renderWrapper = true,
isInteractive = true,
animate,
motionStiffness,
motionDamping,
motionConfig,
}) => {
const container = useRef(null)

return (
<ThemeProvider theme={theme}>
<MotionConfigProvider
animate={animate}
stiffness={motionStiffness}
damping={motionDamping}
config={motionConfig}
>
<MotionConfigProvider animate={animate} config={motionConfig}>
<TooltipProvider container={container}>
{/* we should not render the div element if using the HTTP API */}
<ConditionalWrapper
Expand All @@ -58,8 +43,6 @@ Container.propTypes = {
renderWrapper: PropTypes.bool,
theme: PropTypes.object,
animate: PropTypes.bool,
motionStiffness: PropTypes.number,
motionDamping: PropTypes.number,
motionConfig: PropTypes.string,
}

Expand Down
19 changes: 1 addition & 18 deletions packages/core/src/components/LegacyContainer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { useRef, useMemo, useCallback } from 'react'
import PropTypes from 'prop-types'
import {
Expand Down Expand Up @@ -36,8 +28,6 @@ export const LegacyContainer = ({
isInteractive = true,
renderWrapper = true,
animate,
motionStiffness,
motionDamping,
motionConfig,
}) => {
const container = useRef(null)
Expand All @@ -58,12 +48,7 @@ export const LegacyContainer = ({

return (
<ThemeProvider theme={theme}>
<MotionConfigProvider
animate={animate}
stiffness={motionStiffness}
damping={motionDamping}
config={motionConfig}
>
<MotionConfigProvider animate={animate} config={motionConfig}>
<TooltipActionsContext.Provider value={tooltipActions}>
<TooltipStateContext.Provider value={tooltipState}>
{/* we should not render the div element if using the HTTP API */}
Expand All @@ -87,7 +72,5 @@ LegacyContainer.propTypes = {
renderWrapper: PropTypes.bool,
theme: PropTypes.object.isRequired,
animate: PropTypes.bool.isRequired,
motionStiffness: PropTypes.number,
motionDamping: PropTypes.number,
motionConfig: PropTypes.string,
}
10 changes: 0 additions & 10 deletions packages/core/src/defaults/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { scaleOrdinal } from 'd3-scale'
import { schemeSet3 } from 'd3-scale-chromatic'
import { nivoCategoricalColors } from '../lib/colors'

// motion
export const defaultAnimate = true
export const defaultMotionStiffness = 90
export const defaultMotionDamping = 15

// colors
export const defaultCategoricalColors = nivoCategoricalColors
Expand Down
12 changes: 1 addition & 11 deletions packages/core/src/hocs/withContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,14 @@ export const withContainer = WrappedComponent => {
return class extends Component {
render() {
// eslint-disable-next-line react/prop-types
const {
theme,
renderWrapper,
animate,
motionStiffness,
motionDamping,
motionConfig,
...childProps
} = this.props
const { theme, renderWrapper, animate, motionConfig, ...childProps } = this.props

return (
<Container
theme={theme}
renderWrapper={renderWrapper}
isInteractive={childProps.isInteractive}
animate={animate}
motionStiffness={motionStiffness}
motionDamping={motionDamping}
motionConfig={motionConfig}
>
<WrappedComponent {...childProps} />
Expand Down
Loading