Skip to content

Commit

Permalink
Merge branch 'dev' into add-design-elements-to-reports
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/javascript/app/Modules/Reports/Components/market-symbol-icon-row.jsx
  • Loading branch information
easteregg committed Jul 3, 2019
2 parents cbb3efa + 0fed562 commit ab10694
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ContractDrawer extends Component {
<div className='contract-card__type'>
<ContractTypeCell
type={contract_info.contract_type}
is_high_low={Shortcode.isHighLow(contract_info.shortcode)}
is_high_low={Shortcode.isHighLow({ shortcode: contract_info.shortcode })}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const PositionsDrawerCard = ({
<div className='positions-drawer-card__type'>
<ContractTypeCell
type={type}
is_high_low={Shortcode.isHighLow(contract_info.shortcode)}
is_high_low={Shortcode.isHighLow({ shortcode: contract_info.shortcode })}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@ import ImageTouchDark from 'Images/app/trade_explanations/img-touch-no-to
import ImageTouchLight from 'Images/app/trade_explanations/img-touch-no-touch-light.svg';

// TODO: Replace static image svgs with themed GIFs or animated SVGs
const TradeCategoriesGIF = ({ category, className, is_dark }) => {
const TradeCategoriesGIF = ({ category, className, is_dark_theme }) => {
let TradeTypeGIF;
const themed_classes = classNames(className,
{
[`${className}--dark`] : is_dark,
[`${className}--light`]: !is_dark,
[`${className}--dark`] : is_dark_theme,
[`${className}--light`]: !is_dark_theme,
}
);
if (category) {
switch (category) {
case ('rise_fall' || 'rise_fall_equal'):
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageRiseFallDark className={themed_classes} />)
:
(<ImageRiseFallLight className={themed_classes} />);
break;
case 'high_low':
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageHigherLowerDark className={themed_classes} />)
:
(<ImageHigherLowerLight className={themed_classes} />);
break;
case 'match_diff':
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageMatchesDark className={themed_classes} />)
:
(<ImageMatchesLight className={themed_classes} />);
break;
case 'even_odd':
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageEvenOddDark className={themed_classes} />)
:
(<ImageEvenOddLight className={themed_classes} />);
break;
case 'over_under':
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageOverUnderDark className={themed_classes} />)
:
(<ImageOverUnderLight className={themed_classes} />);
break;
case 'touch':
TradeTypeGIF = is_dark ?
TradeTypeGIF = is_dark_theme ?
(<ImageTouchDark className={themed_classes} />)
:
(<ImageTouchLight className={themed_classes} />);
Expand All @@ -74,9 +74,9 @@ const TradeCategoriesGIF = ({ category, className, is_dark }) => {
};

TradeCategoriesGIF.propTypes = {
category : PropTypes.string,
className: PropTypes.string,
is_dark : PropTypes.bool,
category : PropTypes.string,
className : PropTypes.string,
is_dark_theme: PropTypes.bool,
};

export default TradeCategoriesGIF;
2 changes: 2 additions & 0 deletions src/javascript/app/Assets/icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Icon extends React.PureComponent {
className : this.props.className,
classNamePath: this.props.classNamePath,
classNameRect: this.props.classNameRect,
is_dark_theme: this.props.is_dark_theme,
is_disabled : this.props.is_disabled,
onClick : this.props.onClick,
onMouseEnter : this.props.onMouseEnter,
Expand All @@ -122,6 +123,7 @@ Icon.propTypes = {
classNamePath: PropTypes.string,
classNameRect: PropTypes.string,
icon : PropTypes.string,
is_dark_theme: PropTypes.bool,
is_disabled : PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
onClick : PropTypes.func,
type : PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const MarketSymbolIconRow = ({ payload, show_description }) => {
>
<Icon
icon='IconTradeType'
type={(Shortcode.isHighLow())
type={(Shortcode.isHighLow({ shortcode_info: info_from_shortcode }))
? `${info_from_shortcode.category.toLowerCase()}_barrier`
: info_from_shortcode.category.toLowerCase()}
/>
Expand Down
27 changes: 14 additions & 13 deletions src/javascript/app/Modules/Reports/Helpers/shortcode.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
const Shortcode = (() => {
let info_from_shortcode = {};

const extractInfoFromShortcode = (shortcode) => {
const pattern = new RegExp('^([A-Z]+)_((OTC_[A-Z0-9]+)|R_[\\d]{2,3}|[A-Z]+)_([\\d.\\d]+)_(\\d+\\w)_(\\d+\\w)_(S[\\d.\\d]+P|(?:\\d+))_(\\d+)'); // Used to get market name from shortcode
const info_from_shortcode = {
category : '',
underlying: '',
barrier_1 : '',
};

const pattern = new RegExp('^([A-Z]+)_((OTC_[A-Z0-9]+)|R_[\\d]{2,3}|[A-Z]+)'); // Used to get market name from shortcode
const extracted = pattern.exec(shortcode);
if (extracted !== null) {
info_from_shortcode.category = extracted[1].toLowerCase();
info_from_shortcode.underlying = extracted[2];
info_from_shortcode.atm = extracted[7];

if (/^(CALL|PUT)$/i.test(info_from_shortcode.category)) {
info_from_shortcode.barrier_1 = shortcode.split('_').slice(-2)[0];
}
}

return info_from_shortcode;
};

const isHighLow = (shortcode) => {
if (shortcode) {
info_from_shortcode = extractInfoFromShortcode(shortcode);
}
if (/CALL|PUT/i.test(info_from_shortcode.category)) {
return !/^S0P$/.test(info_from_shortcode.atm);
}

return false;
const isHighLow = ({ shortcode = '', shortcode_info = '' }) => {
const info_from_shortcode = shortcode ? extractInfoFromShortcode(shortcode) : shortcode_info;
return (info_from_shortcode && info_from_shortcode.barrier_1) ? !/^S0P$/.test(info_from_shortcode.barrier_1) : false;
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TradeTypeInfoItem = ({
icon='TradeCategoriesGIF'
category={type.value}
className='trade-type-info-dialog__gif-image'
is_dark={is_dark_theme}
is_dark_theme={is_dark_theme}
/>
</div>
<div className='trade-type-info-dialog__content'>
Expand Down

0 comments on commit ab10694

Please sign in to comment.