Skip to content

Commit c1959c3

Browse files
committed
Review comments
1 parent 42af3f7 commit c1959c3

File tree

8 files changed

+30
-45
lines changed

8 files changed

+30
-45
lines changed

src/EditorControls.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DefaultEditor from './DefaultEditor';
22
import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
4-
import {bem} from './lib';
4+
import {bem, localizeString} from './lib';
55
import {
66
shamefullyClearAxisTypes,
77
shamefullyAdjustAxisRef,
@@ -34,6 +34,8 @@ class EditorControls extends Component {
3434
dataSourceValueRenderer: this.props.dataSourceValueRenderer,
3535
dataSourceOptionRenderer: this.props.dataSourceOptionRenderer,
3636
dictionaries: this.props.dictionaries || {},
37+
localize: key =>
38+
localizeString(this.props.dictionaries || {}, this.props.locale, key),
3739
frames: gd._transitionData ? gd._transitionData._frames : [],
3840
fullData: gd._fullData,
3941
fullLayout: gd._fullLayout,
@@ -313,6 +315,7 @@ EditorControls.childContextTypes = {
313315
graphDiv: PropTypes.any,
314316
layout: PropTypes.object,
315317
locale: PropTypes.string,
318+
localize: PropTypes.func,
316319
onUpdate: PropTypes.func,
317320
plotly: PropTypes.object,
318321
plotSchema: PropTypes.object,

src/components/fields/AxisCreator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class AxisCreator extends Component {
133133
return null;
134134
}
135135

136-
const {localize: _} = this.props;
136+
const {localize: _} = this.context;
137137
const {fullLayout} = this.context;
138138
const axisType = traceTypeToAxisType(this.props.container.type);
139139
const controls = [];
@@ -171,7 +171,6 @@ class AxisCreator extends Component {
171171
}
172172

173173
AxisCreator.propTypes = {
174-
localize: PropTypes.func,
175174
container: PropTypes.object,
176175
fullContainer: PropTypes.object,
177176
};
@@ -180,6 +179,7 @@ AxisCreator.contextTypes = {
180179
data: PropTypes.array,
181180
fullData: PropTypes.array,
182181
fullLayout: PropTypes.object,
182+
localize: PropTypes.func,
183183
};
184184

185185
export default connectToContainer(AxisCreator, {

src/components/fields/ErrorBars.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class ErrorBars extends Component {
6868
}
6969

7070
renderModeSelector() {
71-
const {localize: _} = this.props;
71+
const {localize: _} = this.context;
7272

7373
return (
7474
<Field>
@@ -87,7 +87,7 @@ class ErrorBars extends Component {
8787
}
8888

8989
renderErrorBarControls() {
90-
const {localize: _} = this.props;
90+
const {localize: _} = this.context;
9191
const mode = this.getMode();
9292
const showCustomDataControl = this.props.fullValue.type === 'data';
9393

@@ -163,9 +163,12 @@ class ErrorBars extends Component {
163163

164164
ErrorBars.propTypes = {
165165
attr: PropTypes.string,
166-
localize: PropTypes.func,
167166
fullValue: PropTypes.object,
168167
updatePlot: PropTypes.func,
169168
};
170169

170+
ErrorBars.contextTypes = {
171+
localize: PropTypes.func,
172+
};
173+
171174
export default connectToContainer(ErrorBars);

src/components/fields/derived.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import PropTypes from 'prop-types';
12
import isNumeric from 'fast-isnumeric';
23
import {UnconnectedDropdown} from './Dropdown';
34
import {UnconnectedFlaglist} from './Flaglist';
@@ -13,7 +14,7 @@ import {
1314

1415
export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, {
1516
modifyPlotProps: (props, context, plotProps) => {
16-
const {localize: _} = props;
17+
const {localize: _} = context;
1718
let options = [];
1819

1920
if (
@@ -94,7 +95,7 @@ export const RangesliderVisible = connectToContainer(UnconnectedRadio, {
9495

9596
export const AxisSide = connectToContainer(UnconnectedRadio, {
9697
modifyPlotProps: (props, context, plotProps) => {
97-
const _ = props.localize;
98+
const _ = context.localize;
9899
if (
99100
context.fullContainer &&
100101
context.fullContainer._id &&
@@ -463,7 +464,7 @@ function computeAxesRefOptions(axes, propsAttr) {
463464

464465
export const TextPosition = connectToContainer(UnconnectedDropdown, {
465466
modifyPlotProps: (props, context, plotProps) => {
466-
const {localize: _} = props;
467+
const {localize: _} = context;
467468
let options = [
468469
{label: _('Top Left'), value: 'top left'},
469470
{label: _('Top Center'), value: 'top center'},
@@ -490,7 +491,7 @@ export const TextPosition = connectToContainer(UnconnectedDropdown, {
490491

491492
export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
492493
modifyPlotProps: (props, context, plotProps) => {
493-
const {localize: _} = props;
494+
const {localize: _} = context;
494495
let options = [
495496
{label: _('X'), value: 'x'},
496497
{label: _('Y'), value: 'y'},
@@ -585,7 +586,7 @@ export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
585586

586587
export const FillDropdown = connectToContainer(UnconnectedDropdown, {
587588
modifyPlotProps: (props, context, plotProps) => {
588-
const {localize: _} = props;
589+
const {localize: _} = context;
589590

590591
let options = [
591592
{label: _('None'), value: 'none'},

src/default_panels/GraphCreatePanel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ const GraphCreatePanel = ({localize: _}) => {
8585
</TraceTypeSection>
8686

8787
<PlotlySection name={_('Axes to Use')}>
88-
<AxisCreator attr="fake_attr" localize={_} />
88+
<AxisCreator attr="fake_attr" />
8989
</PlotlySection>
9090

9191
<PlotlySection name={_('Error Bars X')}>
92-
<ErrorBars localize={_} attr="error_x" />
92+
<ErrorBars attr="error_x" />
9393
</PlotlySection>
9494

9595
<PlotlySection name={_('Error Bars Y')}>
96-
<ErrorBars localize={_} attr="error_y" />
96+
<ErrorBars attr="error_y" />
9797
</PlotlySection>
9898

9999
<PlotlySection name={_('Error Bars Z')}>
100-
<ErrorBars localize={_} attr="error_z" />
100+
<ErrorBars attr="error_z" />
101101
</PlotlySection>
102102

103103
<PlotlySection name={_('Header Options')}>

src/default_panels/StyleAxesPanel.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ class StyleAxesPanel extends Component {
7171
}
7272
>
7373
<PlotlySection name={_('Boundaries')} attr="domain[0]">
74-
<AxisOverlayDropdown
75-
label={_('Overlay')}
76-
attr="overlaying"
77-
localize={_}
78-
/>
74+
<AxisOverlayDropdown label={_('Overlay')} attr="overlaying" />
7975
<NumericFractionDomain
8076
label={_('Start Position')}
8177
attr="domain[0]"
@@ -87,12 +83,8 @@ class StyleAxesPanel extends Component {
8783
name={_('Anchor')}
8884
traceTypes={TRACE_TO_AXIS.cartesian}
8985
>
90-
<AxisAnchorDropdown
91-
label={_('Anchor To')}
92-
attr="anchor"
93-
localize={_}
94-
/>
95-
<AxisSide label={_('Side')} attr="side" localize={_} />
86+
<AxisAnchorDropdown label={_('Anchor To')} attr="anchor" />
87+
<AxisSide label={_('Side')} attr="side" />
9688
</TraceTypeSection>
9789
</AxesFold>
9890

src/default_panels/StyleTracesPanel.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@ const StyleTracesPanel = ({localize: _}) => (
5151
/>
5252
<NumericFraction label={_('Opacity')} attr="opacity" />
5353
<ColorPicker label={_('Color')} attr="color" />
54-
<Numeric
55-
showSlider
56-
min={0}
57-
max={1}
58-
step={0.1}
59-
attr="hole"
60-
label={_('Hole')}
61-
/>
54+
<Numeric showSlider step={0.1} attr="hole" label={_('Hole')} />
6255
<PlotlySection name={_('Text Attributes')}>
6356
<Flaglist
6457
attr="textinfo"
@@ -125,7 +118,7 @@ const StyleTracesPanel = ({localize: _}) => (
125118
/>
126119
</PlotlySection>
127120
<PlotlySection name={_('Filled Area')}>
128-
<FillDropdown attr="fill" label={_('Fill to')} localize={_} />
121+
<FillDropdown attr="fill" label={_('Fill to')} />
129122
<ColorPicker label={_('Color')} attr="fillcolor" />
130123
</PlotlySection>
131124
<TraceMarkerSection>
@@ -220,11 +213,7 @@ const StyleTracesPanel = ({localize: _}) => (
220213
<FontSelector label={_('Typeface')} attr="textfont.family" />
221214
<Numeric label={_('Font Size')} attr="textfont.size" units="px" />
222215
<ColorPicker label={_('Font Color')} attr="textfont.color" />
223-
<TextPosition
224-
label={_('Text Position')}
225-
attr="textposition"
226-
localize={_}
227-
/>
216+
<TextPosition label={_('Text Position')} attr="textposition" />
228217
</TraceTypeSection>
229218
<PlotlySection name={_('Colorscale')}>
230219
<ColorscalePicker label={_('Colorscale')} attr="colorscale" />
@@ -373,11 +362,7 @@ const StyleTracesPanel = ({localize: _}) => (
373362
/>
374363
</PlotlySection>
375364
<PlotlySection name={_('On Hover')}>
376-
<HoverInfo
377-
attr="hoverinfo"
378-
label={_('Values Shown On Hover')}
379-
localize={_}
380-
/>
365+
<HoverInfo attr="hoverinfo" label={_('Values Shown On Hover')} />
381366
<Radio
382367
label={_('Show Contour')}
383368
attr="contour.show"

src/lib/connectToContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import unpackPlotProps from './unpackPlotProps';
44
import {getDisplayName} from '../lib';
55

66
export const containerConnectedContextTypes = {
7+
localize: PropTypes.func,
78
container: PropTypes.object,
89
data: PropTypes.array,
910
defaultContainer: PropTypes.object,

0 commit comments

Comments
 (0)