Skip to content

Commit b11f6ad

Browse files
Merge pull request #660 from deriv-com/redesign
SmartTrader Redesign
2 parents 6185dcb + a832e61 commit b11f6ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+18751
-7818
lines changed

build/config/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const release_config = {
3939

4040
const node_modules_paths = {
4141
binary_style: 'node_modules/@binary-com/binary-style',
42+
quill : 'node_modules/@deriv-com/quill-ui',
4243
};
4344

4445
const config = {

build/cssmin.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
],
1313
dest: `${global.dist}/css/common.min.css`,
1414
},
15+
{ src: `${global.dist}/css/reset.css`, dest: `${global.dist}/css/reset.min.css` },
1516
{ src: `${global.dist}/css/app.css`, dest: `${global.dist}/css/app.min.css` },
1617
{ src: `${global.dist}/css/static.css`, dest: `${global.dist}/css/static.min.css` },
1718
],

build/postcss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function (grunt) {
1212
],
1313
},
1414
dist: {
15-
src: `${global.dist}/css/{app,common,static}.css`,
15+
src: `${global.dist}/css/{app,common,static,reset}.css`,
1616
},
1717
};
1818
};

build/webpack/config_common.js

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const commonConfig = (grunt) => ({
6262
},
6363
],
6464
},
65+
{
66+
test: /\.css$/,
67+
use : ['style-loader', 'css-loader'],
68+
},
6569
],
6670
},
6771
watch : false,

package-lock.json

