@stokr/components-library 2.3.65-beta.4 → 2.3.65-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M7 11.0827V2.91602" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M2.91797 7H11.0846" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_5576_18558)">
3
+ <path d="M4.10179 5.87885C4.29705 6.07415 4.29705 6.3907 4.10179 6.586L3.18757 7.5002H7.99822C8.27437 7.5002 8.49822 7.72404 8.49822 8.00019C8.49822 8.27634 8.27437 8.5002 7.99822 8.5002H3.18757L4.10179 9.41439C4.29705 9.60964 4.29705 9.92625 4.10179 10.1215C3.90653 10.3168 3.58994 10.3168 3.39468 10.1215L1.62691 8.35374C1.43165 8.15849 1.43165 7.84189 1.62691 7.64665L3.39468 5.87885C3.58994 5.6836 3.90653 5.6836 4.10179 5.87885ZM7.89462 1.87887C8.0749 1.69863 8.35849 1.68476 8.55462 1.83728L8.60172 1.87887L10.3695 3.64664C10.5498 3.82688 10.5636 4.11049 10.4111 4.30664L10.3695 4.35375L8.60172 6.1215C8.40647 6.3168 8.08992 6.3168 7.89462 6.1215C7.71439 5.94126 7.70052 5.65763 7.85303 5.4615L7.89462 5.4144L8.80887 4.50019H3.99817C3.72203 4.50019 3.49817 4.27633 3.49817 4.00019C3.49817 3.74377 3.69119 3.53244 3.93986 3.50355L3.99817 3.50019H8.80887L7.89462 2.58598C7.69937 2.39072 7.69937 2.07413 7.89462 1.87887Z" fill="#3D9626"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_5576_18558">
7
+ <rect width="12" height="12" fill="white"/>
8
+ </clipPath>
9
+ </defs>
10
+ </svg>
@@ -3,9 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getProjectCurrencySign = exports.getCurrencySymbol = exports.formatCurrencyValue = void 0;
6
+ exports.getProjectCurrencySign = exports.getLiquidAssetIcon = exports.getCurrencySymbol = exports.getCurrencyIcon = exports.formatCurrencyValue = void 0;
7
+ var _usdcLogo = _interopRequireDefault(require("../static/images/usdc-logo.svg"));
8
+ var _usdqLogo = _interopRequireDefault(require("../static/images/usdq-logo.png"));
9
+ var _bitcoinLogo = _interopRequireDefault(require("../static/images/bitcoin-logo.svg"));
10
+ var _bmn2Logo = _interopRequireDefault(require("../static/images/bmn2-logo.svg"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
12
  const formatCurrencyValue = function (currency, value) {
8
13
  let tokenDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
14
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
15
+ const {
16
+ valueFirst = false
17
+ } = options;
9
18
  const [symbol, decimals] = {
10
19
  tether: ['USDT', 2],
11
20
  gemini: ['GUSD', 2],
@@ -27,7 +36,8 @@ const formatCurrencyValue = function (currency, value) {
27
36
  'usdc-fb': ['USDC', 2],
28
37
  'usdq-fb': ['USDQ', 2]
29
38
  }[currency] || [currency, tokenDecimals];
30
- return "".concat(symbol, " ").concat(parseFloat(Math.abs(value)).toFixed(decimals));
39
+ const formattedValue = parseFloat(Math.abs(value)).toFixed(decimals);
40
+ return valueFirst ? "".concat(formattedValue, " ").concat(symbol) : "".concat(symbol, " ").concat(formattedValue);
31
41
  };
32
42
  exports.formatCurrencyValue = formatCurrencyValue;
33
43
  const getCurrencySymbol = currencySelected => ({
@@ -51,4 +61,34 @@ exports.getCurrencySymbol = getCurrencySymbol;
51
61
  const getProjectCurrencySign = tokenCurrency => {
52
62
  return tokenCurrency === 'EUR' ? '€' : tokenCurrency === 'USD' ? '$' : tokenCurrency === 'BTC' ? '₿' : '';
53
63
  };
54
- exports.getProjectCurrencySign = getProjectCurrencySign;
64
+ exports.getProjectCurrencySign = getProjectCurrencySign;
65
+ const getCurrencyIcon = (currency, customIcon) => {
66
+ if (customIcon) return customIcon;
67
+ if (!currency) return null;
68
+ switch (currency.toLowerCase()) {
69
+ case 'btc':
70
+ case 'bitcoin':
71
+ return _bitcoinLogo.default;
72
+ case 'usdc':
73
+ return _usdcLogo.default;
74
+ case 'usdq':
75
+ return _usdqLogo.default;
76
+ case 'bmn2':
77
+ return _bmn2Logo.default;
78
+ default:
79
+ return null;
80
+ }
81
+ };
82
+
83
+ //uses secondary asset id to get liquid icon
84
+ exports.getCurrencyIcon = getCurrencyIcon;
85
+ const getLiquidAssetIcon = async assetId => {
86
+ const url = "https://liquid.network/api/v1/asset/".concat(assetId, "/icon");
87
+ return new Promise(resolve => {
88
+ const img = new Image();
89
+ img.onload = () => resolve(url);
90
+ img.onerror = () => resolve(null);
91
+ img.src = url;
92
+ });
93
+ };
94
+ exports.getLiquidAssetIcon = getLiquidAssetIcon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.65-beta.4",
3
+ "version": "2.3.65-beta.6",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",