UNPKG

@broxus/tvm-connect

Version:

TypeScript SDK for connecting to Nekoton-compatible wallets using a unified interface.

76 lines (75 loc) 5.8 kB
import { Icon } from '@broxus/react-components'; import { Button, Card, DescriptionList, Grid, Text, useConfig } from '@broxus/react-uikit'; import { observer } from 'mobx-react-lite'; import * as React from 'react'; import { useIntl } from 'react-intl'; import { useSharedParams, useTvmConnectDialog } from '../context'; import messages from '../intl'; import { getTvmProviderPlatformLink } from '../utils'; export const TvmInstallationGuide = observer(() => { const intl = useIntl(); const config = useConfig(); const params = useSharedParams(); const dialog = useTvmConnectDialog(); const { connectingProvider } = dialog; const providerInfo = connectingProvider?.connector?.info; const homepage = providerInfo?.links?.homepage; const universalLink = providerInfo?.links?.universalLink; const [platform = 'unknown', extensionLink] = getTvmProviderPlatformLink({ ...providerInfo?.links }) ?? []; const onBack = () => { dialog.setState({ error: undefined, requestState: (universalLink && (dialog.qrEnabled ?? params.qrEnabled ?? true)) ? 'mobile' : undefined, }); if (!dialog.requestState) { dialog.setData({ connectingProvider: undefined, }); } }; if (!extensionLink) { return (React.createElement("div", { className: "tvm-connect-provider-content uk-padding uk-padding-remove-horizontal uk-animation-fade", style: { animationDelay: 'var(--animation-medium-fast-duration)', animationDuration: 'var(--animation-fast-duration)', animationTimingFunction: 'var(--ease-in)', } }, React.createElement(Button, { className: "tvm-connect-back-button uk-position-top-left", type: "text", onClick: onBack }, React.createElement(Icon, { icon: "arrowLeft", ratio: 0.9 })), React.createElement(Text, { align: "center", component: "div" }, intl.formatMessage(messages.TVM_CONNECT_PROVIDER_HOMEPAGE_NOTE, { providerName: providerInfo?.name ?? '', })), React.createElement(Text, { align: "center", className: "uk-margin-top", component: "div" }, React.createElement(Button, { href: homepage, rel: "noopener noreferrer", shape: config.button?.shape ?? 'circle', target: "_blank", type: "secondary" }, intl.formatMessage(messages.TVM_CONNECT_PROVIDER_HOMEPAGE, { providerName: providerInfo?.name ?? '', }))))); } return (React.createElement(React.Fragment, null, React.createElement(Button, { className: "tvm-connect-back-button uk-position-top-left", type: "text", onClick: onBack }, React.createElement(Icon, { icon: "arrowLeft", ratio: 0.9 })), React.createElement("div", { className: "tvm-connect-provider-content uk-animation-fade", style: { animationDelay: 'var(--animation-medium-fast-duration)', animationDuration: 'var(--animation-fast-duration)', animationTimingFunction: 'var(--ease-in)', } }, React.createElement(Grid, { childWidth: 1 }, extensionLink && (React.createElement("div", null, React.createElement(Card, { asBody: true, kind: "default", size: "small" }, React.createElement(Text, { className: "uk-margin-remove", component: "h5", weight: "bold" }, intl.formatMessage(messages.TVM_CONNECT_INSTALL_PROVIDER_TITLE, { platform, providerName: providerInfo?.name ?? '', })), React.createElement(Text, { component: "div", kind: "meta" }, intl.formatMessage(messages.TVM_CONNECT_INSTALL_PROVIDER_NOTE)), React.createElement("div", { className: "uk-margin-top" }, React.createElement(Button, { href: extensionLink, rel: "noopener noreferrer", shape: config.button?.shape ?? 'circle', size: "small", target: "_blank", type: "secondary" }, intl.formatMessage(messages.TVM_CONNECT_INSTALL_PROVIDER_LINK_TEXT, { platform })))))), React.createElement("div", null, React.createElement(Text, { color: "muted", size: "xsmall", transform: "uppercase", weight: "bold" }, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_HEADER)), React.createElement(DescriptionList, null, React.createElement(DescriptionList.Term, null, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_DOWNLOAD_TERM, { providerName: providerInfo?.name ?? '' })), React.createElement(Text, { component: DescriptionList.Description, kind: "meta" }, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_DOWNLOAD_DESCRIPTION, { providerName: providerInfo?.name ?? '' })), React.createElement(DescriptionList.Term, null, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_IMPORT_TERM)), React.createElement(Text, { component: DescriptionList.Description, kind: "meta" }, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_IMPORT_DESCRIPTION, { b: parts => React.createElement("b", null, parts), })), React.createElement(DescriptionList.Term, null, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_RELOAD_TERM)), React.createElement(Text, { component: DescriptionList.Description, kind: "meta" }, intl.formatMessage(messages.TVM_CONNECT_POPUP_INSTALLATION_GUIDE_RELOAD_DESCRIPTION, { providerName: providerInfo?.name ?? 'wallet' })))))))); });