diff options
author | eug-vs <eug-vs@keemail.me> | 2021-01-11 22:29:03 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-01-11 22:29:03 +0300 |
commit | 53e41901558319e6063fdcbca4f6150101c57f10 (patch) | |
tree | 0ee56a21b898e880c65406baf2c48c47bfda84f0 /src/index.tsx | |
parent | 4ad1f101101771350b253762c5b02d57df6f4ddd (diff) | |
download | react-benzin-53e41901558319e6063fdcbca4f6150101c57f10.tar.gz |
feat: allow passing variable context
Diffstat (limited to 'src/index.tsx')
-rw-r--r-- | src/index.tsx | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/index.tsx b/src/index.tsx index 9a80262..3f312bb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,6 +14,7 @@ import { import Header from './demo/Header/Header'; import Window from './demo/Window/Window'; +import content from './demo/content.md'; import icon from './assets/icon.svg'; const useStyles = makeStyles(theme => ({ @@ -128,19 +129,6 @@ const App: React.FC = () => { const url = pageMap[page]; const fileName = url?.slice(url.lastIndexOf('/') + 1); - const info = [ - /* eslint-disable max-len */ - `## Markdown\n [Markdown file](${url}) *(...${fileName})* that you can see on the left was parsed and rendered by **BENZIN**! :rocket:`, - 'Switch between tabs on the header to explore other markdown templates. :recycle: ', - 'Templates on the left are being loaded from the [GitHub](https://github.com), though this pane is generated from plaintext. :pen:', - '## How do I use this feature?', - '```', - 'import Markdown from \'react-benzin\';', - 'const data = \'# Header\\nHello, *world!*\';', - 'ReactDOM.render(<Markdown data={data}/>, document.getElementById(\'root\'));', - '```', - /* eslint-enable max-len */ - ].join('\n'); let primaryWindowContent = <Markdown url={url} />; if (page === 'custom') primaryWindowContent = <CustomPage />; @@ -148,6 +136,19 @@ const App: React.FC = () => { primaryWindowContent = <Markdown data={livePreviewData || '# Start typing in the right window!'} />; } + const tryButton = ( + <p className={classes.promoButton}> + <Button + variant="contained" + color="primary" + size="large" + onClick={handleGoLivePreview} + > + Try it yourself! + </Button> + </p> + ); + return ( <Benzin> <Header @@ -167,21 +168,7 @@ const App: React.FC = () => { { (page === 'live preview') ? <LivePreviewPage setLivePreviewData={setLivePreviewData} /> - : ( - <> - <Markdown data={info} /> - <p className={classes.promoButton}> - <Button - variant="contained" - color="primary" - size="large" - onClick={handleGoLivePreview} - > - Try it yourself! - </Button> - </p> - </> - ) + : <Markdown url={content} context={{ tryButton, fileName }} /> } </div> </Window> |