mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 04:05:49 +00:00
Fix interactive tutorials issues
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import dynamicReact from '@markdoc/markdoc/dist/react';
|
import dynamicReact from '@markdoc/markdoc/dist/react';
|
||||||
import { usePageSharedData, useTranslate } from '@portal/hooks';
|
import { usePageSharedData, useTranslate } from '@portal/hooks';
|
||||||
@@ -27,6 +28,7 @@ export function IndexPageItems() {
|
|||||||
|
|
||||||
export function InteractiveBlock(props: { children: React.ReactNode; label: string; steps: string[] }) {
|
export function InteractiveBlock(props: { children: React.ReactNode; label: string; steps: string[] }) {
|
||||||
const stepId = idify(props.label);
|
const stepId = idify(props.label);
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="interactive-block" id={'interactive-' + stepId}>
|
<div className="interactive-block" id={'interactive-' + stepId}>
|
||||||
@@ -51,7 +53,7 @@ export function InteractiveBlock(props: { children: React.ReactNode; label: stri
|
|||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div className="interactive-block-ui">{dynamicReact(props.children, React, {})}</div>
|
<div className="interactive-block-ui" key={pathname}>{dynamicReact(props.children, React, {})}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -102,7 +104,7 @@ export function Badge(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let childstrings = ""
|
let childstrings = ""
|
||||||
|
|
||||||
React.Children.forEach(props.children, (child, index) => {
|
React.Children.forEach(props.children, (child, index) => {
|
||||||
if (typeof child == "string") {
|
if (typeof child == "string") {
|
||||||
childstrings += child
|
childstrings += child
|
||||||
@@ -125,7 +127,7 @@ export function Badge(props: {
|
|||||||
let badge_url = `https://img.shields.io/badge/${left}-${right}-${color}.svg`
|
let badge_url = `https://img.shields.io/badge/${left}-${right}-${color}.svg`
|
||||||
|
|
||||||
if (props.href) {
|
if (props.href) {
|
||||||
return (
|
return (
|
||||||
<Link to={props.href}>
|
<Link to={props.href}>
|
||||||
<img src={badge_url} alt={childstrings} className="shield" />
|
<img src={badge_url} alt={childstrings} className="shield" />
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function tl(key) {
|
|||||||
*/
|
*/
|
||||||
function idify(s) {
|
function idify(s) {
|
||||||
// s = s.replace(/[^\p{Alphabetic}\p{Mark}\p{Decimal_Number}\p{Connector_Punctuation}\p{Join_Control}]/gu, '').trim().toLowerCase()
|
// s = s.replace(/[^\p{Alphabetic}\p{Mark}\p{Decimal_Number}\p{Connector_Punctuation}\p{Join_Control}]/gu, '').trim().toLowerCase()
|
||||||
s = s.replace(/([^\w]|[\s-])/gu, '').trim().toLowerCase()
|
s = s.replace(/([^\w]|[\s-])/gu, '').trim().toLowerCase()
|
||||||
s = s.replace(/[\s-]+/gu, '-')
|
s = s.replace(/[\s-]+/gu, '-')
|
||||||
if (!s) {
|
if (!s) {
|
||||||
s = "_";
|
s = "_";
|
||||||
@@ -176,8 +176,8 @@ function show_error(block, message) {
|
|||||||
* use the generated credentials instead of the placeholder EXAMPLE_ADDR and
|
* use the generated credentials instead of the placeholder EXAMPLE_ADDR and
|
||||||
* EXAMPLE_SECRET.
|
* EXAMPLE_SECRET.
|
||||||
*/
|
*/
|
||||||
const EXAMPLE_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
var EXAMPLE_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
||||||
const EXAMPLE_SECRET = "s████████████████████████████"
|
var EXAMPLE_SECRET = "s████████████████████████████"
|
||||||
function setup_generate_step() {
|
function setup_generate_step() {
|
||||||
|
|
||||||
$("#generate-creds-button").click( async (event) => {
|
$("#generate-creds-button").click( async (event) => {
|
||||||
@@ -629,6 +629,14 @@ async function show_log(block, msg) {
|
|||||||
block.find(".output-area").append(msg)
|
block.find(".output-area").append(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onCurrentRouteLoaded(callback) {
|
||||||
|
const currentPath = window.location.pathname;
|
||||||
|
window.onRouteChange(() => {
|
||||||
|
if (window.location.pathname === currentPath) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.onRouteChange(() => {
|
window.onRouteChange(() => {
|
||||||
disable_followup_steps()
|
disable_followup_steps()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 1. Generate
|
// 1. Generate
|
||||||
// 2. Connect
|
// 2. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
const EXPLORER = $("#connect-button").data("explorer")
|
const EXPLORER = $("#connect-button").data("explorer")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 1. Generate
|
// 1. Generate
|
||||||
// 2. Connect
|
// 2. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
// 3. Send AccountSet --------------------------------------------------------
|
// 3. Send AccountSet --------------------------------------------------------
|
||||||
$("#send-accountset").click( async (event) => {
|
$("#send-accountset").click( async (event) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 1. Generate
|
// 1. Generate
|
||||||
// 2. Connect
|
// 2. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
// 3. Send AccountSet to Start the Freeze ------------------------------------
|
// 3. Send AccountSet to Start the Freeze ------------------------------------
|
||||||
// also 6. Send AccountSet to End the Freeze.
|
// also 6. Send AccountSet to End the Freeze.
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ window.after_connect.push(async () => {
|
|||||||
trust_line_setup_done = true
|
trust_line_setup_done = true
|
||||||
})
|
})
|
||||||
|
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function domain_to_hex(s) {
|
|||||||
return result.toUpperCase()
|
return result.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
setup_2x_generate_step()
|
setup_2x_generate_step()
|
||||||
|
|
||||||
$("#cold-domain-text").keyup( (event) => {
|
$("#cold-domain-text").keyup( (event) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 1. Generate
|
// 1. Generate
|
||||||
// 2. Connect
|
// 2. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
// 3. Send AccountSet --------------------------------------------------------
|
// 3. Send AccountSet --------------------------------------------------------
|
||||||
$("#send-accountset").click( async (event) => {
|
$("#send-accountset").click( async (event) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// 1. Connect
|
// 1. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
|
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
// 2. Prepare Transaction ------------------------------------------------------
|
// 2. Prepare Transaction ------------------------------------------------------
|
||||||
$("#prepare-button").click( async function(event) {
|
$("#prepare-button").click( async function(event) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
// Get Credentials, Connect steps handled by the snippet
|
// Get Credentials, Connect steps handled by the snippet
|
||||||
|
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
|
|
||||||
// Look Up Offers --------------------------------------------------------------
|
// Look Up Offers --------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 1. Generate
|
// 1. Generate
|
||||||
// 2. Connect
|
// 2. Connect
|
||||||
// The code for these steps is handled by interactive-tutorial.js
|
// The code for these steps is handled by interactive-tutorial.js
|
||||||
window.onRouteChange(() => {
|
onCurrentRouteLoaded(() => {
|
||||||
const LLS_OFFSET = 75 // Expire unconfirmed transactions after about ~5 min
|
const LLS_OFFSET = 75 // Expire unconfirmed transactions after about ~5 min
|
||||||
|
|
||||||
// 3. Check Sequence Number
|
// 3. Check Sequence Number
|
||||||
|
|||||||
Reference in New Issue
Block a user