File tree Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ class App extends Component {
147147 // glByDefault
148148 // traceTypesConfig={traceTypesConfig}
149149 // makeDefaultTrace={() => ({type: 'scattergl', mode: 'markers'})}
150+ // fontOptions={[{label:'Arial', value: 'arial'}]}
150151 >
151152 < DefaultEditor >
152153 < Panel group = "Dev" name = "JSON" >
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class EditorControls extends Component {
5555 showFieldTooltips : this . props . showFieldTooltips ,
5656 glByDefault : this . props . glByDefault ,
5757 mapBoxAccess : this . props . mapBoxAccess ,
58+ fontOptions : this . props . fontOptions ,
5859 } ;
5960 }
6061
@@ -344,6 +345,7 @@ EditorControls.propTypes = {
344345 makeDefaultTrace : PropTypes . func ,
345346 glByDefault : PropTypes . bool ,
346347 mapBoxAccess : PropTypes . bool ,
348+ fontOptions : PropTypes . array ,
347349} ;
348350
349351EditorControls . defaultProps = {
@@ -383,6 +385,7 @@ EditorControls.childContextTypes = {
383385 showFieldTooltips : PropTypes . bool ,
384386 glByDefault : PropTypes . bool ,
385387 mapBoxAccess : PropTypes . bool ,
388+ fontOptions : PropTypes . array ,
386389} ;
387390
388391export default EditorControls ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, {Component} from 'react';
22import createPlotComponent from 'react-plotly.js/factory' ;
33import EditorControls from './EditorControls' ;
44import PropTypes from 'prop-types' ;
5+ import { DEFAULT_FONTS } from 'lib/constants' ;
56
67class PlotlyEditor extends Component {
78 constructor ( props ) {
@@ -31,6 +32,7 @@ class PlotlyEditor extends Component {
3132 mapBoxAccess = { Boolean (
3233 this . props . config && this . props . config . mapboxAccessToken
3334 ) }
35+ fontOptions = { this . props . fontOptions }
3436 >
3537 { this . props . children }
3638 </ EditorControls >
@@ -82,11 +84,13 @@ PlotlyEditor.propTypes = {
8284 } ) ,
8385 makeDefaultTrace : PropTypes . func ,
8486 glByDefault : PropTypes . bool ,
87+ fontOptions : PropTypes . array ,
8588} ;
8689
8790PlotlyEditor . defaultProps = {
8891 hideControls : false ,
8992 showFieldTooltips : false ,
93+ fontOptions : DEFAULT_FONTS ,
9094} ;
9195
9296export default PlotlyEditor ;
Original file line number Diff line number Diff line change 11import Dropdown from './Dropdown' ;
22import React from 'react' ;
3- import { DEFAULT_FONTS } from 'lib/constants ' ;
3+ import PropTypes from 'prop-types ' ;
44
55/* eslint-disable react/prop-types */
66const styledRenderer = ( { value, label} ) => (
77 < span style = { { fontFamily : value } } > { label } </ span >
88) ;
99/* eslint-enable react/prop-types */
1010
11- const FontSelector = props => {
12- let options ;
13- if ( Array . isArray ( props . options ) ) {
14- options = props . options ;
15- } else {
16- options = [ ...DEFAULT_FONTS ] ;
17- }
11+ const FontSelector = ( props , context ) => {
1812 return (
1913 < Dropdown
2014 { ...props }
21- options = { options }
15+ options = { context . fontOptions }
2216 valueRenderer = { styledRenderer }
2317 optionRenderer = { styledRenderer }
2418 />
@@ -33,4 +27,8 @@ FontSelector.defaultProps = {
3327 clearable : false ,
3428} ;
3529
30+ FontSelector . contextTypes = {
31+ fontOptions : PropTypes . array ,
32+ } ;
33+
3634export default FontSelector ;
You can’t perform that action at this time.
0 commit comments