-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): implement TNodeTransformDisplay
- Loading branch information
Showing
10 changed files
with
115 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
apps/website/src/components/TNodeTransformDisplay.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<figure className={styles.figure}> | ||
{title && <div className={styles.figure__title}>{title}</div>} | ||
<CodeBlock title="HTML" className={'html'}> | ||
{normalHtml} | ||
</CodeBlock> | ||
<div className={styles.arrow}>↓</div> | ||
<CodeBlock title="TRT" className={'xml'}> | ||
{normalSnapshot} | ||
</CodeBlock> | ||
{caption && ( | ||
<figcaption className={styles.figure__caption}>{caption}</figcaption> | ||
)} | ||
</figure> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
doc-tools/doc-mdx-gen-cli/src/render/components/TNodeTransformDisplayElement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
/* 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 { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
admonition: AdmonitionProps; | ||
codeblockds: CodeBlockElementProps; | ||
exposnippet: ExpoSnippetElementProps; | ||
renderhtmlcard: RenderHTMLCardElementProps; | ||
svgfigure: SvgFigureElementProps; | ||
tnodetransformdisplay: TNodeTransformDisplayElementProps; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters