From 4eb54cad40f8772ee45bab1664d5767d2b765136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 27 May 2021 14:50:48 +0200 Subject: [PATCH] fix(packages): remove `global` from default props (#1544) * fix(bar): remove `global` from default props * fix(calendar): remove `global` from default props * fix(chord): remove `global` from default props * fix(geo): remove `global` from default props * fix(heatmap): remove `global` from default props * fix(line): remove `global` from default props * fix(network): remove `global` from default props * fix(parallel-coordinates): remove `global` from default props * fix(scatterplot): remove `global` from default props * fix(swarmplot): remove `global` from default props * fix(treemap): remove `global` from default props * fix(waffle): remove `global` from default props --- packages/bar/src/props.js | 3 +-- packages/calendar/src/props.js | 3 +-- packages/chord/src/props.js | 3 +-- packages/geo/src/props.js | 3 +-- packages/heatmap/src/props.js | 3 +-- packages/line/src/props.js | 3 +-- packages/network/src/props.js | 3 +-- packages/parallel-coordinates/src/ParallelCoordinatesCanvas.js | 3 +-- packages/scatterplot/src/props.js | 3 +-- packages/swarmplot/src/props.js | 3 +-- packages/treemap/src/props.js | 3 +-- packages/waffle/src/props.js | 3 +-- 12 files changed, 12 insertions(+), 24 deletions(-) diff --git a/packages/bar/src/props.js b/packages/bar/src/props.js index 5beb47887..386664403 100644 --- a/packages/bar/src/props.js +++ b/packages/bar/src/props.js @@ -152,8 +152,7 @@ export const BarDefaultProps = { annotations: [], - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } export const BarSvgDefaultProps = { diff --git a/packages/calendar/src/props.js b/packages/calendar/src/props.js index 63d38393f..c2ce3628a 100644 --- a/packages/calendar/src/props.js +++ b/packages/calendar/src/props.js @@ -117,6 +117,5 @@ export const CalendarDefaultProps = { export const CalendarCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/chord/src/props.js b/packages/chord/src/props.js index 74a11952a..25c79d138 100644 --- a/packages/chord/src/props.js +++ b/packages/chord/src/props.js @@ -122,6 +122,5 @@ export const ChordDefaultProps = { export const ChordCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/geo/src/props.js b/packages/geo/src/props.js index dafa7ad78..2be2a3b87 100644 --- a/packages/geo/src/props.js +++ b/packages/geo/src/props.js @@ -113,8 +113,7 @@ export const GeoMapDefaultProps = { export const GeoMapCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } const commonChoroplethDefaultProps = { diff --git a/packages/heatmap/src/props.js b/packages/heatmap/src/props.js index c8dfa95e8..bbae2c9ba 100644 --- a/packages/heatmap/src/props.js +++ b/packages/heatmap/src/props.js @@ -99,8 +99,7 @@ export const HeatMapDefaultProps = { cellHoverOthersOpacity: 0.35, // canvas specific - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } export const HeatMapSvgDefaultProps = { diff --git a/packages/line/src/props.js b/packages/line/src/props.js index 350ac9e60..585ccae48 100644 --- a/packages/line/src/props.js +++ b/packages/line/src/props.js @@ -212,6 +212,5 @@ export const LineDefaultProps = { export const LineCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/network/src/props.js b/packages/network/src/props.js index eb7a6a2f2..ea6e31a94 100644 --- a/packages/network/src/props.js +++ b/packages/network/src/props.js @@ -83,6 +83,5 @@ export const NetworkDefaultProps = { export const NetworkCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/parallel-coordinates/src/ParallelCoordinatesCanvas.js b/packages/parallel-coordinates/src/ParallelCoordinatesCanvas.js index 8c2efe20f..58fb1958a 100644 --- a/packages/parallel-coordinates/src/ParallelCoordinatesCanvas.js +++ b/packages/parallel-coordinates/src/ParallelCoordinatesCanvas.js @@ -130,8 +130,7 @@ ParallelCoordinatesCanvas.propTypes = { const WrappedParallelCoordinatesCanvas = withContainer(ParallelCoordinatesCanvas) WrappedParallelCoordinatesCanvas.defaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } export default WrappedParallelCoordinatesCanvas diff --git a/packages/scatterplot/src/props.js b/packages/scatterplot/src/props.js index ef70d1402..fa2f46227 100644 --- a/packages/scatterplot/src/props.js +++ b/packages/scatterplot/src/props.js @@ -151,8 +151,7 @@ export const ScatterPlotDefaultProps = { export const ScatterPlotCanvasDefaultProps = { ...commonDefaultProps, layers: ['grid', 'axes', 'nodes', 'mesh', 'legends', 'annotations'], - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } export const NodePropType = PropTypes.shape({ diff --git a/packages/swarmplot/src/props.js b/packages/swarmplot/src/props.js index 1ad99624c..5b6b7602c 100644 --- a/packages/swarmplot/src/props.js +++ b/packages/swarmplot/src/props.js @@ -132,6 +132,5 @@ export const SwarmPlotDefaultProps = { export const SwarmPlotCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/treemap/src/props.js b/packages/treemap/src/props.js index cbc29770a..7737e42c9 100644 --- a/packages/treemap/src/props.js +++ b/packages/treemap/src/props.js @@ -122,6 +122,5 @@ export const TreeMapHtmlDefaultProps = { export const TreeMapCanvasDefaultProps = { ...commonDefaultProps, - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, } diff --git a/packages/waffle/src/props.js b/packages/waffle/src/props.js index 6d9dac2d6..a1d10fac0 100644 --- a/packages/waffle/src/props.js +++ b/packages/waffle/src/props.js @@ -103,6 +103,5 @@ export const WaffleHtmlDefaultProps = { export const WaffleCanvasDefaultProps = { ...commonDefaultProps, legends: [], - pixelRatio: - global.window && global.window.devicePixelRatio ? global.window.devicePixelRatio : 1, + pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, }