Skip to content

Commit 3b59d22

Browse files
authored
Merge pull request #322 from plotly/AxesFold-refactor
Put AxesSelector into AxesFold by default
2 parents a6eb9e4 + 333f37d commit 3b59d22

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import AxesSelector from '../fields/AxesSelector';
2+
import Fold from './Fold';
3+
import PropTypes from 'prop-types';
4+
import React, {Component} from 'react';
5+
import {connectAxesToLayout} from 'lib';
6+
7+
class AxesFold extends Component {
8+
render() {
9+
return this.props.children ? (
10+
<Fold {...this.props}>
11+
<AxesSelector />
12+
{this.props.children}
13+
</Fold>
14+
) : null;
15+
}
16+
}
17+
18+
AxesFold.propTypes = {
19+
children: PropTypes.any,
20+
};
21+
22+
AxesFold.plotly_editor_traits = {foldable: true};
23+
24+
export default connectAxesToLayout(AxesFold);

src/components/containers/derived.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import React from 'react';
22
import Panel from './Panel';
3-
import Fold from './Fold';
43
import Section from './Section';
54
import PropTypes from 'prop-types';
65

7-
import {
8-
connectLayoutToPlot,
9-
connectAxesToLayout,
10-
containerConnectedContextTypes,
11-
} from 'lib';
6+
import {connectLayoutToPlot, containerConnectedContextTypes} from 'lib';
127

138
const LayoutPanel = connectLayoutToPlot(Panel);
149

15-
const AxesFold = connectAxesToLayout(Fold);
16-
1710
const TraceTypeSection = (props, context) => {
1811
const {fullContainer} = context;
1912
if (
@@ -39,4 +32,4 @@ TraceTypeSection.defaultProps = {
3932
traceTypes: [],
4033
};
4134

42-
export {AxesFold, LayoutPanel, TraceTypeSection};
35+
export {LayoutPanel, TraceTypeSection};

src/components/containers/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import AnnotationAccordion from './AnnotationAccordion';
2+
import AxesFold from './AxesFold';
23
import Fold from './Fold';
34
import MenuPanel from './MenuPanel';
45
import Panel from './Panel';
56
import Section from './Section';
67
import TraceAccordion from './TraceAccordion';
78
import TraceMarkerSection from './TraceMarkerSection';
8-
import {AxesFold, LayoutPanel, TraceTypeSection} from './derived';
9+
import {LayoutPanel, TraceTypeSection} from './derived';
910
import TraceRequiredPanel from './TraceRequiredPanel';
1011
import SingleSidebarItem from './SingleSidebarItem';
1112

src/default_panels/StyleAxesPanel.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
AxesSelector,
54
AxesRange,
65
ColorPicker,
76
Dropdown,
@@ -21,15 +20,13 @@ import {localize} from '../lib';
2120
const StyleAxesPanel = ({localize: _}) => (
2221
<TraceRequiredPanel>
2322
<AxesFold name={_('Titles')}>
24-
<AxesSelector />
2523
<TextEditor attr="title" />
2624
<FontSelector label={_('Typeface')} attr="titlefont.family" />
2725
<Numeric label={_('Font Size')} attr="titlefont.size" units="px" />
2826
<ColorPicker label={_('Font Color')} attr="titlefont.color" />
2927
</AxesFold>
3028

3129
<AxesFold name={_('Range')}>
32-
<AxesSelector />
3330
<Section name={_('Selection')} attr="autorange">
3431
<Radio
3532
attr="autorange"
@@ -51,8 +48,6 @@ const StyleAxesPanel = ({localize: _}) => (
5148
</AxesFold>
5249

5350
<AxesFold name={_('Lines')}>
54-
<AxesSelector />
55-
5651
<Section name={_('Axis Line')} attr="showline">
5752
<Radio
5853
attr="showline"
@@ -119,7 +114,6 @@ const StyleAxesPanel = ({localize: _}) => (
119114
</AxesFold>
120115

121116
<AxesFold name={_('Tick Labels')}>
122-
<AxesSelector />
123117
<Section name={_('Tick Labels')} attr="showticklabels">
124118
<Radio
125119
attr="showticklabels"
@@ -223,7 +217,6 @@ const StyleAxesPanel = ({localize: _}) => (
223217
</Section>
224218
</AxesFold>
225219
<AxesFold name={_('Tick Markers')}>
226-
<AxesSelector />
227220
<Section name={_('Tick Markers')} attr="ticks">
228221
<Radio
229222
attr="ticks"
@@ -276,7 +269,6 @@ const StyleAxesPanel = ({localize: _}) => (
276269
</Fold>
277270

278271
<AxesFold name={_('Zoom Interactivity')}>
279-
<AxesSelector />
280272
<Radio
281273
attr="fixedrange"
282274
options={[
@@ -286,8 +278,6 @@ const StyleAxesPanel = ({localize: _}) => (
286278
/>
287279
</AxesFold>
288280
<AxesFold name={_('Layout')}>
289-
<AxesSelector />
290-
291281
<Section name={_('Axis Width')} attr="domain[0]">
292282
<Numeric
293283
label={_('Start Position')}
@@ -317,8 +307,6 @@ const StyleAxesPanel = ({localize: _}) => (
317307
</AxesFold>
318308

319309
<AxesFold name={_('Hover Projections')}>
320-
<AxesSelector />
321-
322310
<Radio
323311
attr="showspikes"
324312
options={[

0 commit comments

Comments
 (0)