+12,770-7,349
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"devDependencies": {
2323
"@babel/core": "7.24.0",
2424
"@babel/eslint-parser": "7.23.10",
25-
"@babel/parser": "7.1.2",
25+
"@babel/parser": "7.25.0",
2626
"@babel/plugin-proposal-decorators": "^7.24.7",
2727
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
2828
"@babel/plugin-transform-class-properties": "^7.24.7",
@@ -44,6 +44,7 @@
4444
"commander": "2.12.2",
4545
"connect-livereload": "0.6.0",
4646
"connect-modrewrite": "^0.10.2",
47+
"css-loader": "^7.1.2",
4748
"deep-diff": "0.3.8",
4849
"emphasize": "7.0.0",
4950
"enzyme": "3.3.0",
@@ -87,6 +88,7 @@
8788
"react-render-html": "0.6.0",
8889
"sass": "^1.77.6",
8990
"sitemap": "1.13.0",
91+
"style-loader": "^4.0.0",
9092
"stylelint": "15.11.0",
9193
"stylelint-formatter-pretty": "1.0.3",
9294
"stylelint-selector-bem-pattern": "3.0.1",
@@ -103,7 +105,9 @@
103105
"@binary-com/binary-document-uploader": "^2.4.4",
104106
"@binary-com/binary-style": "^0.2.26",
105107
"@binary-com/webtrader-charts": "^0.6.1",
108+
"@deriv-com/quill-ui": "^1.13.44",
106109
"@deriv/deriv-api": "^1.0.15",
110+
"@deriv/quill-icons": "^1.23.1",
107111
"@livechat/customer-sdk": "4.0.2",
108112
"canvas-toBlob": "1.0.0",
109113
"classnames": "2.2.5",
@@ -112,6 +116,7 @@
112116
"davidshimjs-qrcodejs": "0.0.2",
113117
"event-source-polyfill": "0.0.9",
114118
"highstock-release": "5.0.14",
119+
"html-react-parser": "^5.1.10",
115120
"jquery": "3.5.1",
116121
"jquery.scrollto": "2.1.2",
117122
"js-cookie": "2.2.0",
@@ -131,6 +136,11 @@
131136
"peerDependencies": {
132137
"circular-dependency-plugin": "5.2.2"
133138
},
139+
"overrides": {
140+
"braces": "^3.0.3",
141+
"@babel/parser": "7.25.0",
142+
"@babel/plugin-proposal-optional-chaining": "7.22.5"
143+
},
134144
"engines": {
135145
"node": "18.x"
136146
},

scripts/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports.sections_config = {
2121
'': { // '' is the default section when no 'section' specified in pages.js (to avoid adding 'app' as section for all)
2222
path : '',
2323
js_files : ['vendor', 'binary'],
24-
css_files: ['common.min', 'app.min', 'static.min'],
24+
css_files: ['common.min', 'app.min', 'static.min', 'reset.min'],
2525
has_pjax : true,
2626
},
2727
};

scripts/js_texts/extracted_strings_app.js

+107-1
Large diffs are not rendered by default.

src/javascript/_autogenerated/ach.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/de.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/es.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/fr.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/id.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/it.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/pl.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/pt.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/ru.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/th.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/vi.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/zh_cn.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_autogenerated/zh_tw.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/_common/localize.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const moment = require('moment');
2+
const { urlLang } = require('./language');
23
require('moment/min/locales');
34
const template = require('./utility').template;
45

@@ -15,6 +16,12 @@ const Localize = (() => {
1516

1617
const index = text.replace(/[\s|.]/g, '_');
1718

19+
const lang = urlLang().toUpperCase();
20+
21+
const strings = typeof texts_json !== 'undefined' ? texts_json : {};
22+
23+
localized_texts = strings[lang];
24+
1825
text = (localized_texts && localized_texts[index]) || text;
1926

2027
// only use template when explicitly required

src/javascript/app/base/binary_loader.js

+5-26
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const isStorageSupported = require('../../_common/storage').isStorageSupported;
2020
const ThirdPartyLinks = require('../../_common/third_party_links');
2121
const urlFor = require('../../_common/url').urlFor;
2222
const createElement = require('../../_common/utility').createElement;
23+
const NotAvailable = require('../pages/trade/not-available.jsx');
2324

2425
const BinaryLoader = (() => {
2526
let container;
@@ -152,9 +153,9 @@ const BinaryLoader = (() => {
152153
if (config.no_blocked_country && Client.isLoggedIn() && Client.isOptionsBlocked()) {
153154
displayMessage(error_messages.options_blocked());
154155
} else if (Client.isLoggedIn() && Client.isOfferingBlocked()) {
155-
displayMessage(error_messages.offerings_blocked());
156+
displayUnavailable({ body: error_messages.offerings_blocked() });
156157
} else if (config.no_mf && Client.isLoggedIn() && Client.isAccountOfType('financial')) {
157-
displayUnavailable();
158+
displayUnavailable({ body: localize('Unfortunately, this trading platform is not available for EU Deriv account. Please switch to a non-EU account to continue trading.') });
158159
}
159160
});
160161

@@ -193,35 +194,13 @@ const BinaryLoader = (() => {
193194
}
194195
};
195196

196-
const displayUnavailable = () => {
197+
const displayUnavailable = (props) => {
197198
const content = container.querySelector('#content .container');
198199
if (!content) {
199200
return;
200201
}
201202

202-
const div_container = createElement('div', { class: 'platform-unavailable' });
203-
const inner_container = createElement('div', { class: 'platform-unavailable-inner' });
204-
const h1_title = createElement('h1', { text: localize('SmartTrader is unavailable for this account'), class: 'platform-unavailable-inner-title' });
205-
const message = createElement('div',
206-
{
207-
text: localize(
208-
'Unfortunately, this trading platform is not available for EU Deriv account. Please switch to a non-EU account to continue trading.'
209-
),
210-
class: 'platform-unavailable-inner-message',
211-
});
212-
const button = createElement('button', { text: localize('Switch to another account'), class: 'platform-unavailable-inner-button' });
213-
214-
div_container.appendChild(inner_container);
215-
inner_container.appendChild(h1_title);
216-
inner_container.appendChild(message);
217-
inner_container.appendChild(button);
218-
219-
button.addEventListener('click', (event) => {
220-
document.getElementById('acc_switcher').click();
221-
event.stopPropagation();
222-
});
223-
224-
content.html(div_container);
203+
NotAvailable.init({ title: localize('SmartTrader is unavailable for this account'), ...props });
225204
};
226205

227206
const handleNotAuthenticated = () => {

src/javascript/app/base/clock.js

+8
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,17 @@ const Clock = (() => {
3535
});
3636
};
3737

38+
const getLocalTime = (time) => {
39+
const gmt_time_str = time.replaceAll('\n', ' ');
40+
const local_time = moment.utc(gmt_time_str, 'YYYY-MM-DD HH:mm:ss').local();
41+
42+
return local_time.format('YYYY-MM-DD HH:mm:ss Z');
43+
};
44+
3845
return {
3946
startClock,
4047
showLocalTimeOnHover,
48+
getLocalTime,
4149
setExternalTimer: (func) => { fncExternalTimer = func; },
4250
};
4351
})();

src/javascript/app/common/active_symbols.js

+38
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ const submarket_order = {
2424
random_nightly : 20,
2525
};
2626

27+
const marketOrder = [
28+
'forex',
29+
'indices',
30+
'cryptocurrency',
31+
'commodities',
32+
'baskets',
33+
'synthetics',
34+
];
35+
36+
const derived = ['baskets', 'synthetics'];
37+
2738
const ActiveSymbols = (() => {
2839
const groupBy = (xs, key) => (
2940
xs.reduce((rv, x) => {
@@ -218,6 +229,30 @@ const ActiveSymbols = (() => {
218229
return all_symbols;
219230
};
220231

232+
const sortObjectByKeys = (obj, order) => {
233+
const orderedObj = {};
234+
const remainingObj = {};
235+
236+
// Add keys in the specified order
237+
order.forEach(key => {
238+
// eslint-disable-next-line no-prototype-builtins
239+
if (obj.hasOwnProperty(key)) {
240+
orderedObj[key] = obj[key];
241+
}
242+
});
243+
244+
// Add any remaining keys that were not specified in the order array
245+
Object.keys(obj).forEach(key => {
246+
// eslint-disable-next-line no-prototype-builtins
247+
if (!orderedObj.hasOwnProperty(key)) {
248+
remainingObj[key] = obj[key];
249+
}
250+
});
251+
252+
// Combine ordered keys and remaining keys
253+
return { ...orderedObj, ...remainingObj };
254+
};
255+
221256
return {
222257
getMarkets,
223258
getSubmarkets,
@@ -229,6 +264,9 @@ const ActiveSymbols = (() => {
229264
getSymbolsForMarket,
230265
sortSubmarket,
231266
getAvailableUnderlyings,
267+
marketOrder,
268+
derived,
269+
sortObjectByKeys,
232270
};
233271
})();
234272

src/javascript/app/common/currency.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
const dataManager = require('./data_manager').default;
12
const CurrencyBase = require('../../_common/base/currency_base');
23
const localize = require('../../_common/localize').localize;
34

45
const getCurrencyFullName = (currency) => CurrencyBase.isCryptocurrency(currency) ? `${CurrencyBase.getCurrencyName(currency)} (${CurrencyBase.getCurrencyDisplayCode(currency)})` : currency;
56

67
const getCurrencyList = (currencies) => {
8+
const currency_list = {
9+
fiat : [],
10+
crypto: [],
11+
};
712
const $currencies = $('<select/>');
813
const $fiat_currencies = $('<optgroup/>', { label: localize('Fiat') });
914
const $cryptocurrencies = $('<optgroup/>', { label: localize('Crypto') });
@@ -12,6 +17,14 @@ const getCurrencyList = (currencies) => {
1217
const currency_name = getCurrencyFullName(currency);
1318
(CurrencyBase.isCryptocurrency(currency) ? $cryptocurrencies : $fiat_currencies)
1419
.append($('<option/>', { value: currency, text: currency_name }));
20+
if (CurrencyBase.isCryptocurrency(currency)) {
21+
currency_list.crypto.push({ value: currency, text: currency_name });
22+
} else {
23+
currency_list.fiat.push({ value: currency, text: currency_name });
24+
}
25+
});
26+
dataManager.setTrade({
27+
currency_list,
1528
});
1629

1730
return $currencies.append($fiat_currencies.children().length ? $fiat_currencies : '').append($cryptocurrencies.children().length ? $cryptocurrencies : '');

0 commit comments

Comments
 (0)