mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-22 02:08:03 +00:00
Set UI defaults based on environment (#86)
* Bump deps * Set defaults based on hosted environment * Update tests (package bumps) * Do location detection on 'polkadot'
This commit is contained in:
+3
-2
@@ -23,8 +23,9 @@
|
||||
"demo:identicon": "webpack-serve --config packages/ui-identicon/webpack.config.js --content packages/ui-identicon --port 3000"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.3.3",
|
||||
"@polkadot/dev-react": "^0.25.4",
|
||||
"@babel/core": "^7.3.4",
|
||||
"@babel/runtime": "^7.3.4",
|
||||
"@polkadot/dev-react": "^0.25.7",
|
||||
"@polkadot/ts": "^0.1.53",
|
||||
"empty": "^0.10.1"
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1"
|
||||
"@babel/runtime": "^7.3.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"@babel/runtime": "^7.3.4",
|
||||
"@polkadot/ui-settings": "^0.28.4",
|
||||
"@types/color": "^3.0.0",
|
||||
"@types/react-copy-to-clipboard": "^4.2.6",
|
||||
@@ -23,8 +23,8 @@
|
||||
"react": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.34.28",
|
||||
"@polkadot/util-crypto": "^0.34.28",
|
||||
"@polkadot/keyring": "^0.34.33",
|
||||
"@polkadot/util-crypto": "^0.34.33",
|
||||
"xmlserializer": "^0.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ describe('identicon', () => {
|
||||
identicon(new Uint8Array(32))
|
||||
)
|
||||
).toEqual(
|
||||
// '<div xmlns="http://www.w3.org/1999/xhtml" class="" style="background: white; border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><div class="" style="border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="256" height="256"><circle cx="128" cy="140.8" r="128" fill="hsla(12.899999999999977, 100%, 49.4%, 0.9)"/><circle cx="128" cy="153.6" r="102.4" fill="hsla(174.29999999999995, 93.7%, 18.8%, 0.9)"/><circle cx="128" cy="166.4" r="76.8" fill="hsla(0.10000000000002274, 99.2%, 48.6%, 0.9)"/><circle cx="128" cy="179.2" r="51.2" fill="hsla(326.20000000000005, 97.4%, 54.3%, 0.9)"/><circle cx="128" cy="192" r="25.6" fill="hsla(326.20000000000005, 81.7%, 42.9%, 0.9)"/></svg></div></div>'
|
||||
'<div xmlns="http://www.w3.org/1999/xhtml" class="" style="background: white; border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><div class="" style="border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="256" height="256"><circle cx="128" cy="140.8" r="128" fill="hsl(212.10000000000002, 65.6%, 55.5%)"/><circle cx="128" cy="153.6" r="102.4" fill="hsl(9.800000000000011, 90.7%, 57.6%)"/><circle cx="128" cy="166.4" r="76.8" fill="hsl(345, 85.7%, 86.3%)"/><circle cx="128" cy="179.2" r="51.2" fill="hsl(261.9, 100%, 87.3%)"/><circle cx="128" cy="192" r="25.6" fill="hsl(345, 100%, 25.1%)"/></svg></div></div>'
|
||||
'<div xmlns="http://www.w3.org/1999/xhtml" class="" style="background: white; border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><div class="" style="background: hsl(37.19999999999999, 100%, 54%); border-radius: 128px; display: inline-block; height: 256px; margin: 0px; overflow: hidden; padding: 0px; width: 256px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="256" height="256"><circle cx="128" cy="140.8" r="128" fill="hsl(212.10000000000002, 65.6%, 55.5%)"/><circle cx="128" cy="153.6" r="102.4" fill="hsl(9.800000000000011, 90.7%, 57.6%)"/><circle cx="128" cy="166.4" r="76.8" fill="hsl(345, 85.7%, 86.3%)"/><circle cx="128" cy="179.2" r="51.2" fill="hsl(261.9, 100%, 87.3%)"/><circle cx="128" cy="192" r="25.6" fill="hsl(345, 100%, 25.1%)"/></svg></div></div>'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -24,8 +23,7 @@ describe('identicon', () => {
|
||||
identicon(new Uint8Array(32), 100, 'testClass', { display: 'block' })
|
||||
)
|
||||
).toEqual(
|
||||
// '<div xmlns="http://www.w3.org/1999/xhtml" class="testClass" style="background: white; border-radius: 50px; display: block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><div class="" style="border-radius: 50px; display: inline-block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="100" height="100"><circle cx="50" cy="55" r="50" fill="hsla(12.899999999999977, 100%, 49.4%, 0.9)"/><circle cx="50" cy="60" r="40" fill="hsla(174.29999999999995, 93.7%, 18.8%, 0.9)"/><circle cx="50" cy="65" r="30" fill="hsla(0.10000000000002274, 99.2%, 48.6%, 0.9)"/><circle cx="50" cy="70" r="20" fill="hsla(326.20000000000005, 97.4%, 54.3%, 0.9)"/><circle cx="50" cy="75" r="10" fill="hsla(326.20000000000005, 81.7%, 42.9%, 0.9)"/></svg></div></div>'
|
||||
'<div xmlns="http://www.w3.org/1999/xhtml" class="testClass" style="background: white; border-radius: 50px; display: block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><div class="" style="border-radius: 50px; display: inline-block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="100" height="100"><circle cx="50" cy="55" r="50" fill="hsl(212.10000000000002, 65.6%, 55.5%)"/><circle cx="50" cy="60" r="40" fill="hsl(9.800000000000011, 90.7%, 57.6%)"/><circle cx="50" cy="65" r="30" fill="hsl(345, 85.7%, 86.3%)"/><circle cx="50" cy="70" r="20" fill="hsl(261.9, 100%, 87.3%)"/><circle cx="50" cy="75" r="10" fill="hsl(345, 100%, 25.1%)"/></svg></div></div>'
|
||||
'<div xmlns="http://www.w3.org/1999/xhtml" class="testClass" style="background: white; border-radius: 50px; display: block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><div class="" style="background: hsl(37.19999999999999, 100%, 54%); border-radius: 50px; display: inline-block; height: 100px; margin: 0px; overflow: hidden; padding: 0px; width: 100px;"><svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="100" height="100"><circle cx="50" cy="55" r="50" fill="hsl(212.10000000000002, 65.6%, 55.5%)"/><circle cx="50" cy="60" r="40" fill="hsl(9.800000000000011, 90.7%, 57.6%)"/><circle cx="50" cy="65" r="30" fill="hsl(345, 85.7%, 86.3%)"/><circle cx="50" cy="70" r="20" fill="hsl(261.9, 100%, 87.3%)"/><circle cx="50" cy="75" r="10" fill="hsl(345, 100%, 25.1%)"/></svg></div></div>'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"@babel/runtime": "^7.3.4",
|
||||
"@types/store": "^2.0.1",
|
||||
"rxjs": "^6.4.0",
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.34.28",
|
||||
"@polkadot/types": "^0.45.15",
|
||||
"@polkadot/util": "^0.34.28"
|
||||
"@polkadot/keyring": "^0.34.33",
|
||||
"@polkadot/types": "^0.45.18",
|
||||
"@polkadot/util": "^0.34.33"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/keyring": "*",
|
||||
|
||||
@@ -138,7 +138,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
|
||||
const [, hexAddr] = key.split(':');
|
||||
|
||||
this.rewriteKey(json, key, hexAddr, accountKey);
|
||||
this.rewriteKey(json, key, hexAddr.trim(), accountKey);
|
||||
}
|
||||
|
||||
private loadAddress (json: KeyringJson, key: string) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"@babel/runtime": "^7.3.4",
|
||||
"@types/store": "^2.0.1",
|
||||
"store": "^2.0.12"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import store from 'store';
|
||||
|
||||
import { ENDPOINTS, LANGUAGES, UIMODES, UITHEMES } from './defaults';
|
||||
import { ENDPOINT_DEFAULT, ENDPOINTS, LANGUAGE_DEFAULT, LANGUAGES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
|
||||
import { Options, SettingsStruct } from './types';
|
||||
|
||||
export class Settings implements SettingsStruct {
|
||||
@@ -16,10 +16,10 @@ export class Settings implements SettingsStruct {
|
||||
constructor () {
|
||||
const settings = store.get('settings') || {};
|
||||
|
||||
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINTS[0].value;
|
||||
this._i18nLang = settings.i18nLang || LANGUAGES[0].value;
|
||||
this._uiMode = settings.uiMode || process.env.UI_MODE || UIMODES[0].value;
|
||||
this._uiTheme = settings.uiTheme || process.env.UI_THEME || UITHEMES[0].value;
|
||||
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
|
||||
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
|
||||
this._uiMode = settings.uiMode || process.env.UI_MODE || UIMODE_DEFAULT;
|
||||
this._uiTheme = settings.uiTheme || process.env.UI_THEME || UITHEME_DEFAULT;
|
||||
}
|
||||
|
||||
get apiUrl (): string {
|
||||
|
||||
@@ -4,14 +4,21 @@
|
||||
|
||||
import { Options } from './types';
|
||||
|
||||
// matches https://polkadot.js.org & https://poc-3.polkadot.io
|
||||
const isPolkadot = window.location.host.indexOf('polkadot') !== -1;
|
||||
|
||||
const WSS_POLKADOT = 'wss://poc3-rpc.polkadot.io/';
|
||||
const WSS_SUBSTRATE = 'wss://substrate-rpc.parity.io/';
|
||||
const LANGUAGE_DEFAULT = 'default';
|
||||
|
||||
const ENDPOINTS: Options = [
|
||||
{ text: 'Alexander (Polkadot, hosted by Parity)', value: 'wss://poc3-rpc.polkadot.io/' },
|
||||
{ text: 'Dried Danta (Substrate, hosted by Parity)', value: 'wss://substrate-rpc.parity.io/' },
|
||||
{ text: 'Alexander (Polkadot, hosted by Parity)', value: WSS_POLKADOT },
|
||||
{ text: 'Dried Danta (Substrate, hosted by Parity)', value: WSS_SUBSTRATE },
|
||||
{ text: 'Local Node (127.0.0.1:9944)', value: 'ws://127.0.0.1:9944/' }
|
||||
];
|
||||
|
||||
const LANGUAGES: Options = [
|
||||
{ value: 'default', text: 'Default browser language (auto-detect)' }
|
||||
{ value: LANGUAGE_DEFAULT, text: 'Default browser language (auto-detect)' }
|
||||
];
|
||||
|
||||
const UIMODES: Options = [
|
||||
@@ -24,9 +31,25 @@ const UITHEMES: Options = [
|
||||
{ value: 'substrate', text: 'Substrate' }
|
||||
];
|
||||
|
||||
const ENDPOINT_DEFAULT = isPolkadot
|
||||
? WSS_POLKADOT
|
||||
: WSS_SUBSTRATE;
|
||||
|
||||
const UITHEME_DEFAULT = isPolkadot
|
||||
? 'polkadot'
|
||||
: 'substrate';
|
||||
|
||||
const UIMODE_DEFAULT = !isPolkadot && window.location.host.indexOf('ui-light') !== -1
|
||||
? 'light'
|
||||
: 'full';
|
||||
|
||||
export {
|
||||
ENDPOINT_DEFAULT,
|
||||
ENDPOINTS,
|
||||
LANGUAGE_DEFAULT,
|
||||
LANGUAGES,
|
||||
UIMODE_DEFAULT,
|
||||
UIMODES,
|
||||
UITHEME_DEFAULT,
|
||||
UITHEMES
|
||||
};
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1"
|
||||
"@babel/runtime": "^7.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "^0.45.15"
|
||||
"@polkadot/types": "^0.45.18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/types": "*"
|
||||
|
||||
Reference in New Issue
Block a user