aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-12-05 02:58:43 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-12-05 02:58:43 +0800
commitdfe5752411509f8fe6b26a4aa23c182fc84b0948 (patch)
tree4680e55574ed104c50cad0aca23bff823a836c72 /packages
parentea4155e5fa69fe488eb183255f7ba64c9c07855b (diff)
downloaddexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar.gz
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar.bz2
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar.lz
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar.xz
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.tar.zst
dexon-sol-tools-dfe5752411509f8fe6b26a4aa23c182fc84b0948.zip
feat: update configurator snippet to actually work if copy and pasted
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/pages/instant/configurator.tsx40
1 files changed, 23 insertions, 17 deletions
diff --git a/packages/website/ts/pages/instant/configurator.tsx b/packages/website/ts/pages/instant/configurator.tsx
index 9f1fa8359..e3766057e 100644
--- a/packages/website/ts/pages/instant/configurator.tsx
+++ b/packages/website/ts/pages/instant/configurator.tsx
@@ -22,7 +22,7 @@ export class Configurator extends React.Component<ConfiguratorProps> {
public state: ConfiguratorState = {
instantConfig: {
orderSource: 'https://api.radarrelay.com/0x/v2/',
- availableAssetDatas: [],
+ availableAssetDatas: undefined,
affiliateInfo: {
feeRecipient: '',
feePercentage: 0.01,
@@ -65,35 +65,41 @@ export class Configurator extends React.Component<ConfiguratorProps> {
};
private readonly _generateCodeDemoCode = (): string => {
const { instantConfig } = this.state;
- return `<head>
- <script src="https://instant.0xproject.com/instant.js"></script>
-</head>
-<body>
- <script>
- zeroExInstant.render({
- orderSource: '${instantConfig.orderSource}',${
+ return `<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <script src="https://instant.0xproject.com/instant.js"></script>
+ </head>
+ <body>
+ <script>
+ zeroExInstant.render({
+ orderSource: '${instantConfig.orderSource}',${
!_.isUndefined(instantConfig.affiliateInfo) && instantConfig.affiliateInfo.feeRecipient
- ? `\n affiliateInfo: {
- feeRecipient: '${instantConfig.affiliateInfo.feeRecipient.toLowerCase()}',
- feePercentage: ${instantConfig.affiliateInfo.feePercentage}
- }`
+ ? `\n affiliateInfo: {
+ feeRecipient: '${instantConfig.affiliateInfo.feeRecipient.toLowerCase()}',
+ feePercentage: ${instantConfig.affiliateInfo.feePercentage}
+ }`
: ''
}${
!_.isUndefined(instantConfig.availableAssetDatas)
- ? `\n availableAssetDatas: ${this._renderAvailableAssetDatasString(
+ ? `\n availableAssetDatas: ${this._renderAvailableAssetDatasString(
instantConfig.availableAssetDatas,
)}`
: ''
}
- }, 'body');
- </script>
-</body>`;
+ }, 'body');
+ </script>
+ </body>
+</html>`;
};
private readonly _renderAvailableAssetDatasString = (availableAssetDatas: string[]): string => {
const stringAvailableAssetDatas = availableAssetDatas.map(assetData => `'${assetData}'`);
if (availableAssetDatas.length < 2) {
return `[${stringAvailableAssetDatas.join(', ')}]`;
}
- return `[\n\t\t${stringAvailableAssetDatas.join(', \n\t\t')}\n ]`;
+ return `[\n ${stringAvailableAssetDatas.join(
+ ', \n ',
+ )}\n ]`;
};
}