import * as React from 'react'; import { useLocation } from 'react-router-dom'; // @ts-ignore import dynamicReact from '@markdoc/markdoc/dist/react'; import { usePageSharedData, useTranslate } from '@portal/hooks'; import { Link } from '@portal/Link'; import { idify } from '../helpers'; export {default as XRPLoader} from '../components/XRPLoader'; export { XRPLCard, CardGrid } from '../components/XRPLCard'; export function IndexPageItems() { const data = usePageSharedData('index-page-items') as any[]; return (
); } export function InteractiveBlock(props: { children: React.ReactNode; label: string; steps: string[] }) { const stepId = idify(props.label); const { pathname } = useLocation(); return (
    {props.steps?.map((step, idx) => { const iterStepId = idify(step).toLowerCase(); let className = `breadcrumb-item bc-${iterStepId}`; if (idx > 0) className += ' disabled'; if (iterStepId === stepId) className += ' current'; return (
  • {step}
  • ); })}
{dynamicReact(props.children, React, {})}
); } export function RepoLink(props: { children: React.ReactNode; path: string; github_fork: string; github_branch: string }) { const treeblob = props.path.indexOf(".") >= 0 ? "blob/" : "tree/" const sep = props.github_fork[-1] == "/" ? "" : "/" const href = props.github_fork+sep+treeblob+props.github_branch+"/"+props.path return ( {dynamicReact(props.children, React, {})} ) } export function CodePageName(props: { name: string; }) { return ( {props.name} ) } export function Badge(props: { children: React.ReactNode; color: string; href: string; }) { const DEFAULT_COLORS = { "open for voting": "80d0e0", "投票中": "80d0e0", // ja: open for voting "expected": "blue", "予定": "blue", // ja: expected "enabled": "green", "有効": "green", // ja: enabled "obsolete": "red", "廃止": "red", // ja: obsolete "撤回": "red", // ja: withdrawn/removed/vetoed "new in": "blue", "新規": "blue", // ja: new in" "in development": "lightgrey", "開発中": "lightgrey", // ja: in development } let childstrings = "" React.Children.forEach(props.children, (child, index) => { if (typeof child == "string") { childstrings += child } }); const parts = childstrings.split(":") const left : string = shieldsIoEscape(parts[0]) const right : string = shieldsIoEscape(parts.slice(1).join(":")) let color = props.color if (!color) { if (DEFAULT_COLORS.hasOwnProperty(left.toLowerCase())) { color = DEFAULT_COLORS[left.toLowerCase()] } else { color = "lightgrey" } } let badge_url = `https://img.shields.io/badge/${left}-${right}-${color}.svg` if (props.href) { return ( {childstrings} ) } else { return ( {childstrings} ) } } function shieldsIoEscape(s: string) { return s.trim().replaceAll('-', '--').replaceAll('_', '__') } export function NotEnabled() { const { translate } = useTranslate(); return ( ) }