Skip to content

Commit

Permalink
(feature) add ability to insert extra header components to left/right
Browse files Browse the repository at this point in the history
  • Loading branch information
f3rno authored and JacobPlaster committed Feb 25, 2020
1 parent 9502242 commit 7f50ae9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
9 changes: 6 additions & 3 deletions dist/components/Chart/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ class Chart extends React.Component {
disableTopbar,
onDeleteIndicator,
disableIndicators,
candleLoadingThreshold = 0
candleLoadingThreshold = 0,
extraHeaderComponentsLeft,
extraHeaderComponentsRight,
showMarketLabel
} = this.props;
const height = isFullscreen ? window.innerHeight : this.props.height;
const width = isFullscreen ? window.innerWidth : this.props.width;
Expand All @@ -387,7 +390,7 @@ class Chart extends React.Component {
}
}), !disableTopbar && React.createElement("div", {
className: "bfxc__topbar"
}, React.createElement("p", {
}, extraHeaderComponentsLeft, showMarketLabel && React.createElement("p", {
className: "bfxcs__topbar-market"
}, marketLabel), React.createElement("div", {
className: "bfxcs__topbar-tfs bfxcs__topbar-section"
Expand Down Expand Up @@ -416,7 +419,7 @@ class Chart extends React.Component {
onClick: this.onToggleFullscreen
})), isSyncing && React.createElement("div", {
className: "bfxc__topbar-spinner"
})), !disableToolbar && React.createElement("ul", {
}), extraHeaderComponentsRight), !disableToolbar && React.createElement("ul", {
className: "bfxc__toolbar"
}, React.createElement("li", {
onClick: () => onAddDrawing && onAddDrawing(LineDrawing)
Expand Down
9 changes: 7 additions & 2 deletions dist/components/Chart/Chart.props.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import PropTypes from 'prop-types';
export const propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired
height: PropTypes.number.isRequired,
showMarketLabel: PropTypes.bool,
extraHeaderComponentsLeft: PropTypes.any,
extraHeaderComponentsRight: PropTypes.any
};
export const defaultProps = {};
export const defaultProps = {
showMarketLabel: true
};
14 changes: 10 additions & 4 deletions src/components/Chart/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ class Chart extends React.Component {
const {
marketLabel, bgColor = '#000', candleWidth, candles, onTimeFrameChange,
onAddDrawing, isSyncing, disableToolbar, disableTopbar, onDeleteIndicator,
disableIndicators, candleLoadingThreshold = 0
disableIndicators, candleLoadingThreshold = 0, extraHeaderComponentsLeft,
extraHeaderComponentsRight, showMarketLabel,
} = this.props

const height = isFullscreen ? window.innerHeight : this.props.height
Expand Down Expand Up @@ -365,9 +366,13 @@ class Chart extends React.Component {

{!disableTopbar && (
<div className='bfxc__topbar'>
<p className='bfxcs__topbar-market'>
{marketLabel}
</p>
{extraHeaderComponentsLeft}

{showMarketLabel && (
<p className='bfxcs__topbar-market'>
{marketLabel}
</p>
)}

<div className='bfxcs__topbar-tfs bfxcs__topbar-section'>
<Dropdown
Expand Down Expand Up @@ -420,6 +425,7 @@ class Chart extends React.Component {
</div>

{isSyncing && (<div className='bfxc__topbar-spinner' />)}
{extraHeaderComponentsRight}
</div>
)}

Expand Down
9 changes: 7 additions & 2 deletions src/components/Chart/Chart.props.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import PropTypes from 'prop-types'

export const propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired
height: PropTypes.number.isRequired,
showMarketLabel: PropTypes.bool,
extraHeaderComponentsLeft: PropTypes.any,
extraHeaderComponentsRight: PropTypes.any
}

export const defaultProps = {}
export const defaultProps = {
showMarketLabel: true
}

0 comments on commit 7f50ae9

Please sign in to comment.