Skip to content

Commit 15c29f5

Browse files
remove child.type checks & fix up trace-names (#307)
* remove child.type checks * tweaking trace-name ux * update button css to take up available space if in sidebar * remove unused properties * remove var
1 parent ccfb20b commit 15c29f5

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

src/components/containers/Fold.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ class Fold extends Component {
9696
<div className="fold__top__arrow-title">
9797
{arrowIcon}
9898
{icon}
99-
<div className="fold__top__title">{name}</div>
99+
<div
100+
className="fold__top__title"
101+
dangerouslySetInnerHTML={{__html: name}}
102+
/>
100103
</div>
101104
{deleteButton(deleteContainer)}
102105
</div>

src/components/containers/MenuPanel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ MenuPanel.propTypes = {
6868
question: PropTypes.bool,
6969
show: PropTypes.bool,
7070
};
71+
72+
MenuPanel.plotly_editor_traits = {is_menu_panel: true};

src/components/containers/Section.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Info from '../fields/Info';
2-
import MenuPanel from './MenuPanel';
32
import React, {Component, cloneElement} from 'react';
43
import PropTypes from 'prop-types';
54
import {
@@ -28,7 +27,7 @@ class Section extends Component {
2827
this.sectionVisible = isVisible === true;
2928

3029
this.children = React.Children.map(nextProps.children, child => {
31-
if (child.type === MenuPanel) {
30+
if ((child.type.plotly_editor_traits || {}).is_menu_panel) {
3231
// Process the first menuPanel. Ignore the rest. MenuPanel does
3332
// not affect visibility.
3433
if (!this.menuPanel) {

src/components/containers/SingleSidebarItem.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import PropTypes from 'prop-types';
2-
import React, {cloneElement, Component} from 'react';
3-
import Button from '../widgets/Button';
2+
import React, {Component} from 'react';
43

54
export default class SingleSidebarItem extends Component {
65
render() {
7-
let {children} = this.props;
8-
children = React.Children.map(children, child => {
9-
if (child.type === Button) {
10-
return cloneElement(child, {className: 'button--menu'});
11-
}
12-
return child;
13-
});
14-
return children ? (
15-
<div className="sidebar__item--single">{children}</div>
6+
return this.props.children ? (
7+
<div className="sidebar__item--single">{this.props.children}</div>
168
) : null;
179
}
1810
}

src/default_panels/GraphCreatePanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {localize} from '../lib';
1717
const GraphCreatePanel = ({localize: _}) => {
1818
return (
1919
<TraceAccordion canAdd>
20-
<TraceSelector label={_('Type')} attr="type" show />
2120
<TextEditor label={_('Name')} attr="name" richTextOnly />
21+
<TraceSelector label={_('Type')} attr="type" show />
2222

2323
<Section name={_('Data')}>
2424
<DataSelector label={_('Labels')} attr="labels" />

src/styles/components/widgets/_button.scss

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ button {
3131
position: relative;
3232
overflow: hidden;
3333
}
34-
3534
&__label {
3635
padding-left: var(--spacing-half-unit);
3736
}
@@ -51,9 +50,15 @@ button {
5150
padding-left: 0;
5251
}
5352
}
54-
&--menu {
55-
min-width: 75px;
53+
54+
// If a button is placed in the sidebar,
55+
// it should grow to the width of the available space.
56+
@at-root .sidebar .button {
57+
width: calc(100% - var(--spacing-base-unit));
58+
margin-left: var(--spacing-half-unit);
59+
margin-right: var(--spacing-half-unit);
5660
}
61+
5762
&--default {
5863
@include button();
5964
}

0 commit comments

Comments
 (0)