nocobase/.dumi/theme/builtins/Example.tsx
chenos d5d0e1036b
docs: add docs (#75)
* docs: add docs

* ignore dumi theme test

* fix: error TS2717: Subsequent property declarations must have the same type.

* update docs

* deploy gh-pages

* plugins docs

* hash & cname

* exportStatic

* ssr

* vercel

* vercel

* fix: deploy vercel

* Delete vercel.json

* docs

* fix APP_DIST

* on master branch
2021-04-17 21:33:21 +08:00

35 lines
1.1 KiB
TypeScript
Executable File

import React, { useRef, useEffect, useState } from 'react';
import './Example.less';
export default (props: { route: any }) => {
const elm = useRef<HTMLIFrameElement>();
const [height, setHeight] = useState(0);
useEffect(() => {
setHeight(elm.current.contentWindow.document.documentElement.scrollHeight);
}, [elm]);
return (
props.route.meta.examplePath && (
<div className="__dumi-default-example-wrapper">
<div className="__dumi-default-example-wrapper-toolbar">
{props.route.meta.description || props.route.meta.title}
<span>
<button
className="__dumi-default-icon"
onClick={() => elm.current.contentWindow.location.reload()}
/>
<a
target="_blank"
rel="noopener noreferrer"
href={props.route.meta.examplePath}
className="__dumi-default-icon"
/>
</span>
</div>
<iframe src={props.route.meta.examplePath} ref={elm} style={{ height }} title="dumi" />
</div>
)
);
};