aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-12-05 02:58:43 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-06 18:58:37 +0800
commit27cb0386a3da6bc725035c0f150a3ab890195c1b (patch)
tree1b2a6406dac1fa159c156f9c6cd69f16fd58f099 /packages
parent42d6284cf7d26695efe7eac1a9f2c4bb43c3ed81 (diff)
downloaddexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar.gz
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar.bz2
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar.lz
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar.xz
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.tar.zst
dexon-sol-tools-27cb0386a3da6bc725035c0f150a3ab890195c1b.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 ]`;
};
}