Skip to content

Commit 21fb7ec

Browse files
TraceMarkerSection handles naming section after trace types
1 parent d022316 commit 21fb7ec

File tree

8 files changed

+74
-9
lines changed

8 files changed

+74
-9
lines changed

src/DefaultEditor.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
MenuPanel,
1818
SymbolSelector,
1919
TraceAccordion,
20+
TraceMarkerSection,
2021
TraceSelector,
2122
} from './components';
2223
import {DEFAULT_FONTS} from './constants';
@@ -142,14 +143,21 @@ class DefaultEditor extends Component {
142143
<ColorPicker label={_('Color')} attr="fillcolor" />
143144
</Section>
144145

145-
<Section name={_('Points')}>
146+
<TraceMarkerSection>
147+
<Radio
148+
attr="orientation"
149+
options={[
150+
{label: _('Vertical'), value: 'v'},
151+
{label: _('Horizontal'), value: 'h'},
152+
]}
153+
/>
146154
<ColorPicker label={_('Color')} attr="marker.color" />
147155
<Numeric label={_('Opacity')} step={0.1} attr="marker.opacity" />
148156
<Numeric label={_('Size')} attr="marker.size" />
149157
<SymbolSelector label={_('Symbol')} attr="marker.symbol" />
150158
<Numeric label={_('Border Width')} attr="marker.line.width" />
151159
<ColorPicker label={_('Border Color')} attr="marker.line.color" />
152-
</Section>
160+
</TraceMarkerSection>
153161

154162
<Section name={_('Lines')}>
155163
<Numeric label={_('Width')} step={1.0} attr="line.width" />

src/components/containers/Section.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ class Section extends Component {
4545
}
4646

4747
const isAttr = Boolean(child.props.attr);
48-
const plotProps = isAttr
49-
? unpackPlotProps(child.props, context, child.type)
50-
: {isVisible: true};
48+
let plotProps;
49+
if (child.plotProps) {
50+
plotProps = child.plotProps;
51+
} else if (isAttr) {
52+
plotProps = unpackPlotProps(child.props, context, child.type);
53+
} else {
54+
plotProps = {isVisible: true};
55+
}
5156
const childProps = Object.assign({plotProps}, child.props);
5257
childProps.key = i;
5358
attrChildren.push(cloneElement(child, childProps));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Section from './Section';
2+
import React, {Component} from 'react';
3+
import PropTypes from 'prop-types';
4+
import localize from '../../lib/localize';
5+
6+
class TraceMarkerSection extends Component {
7+
constructor(props, context) {
8+
super(props, context);
9+
this.setLocals(context);
10+
}
11+
12+
componentWillReceiveProps(nextProps, nextContext) {
13+
this.setLocals(nextContext);
14+
}
15+
16+
setLocals(context) {
17+
const _ = this.props.localize;
18+
const traceType = context.fullContainer.type;
19+
if (traceType === 'bar') {
20+
this.name = _('Bars');
21+
} else {
22+
this.name = _('Points');
23+
}
24+
}
25+
26+
render() {
27+
return <Section name={this.name}>{this.props.children}</Section>;
28+
}
29+
}
30+
31+
TraceMarkerSection.propTypes = {
32+
children: PropTypes.node,
33+
localize: PropTypes.func,
34+
name: PropTypes.string,
35+
};
36+
37+
TraceMarkerSection.contextTypes = {
38+
fullContainer: PropTypes.object,
39+
};
40+
41+
export default localize(TraceMarkerSection);

src/components/containers/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import Fold from './Fold';
33
import Panel from './Panel';
44
import Section from './Section';
55
import TraceAccordion from './TraceAccordion';
6+
import TraceMarkerSection from './TraceMarkerSection';
67

7-
export {MenuPanel, Fold, Panel, Section, TraceAccordion};
8+
export {MenuPanel, Fold, Panel, Section, TraceAccordion, TraceMarkerSection};

src/components/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ import {
1212
TraceSelector,
1313
} from './fields';
1414

15-
import {MenuPanel, Fold, Panel, Section, TraceAccordion} from './containers';
15+
import {
16+
MenuPanel,
17+
Fold,
18+
Panel,
19+
Section,
20+
TraceAccordion,
21+
TraceMarkerSection,
22+
} from './containers';
1623
import PanelMenuWrapper from './PanelMenuWrapper';
1724

1825
export {
@@ -32,5 +39,6 @@ export {
3239
Section,
3340
SymbolSelector,
3441
TraceAccordion,
42+
TraceMarkerSection,
3543
TraceSelector,
3644
};

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
MenuPanel,
2828
SymbolSelector,
2929
TraceAccordion,
30+
TraceMarkerSection,
3031
TraceSelector,
3132
} from './components';
3233

@@ -50,6 +51,7 @@ export {
5051
Section,
5152
SymbolSelector,
5253
TraceAccordion,
54+
TraceMarkerSection,
5355
TraceSelector,
5456
connectAxesToLayout,
5557
connectLayoutToPlot,

src/styles/components/fields/_field.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
.field__widget {
3737
width: 64%;
38-
padding-left: 18px;
38+
padding-left: 12px;
3939
display: inline-block;
4040
padding-right: 12px;
4141
}

src/styles/components/widgets/_numeric-input.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
text-align: left;
1515
border-radius: 2px;
1616
padding: 6px 6px 6px 12px;
17-
width: 80px;
17+
width: 62px;
1818
vertical-align: middle;
1919
font-size: inherit;
2020
color: inherit;

0 commit comments

Comments
 (0)