import React, { useState, useRef } from 'react'; import ReactDOM from 'react-dom'; import { makeStyles, TextField, Button, Link, } from '@material-ui/core'; import { Benzin, Markdown, Heading, } from './lib'; 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 => ({ window: { padding: theme.spacing(4), }, promoButton: { display: 'flex', justifyContent: 'center', marginTop: theme.spacing(4), }, })); const Icon = logo; const headerContents = { home: null, dotfiles: null, 'material-ui': null, custom: null, 'live preview': null, }; const pageMap: Record = { home: 'https://raw.githubusercontent.com/eug-vs/react-benzin/develop/README.md', 'material-ui': 'https://raw.githubusercontent.com/mui-org/material-ui/master/README.md', dotfiles: 'https://raw.githubusercontent.com/eug-vs/dotfiles/master/.github/README.md', }; const CustomPage: React.FC = () => { const [url, setUrl] = useState(''); const inputEl = useRef(null); const handleParseUrl = (): void => { setUrl(inputEl.current?.value || ''); }; return ( <> Render custom markdown document

This should be a link to a valid markdown file. Response should give the file contents. If you copy README file from GitHub, make sure you provide link to raw view.

); }; interface LivePropTypes { setLivePreviewData: (livePreviewData: string) => void; } const LivePreviewPage: React.FC = ({ setLivePreviewData }) => { const inputEl = useRef(null); const handleRender = (): void => { setLivePreviewData(inputEl.current?.value || ''); }; return ( <> Markdown live preview

Start typing and see your text rendered on the left window! You can find the list of all Markdown features {' '} here . (some of them are yet in progress). We recommend starting with # Header.

); }; const App: React.FC = () => { const classes = useStyles(); const [page, setPage] = useState('home'); const [livePreviewData, setLivePreviewData] = useState(''); const handleGoLivePreview = (): void => { setPage('live preview'); }; const url = pageMap[page]; const fileName = url?.slice(url.lastIndexOf('/') + 1); let primaryWindowContent = ; if (page === 'custom') primaryWindowContent = ; else if (page === 'live preview') { primaryWindowContent = ; } const tryButton = (

); return (
{primaryWindowContent}
{ (page === 'live preview') ? : }
); }; ReactDOM.render(, document.getElementById('root'));