diff --git a/apps/website/src/components/ExpoSnippet.module.scss b/apps/website/src/components/RenderHTMLCard.module.scss similarity index 94% rename from apps/website/src/components/ExpoSnippet.module.scss rename to apps/website/src/components/RenderHTMLCard.module.scss index 40bdca084..8a26f3cd4 100644 --- a/apps/website/src/components/ExpoSnippet.module.scss +++ b/apps/website/src/components/RenderHTMLCard.module.scss @@ -26,6 +26,12 @@ padding-bottom: 0; } +.notice { + display: block; + text-align: center; + color: var(--ifm-font-color-secondary); +} + .expoBox { display: flex; justify-content: center; diff --git a/apps/website/src/components/ExpoSnippet.tsx b/apps/website/src/components/RenderHTMLCard.tsx similarity index 95% rename from apps/website/src/components/ExpoSnippet.tsx rename to apps/website/src/components/RenderHTMLCard.tsx index 38ffb8093..f3bdb3a1d 100644 --- a/apps/website/src/components/ExpoSnippet.tsx +++ b/apps/website/src/components/RenderHTMLCard.tsx @@ -7,7 +7,7 @@ import React, { useState } from 'react'; import useThemeContext from '@theme/hooks/useThemeContext'; -import styles from './ExpoSnippet.module.scss'; +import styles from './RenderHTMLCard.module.scss'; import ReactModal from 'react-modal'; import CodeBlock from '@theme/CodeBlock'; @@ -219,6 +219,12 @@ export default function RenderHTMLCard({ {caption && (
{caption}
)} + + Press on the button below to show how this code renders on your + device. +
diff --git a/apps/website/src/components/TNodeTransformDisplay.module.scss b/apps/website/src/components/TNodeTransformDisplay.module.scss new file mode 100644 index 000000000..6ced5ec08 --- /dev/null +++ b/apps/website/src/components/TNodeTransformDisplay.module.scss @@ -0,0 +1,20 @@ +@import '../css/shared.scss'; + +.arrow { + text-align: center; + font-size: 50px; + padding-bottom: var(--ifm-leading); +} + +.figure { + @extend .figure; +} + +.figure__caption { + @extend .figure__caption; +} + +.figure__title { + text-align: center; + font-weight: bold; +} diff --git a/apps/website/src/components/TNodeTransformDisplay.tsx b/apps/website/src/components/TNodeTransformDisplay.tsx new file mode 100644 index 000000000..b4ceed260 --- /dev/null +++ b/apps/website/src/components/TNodeTransformDisplay.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import CodeBlock from '@theme/CodeBlock'; +import styles from './TNodeTransformDisplay.module.scss'; + +export default function TNodeTransformDisplay({ + html, + snapshot, + caption, + title +}: { + title?: string; + caption?: string; + html: string; + snapshot: string; +}) { + const normalHtml = decodeURIComponent(html); + const normalSnapshot = decodeURIComponent(snapshot); + return ( +
+ {title &&
{title}
} + + {normalHtml} + +
+ + {normalSnapshot} + + {caption && ( +
{caption}
+ )} +
+ ); +} diff --git a/doc-tools/doc-mdx-gen-cli/src/MdxToolkitProvider.tsx b/doc-tools/doc-mdx-gen-cli/src/MdxToolkitProvider.tsx index 961f150ec..322fc81ed 100644 --- a/doc-tools/doc-mdx-gen-cli/src/MdxToolkitProvider.tsx +++ b/doc-tools/doc-mdx-gen-cli/src/MdxToolkitProvider.tsx @@ -33,7 +33,7 @@ export default function MdxToolkitProvider({ Paragraph: ({ children }) =>

{children}

, Bold: ({ children }) => {children}, RenderHtmlCard: ({ caption, snippet, title, props, preferHtmlSrc }) => ( - ), SourceDisplay: (props) => , - TNodeTransformDisplay: ({ html, snaphost, caption, title }) => { - return ( -
- {title && {title}} - - {/*@ts-ignore*/} -

- - {caption &&
{caption}
} -
- ); + TNodeTransformDisplay: ({ snaphost, ...props }) => { + return ; }, Admonition: ({ children, type, title }) => ( diff --git a/doc-tools/doc-mdx-gen-cli/src/render/components/ExpoSnippetElement.ts b/doc-tools/doc-mdx-gen-cli/src/render/components/RenderHTMLCardElement.ts similarity index 69% rename from doc-tools/doc-mdx-gen-cli/src/render/components/ExpoSnippetElement.ts rename to doc-tools/doc-mdx-gen-cli/src/render/components/RenderHTMLCardElement.ts index 73b0c4fa7..da71a8425 100644 --- a/doc-tools/doc-mdx-gen-cli/src/render/components/ExpoSnippetElement.ts +++ b/doc-tools/doc-mdx-gen-cli/src/render/components/RenderHTMLCardElement.ts @@ -3,7 +3,7 @@ import NodeWithChildren from './NodeWithChildren'; const version = require('react-native-render-html/package.json').version; -export type ExpoSnippetElementProps = { +export type RenderHTMLCardElementProps = { snippet: string; title: string; html: string; @@ -11,16 +11,16 @@ export type ExpoSnippetElementProps = { preferHtmlSrc: boolean; }; -export default class ExpoSnippetElement extends NodeWithChildren { - props: ExpoSnippetElementProps; - constructor(props: ExpoSnippetElementProps, root: MDXDocument) { +export default class RenderHTMLCardElement extends NodeWithChildren { + props: RenderHTMLCardElementProps; + constructor(props: RenderHTMLCardElementProps, root: MDXDocument) { super(); this.props = props; - root.registerImport('ExpoSnippet'); + root.registerImport('RenderHTMLCard'); } toMdx(): string { - const tagName = 'ExpoSnippet'; + const tagName = 'RenderHTMLCard'; const { snippet, html, preferHtmlSrc, ...inlineProps } = this.props; const identifiers = [tagName, ...this.getInlineProps(inlineProps)]; return `\n<${identifiers.join( diff --git a/doc-tools/doc-mdx-gen-cli/src/render/components/TNodeTransformDisplayElement.ts b/doc-tools/doc-mdx-gen-cli/src/render/components/TNodeTransformDisplayElement.ts new file mode 100644 index 000000000..a231cc179 --- /dev/null +++ b/doc-tools/doc-mdx-gen-cli/src/render/components/TNodeTransformDisplayElement.ts @@ -0,0 +1,27 @@ +import MDXDocument from './MDXDocument'; +import NodeWithChildren from './NodeWithChildren'; + +export interface TNodeTransformDisplayElementProps { + title?: string; + caption?: string; + html: string; + snapshot: string; +} + +export default class TNodeTransformDisplayElement extends NodeWithChildren { + props: TNodeTransformDisplayElementProps; + constructor(props: TNodeTransformDisplayElementProps, root: MDXDocument) { + super(); + this.props = props; + root.registerImport('TNodeTransformDisplay'); + } + + toMdx(): string { + const tagName = 'TNodeTransformDisplay'; + const { snapshot, html, ...inlineProps } = this.props; + const identifiers = [tagName, ...this.getInlineProps(inlineProps)]; + return `\n<${identifiers.join(' ')} html="${encodeURIComponent( + html + )}" snapshot="${encodeURIComponent(snapshot)}" />\n`; + } +} diff --git a/doc-tools/doc-mdx-gen-cli/src/render/createElement.ts b/doc-tools/doc-mdx-gen-cli/src/render/createElement.ts index 906814c91..0c23d8485 100644 --- a/doc-tools/doc-mdx-gen-cli/src/render/createElement.ts +++ b/doc-tools/doc-mdx-gen-cli/src/render/createElement.ts @@ -1,6 +1,6 @@ import AdmonitionElement from './components/AdmonitionElement'; import CodeBlockElement from './components/CodeBlockElement'; -import ExpoSnippetElement from './components/ExpoSnippetElement'; +import RenderHTMLCardElement from './components/RenderHTMLCardElement'; import SvgFigureElement from './components/SvgFigureElement'; import H2Element from './components/H2Element'; import HTMLElement from './components/HTMLElement'; @@ -10,6 +10,7 @@ import BoldElement from './components/AnchorElement'; import ParagraphElement from './components/ParagraphElement'; import StrongElement from './components/StrongElement'; import H3Element from './components/H3Element'; +import TNodeTransformDisplayElement from './components/TNodeTransformDisplayElement'; export type NodeType = 'ROOT' | keyof JSX.IntrinsicElements; @@ -24,10 +25,12 @@ function createElement(type: NodeType, props: any, root: MDXDocument) { return new AdmonitionElement(props); case 'codeblockds': return new CodeBlockElement(props); - case 'exposnippet': - return new ExpoSnippetElement(props, root!); + case 'renderhtmlcard': + return new RenderHTMLCardElement(props, root!); case 'svgfigure': return new SvgFigureElement(props, root!); + case 'tnodetransformdisplay': + return new TNodeTransformDisplayElement(props, root!); case 'h2': return new H2Element(); case 'h3': diff --git a/doc-tools/doc-mdx-gen-cli/src/render/index.ts b/doc-tools/doc-mdx-gen-cli/src/render/index.ts index 37b3e97ff..56b36d5c1 100644 --- a/doc-tools/doc-mdx-gen-cli/src/render/index.ts +++ b/doc-tools/doc-mdx-gen-cli/src/render/index.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { AdmonitionProps } from './components/AdmonitionElement'; import { CodeBlockElementProps } from './components/CodeBlockElement'; -import { ExpoSnippetElementProps } from './components/ExpoSnippetElement'; +import { RenderHTMLCardElementProps } from './components/RenderHTMLCardElement'; import { SvgFigureElementProps } from './components/SvgFigureElement'; +import { TNodeTransformDisplayElementProps } from './components/TNodeTransformDisplayElement'; export { default as renderMdx } from './renderMdx'; declare global { @@ -10,8 +11,9 @@ declare global { interface IntrinsicElements { admonition: AdmonitionProps; codeblockds: CodeBlockElementProps; - exposnippet: ExpoSnippetElementProps; + renderhtmlcard: RenderHTMLCardElementProps; svgfigure: SvgFigureElementProps; + tnodetransformdisplay: TNodeTransformDisplayElementProps; } } } diff --git a/doc-tools/doc-pages/src/pages/PageContentLists.tsx b/doc-tools/doc-pages/src/pages/PageContentLists.tsx index d730b5565..e65e90e9a 100644 --- a/doc-tools/doc-pages/src/pages/PageContentLists.tsx +++ b/doc-tools/doc-pages/src/pages/PageContentLists.tsx @@ -5,7 +5,7 @@ import Page from '../Page'; import useToolkit from '../toolkit/useToolkit'; import olUpperRomanConfig from './cards/olUpperRomanConfig'; import ulSquareConfig from './cards/ulSquareConfig'; -import customListThaiConfig from './cards/customListThaiConfig'; +import customListKatanaConfig from './cards/customListThaiConfig'; import customListRussianConfig from './cards/customListRussianConfig'; import rtlListArabicConfig from './cards/rtlListArabicConfig'; import rtlListDiscConfig from './cards/rtlListDiscConfig'; @@ -129,7 +129,7 @@ export default function PageContentLists() { of presets with a one-liner! See below example with the{' '} Thai preset: - +