Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions dev/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, {Component} from 'react';
import {hot} from 'react-hot-loader';
import plotly from 'plotly.js/dist/plotly';
import '../src/styles/main.scss';
import Nav from './Nav';
import PlotlyEditor from '../src';
import 'react-select/dist/react-select.css';
import ReactJson from 'react-json-view';
import Select from 'react-select';
import PlotlyEditor, {DefaultEditor, Panel} from '../src';

// https://github.com/plotly/react-chart-editor#mapbox-access-tokens
import ACCESS_TOKENS from '../accessTokens';
Expand Down Expand Up @@ -82,12 +84,43 @@ class App extends Component {
useResizeHandler
debug
advancedTraceTypeSelector
/>
<Nav
currentMockIndex={this.state.currentMockIndex}
loadMock={this.loadMock}
mocks={this.state.mocks}
/>
>
{' '}
<DefaultEditor>
<Panel group="Dev" name="JSON">
<Select
clearable={true}
value={this.state.currentMockIndex}
name="mock-dropdown"
options={this.state.mocks.map((item, i) => ({
label: item,
value: i,
}))}
searchable={true}
searchPromptText="Search for a mock"
onChange={option => this.loadMock(option.value)}
noResultsText={'No Results'}
placeholder={'Search for a mock'}
/>
<br />
<ReactJson
enableClipboard={false}
name={false}
displayDataTypes={false}
displayObjectSize={false}
indentWidth={2}
onAdd={({updated_src}) => this.setState(updated_src)}
onEdit={({updated_src}) => this.setState(updated_src)}
onDelete={({updated_src}) => this.setState(updated_src)}
src={{
data: this.state.data,
layout: this.state.layout,
Copy link
Contributor

@VeraZab VeraZab Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frames? config?

frames: this.state.frames,
}}
/>
</Panel>
</DefaultEditor>
</PlotlyEditor>
</div>
);
}
Expand Down
35 changes: 0 additions & 35 deletions dev/Nav.js

This file was deleted.

46 changes: 2 additions & 44 deletions dev/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,7 @@ body {
}

.app {
height: calc(100vh - 50px);
max-height: calc(100vh - 50px);
height: 100vh;
max-height: 100vh;
}

.mock-nav {
height: 50px;
width: 100%;
background-color: #506784;
display: inline-flex;
color: white;
}

.mock-nav__label {
line-height: 50px;
padding-left: 10px;
}

.mock-nav__select {
width: 300px;
margin-left: 20px;
margin-right: 20px;
margin-top: 7px;
}

.Select.open-top .Select-menu-outer {
top: auto;
bottom: 100%;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: unset;
border-bottom-left-radius: unset;
}
.Select.open-top .Select-option:first-child {
border-top-right-radius: 4px;
border-top-left-radius: 4px;
}
.Select.open-top .Select-option:last-child {
border-bottom-right-radius: unset;
border-bottom-left-radius: unset;
}
.Select.open-top .Select.is-open > .Select-control {
border-top-right-radius: unset;
border-top-left-radius: unset;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-hot-loader": "^4.0.0-beta.21",
"react-json-view": "^1.16.1",
"react-test-renderer": "^16.2.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.1",
Expand Down
4 changes: 3 additions & 1 deletion src/DefaultEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
StyleUpdateMenusPanel,
} from './default_panels';

const DefaultEditor = ({localize: _}) => (
const DefaultEditor = ({children, localize: _}) => (
<Fragment>
<PanelMenuWrapper>
<GraphCreatePanel group={_('Graph')} name={_('Create')} />
Expand All @@ -30,12 +30,14 @@ const DefaultEditor = ({localize: _}) => (
<StyleImagesPanel group={_('Style')} name={_('Images')} />
<StyleSlidersPanel group={_('Style')} name={_('Sliders')} />
<StyleUpdateMenusPanel group={_('Style')} name={_('Update Menus')} />
{children ? children : null}
</PanelMenuWrapper>
</Fragment>
);

DefaultEditor.propTypes = {
localize: PropTypes.func,
children: PropTypes.node,
};

export default localize(DefaultEditor);
4 changes: 4 additions & 0 deletions src/components/PanelMenuWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class PanelsWithSidebar extends Component {
let groupIndex;

React.Children.forEach(children, child => {
if (!child) {
return;
}
const group = child.props.group;
const name = child.props.name;

Expand Down Expand Up @@ -81,6 +84,7 @@ class PanelsWithSidebar extends Component {
{React.Children.map(
this.props.children,
(child, i) =>
child === null ||
this.state.group !== child.props.group ||
this.state.panel !== child.props.name
? null
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PlotlyEditor from './PlotlyEditor';
import DefaultEditor from './DefaultEditor';
import EditorControls from './EditorControls';
import {
connectAnnotationToLayout,
Expand Down Expand Up @@ -143,6 +144,7 @@ export {
localizeString,
walkObject,
EditorControls,
DefaultEditor,
};

export default PlotlyEditor;
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module.exports = {
},
],
},

plugins: [new webpack.IgnorePlugin(/vertx/)],
devServer: {
open: true,
contentBase: './dev',
Expand Down