Skip to content

Commit 62df0ff

Browse files
authored
Merge pull request #8 from eug-vs/develop
Markdown parser
2 parents a72027d + 400330f commit 62df0ff

18 files changed

+491
-75
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"react-app",
55
"plugin:@typescript-eslint/recommended"
66
],
7+
"ignorePatterns": "dist/",
78
"rules": {
89
"jsx-quotes": ["error", "prefer-double"],
910
"quotes": ["error", "single"]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66

77
# Production
88
/dist
9+
/build
10+

package-lock.json

Lines changed: 139 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "react-benzin",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "A powerful React Material components library.",
5+
"homepage": "https://eug-vs.github.io/react-benzin",
56
"main": "dist/index.js",
67
"files": [
78
"dist",
@@ -11,12 +12,14 @@
1112
"start": "react-scripts start",
1213
"lint": "eslint . --ext ts,tsx --max-warnings 0",
1314
"test": "npm run lint && tsc",
14-
"build": "rm -rf dist && tsc --project ts-compile-config.json",
15+
"build": "rm -rf dist && tsc --project tsconfig.release.json",
1516
"deploy": "npm run lint && npm run build && npm publish --public"
1617
},
1718
"license": "MIT",
1819
"dependencies": {
1920
"@material-ui/core": "^4.9.0",
21+
"axios": "^0.19.2",
22+
"emojilib": "^2.4.0",
2023
"react": "^16.12.0",
2124
"react-dom": "^16.12.0",
2225
"react-virtualized-auto-sizer": "^1.0.2",
@@ -33,6 +36,7 @@
3336
"@typescript-eslint/parser": "^2.19.0",
3437
"eslint": "^6.8.0",
3538
"eslint-config-react-app": "^5.1.0",
39+
"gh-pages": "^2.2.0",
3640
"react-scripts": "^3.3.1",
3741
"typescript": "^3.7.5"
3842
},

src/index.tsx

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import React, { useState } from 'react';
22
import ReactDOM from 'react-dom';
33

4-
import { makeStyles, Link } from '@material-ui/core';
4+
import { makeStyles } from '@material-ui/core';
55

66
import {
7-
BenzinThemeProvider,
7+
Benzin,
88
Header,
99
Window,
10-
ContentSection,
11-
SmartList,
12-
Button,
10+
Markdown,
1311
} from './lib';
1412

1513
import icon from './assets/icon.svg';
@@ -31,42 +29,42 @@ const Icon = <img src={icon} width="32px" height="37px" alt="logo"/>
3129

3230
const headerContents = {
3331
home: null,
34-
page: null,
35-
'another page': null,
32+
space: null,
33+
'spacevim': null,
34+
'emoji': null,
35+
'material-ui': null,
36+
};
37+
38+
const pageMap: Record<string, string> = {
39+
home: 'https://raw.githubusercontent.com/eug-vs/react-benzin/develop/README.md',
40+
space: 'https://raw.githubusercontent.com/eug-vs/space/master/docs/environment.md',
41+
'spacevim': 'https://raw.githubusercontent.com/spacevim/spacevim/master/README.md',
42+
emoji: 'https://raw.githubusercontent.com/muan/emoji/gh-pages/README.md',
43+
'material-ui': 'https://raw.githubusercontent.com/mui-org/material-ui/master/README.md',
3644
};
3745

3846

3947
const App: React.FC = () => {
4048
const classes = useStyles();
4149
const [page, setPage] = useState('home');
4250

43-
const renderItem: React.FC<RenderPropTypes> = ({ index, style}) => {
44-
return (
45-
<div style={style} className={classes.window}>
46-
<ContentSection sectionName={`Item ${index+1}`}>
47-
<p>
48-
Fusce commodo. Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus. Nullam libero mauris, consequat quis, varius et, dictum id, arcu. Mauris mollis tincidunt felis.
49-
</p>
50-
{(index % 2 === 0)?
51-
(
52-
<Button color="primary">
53-
primary
54-
</Button>
55-
)
56-
:
57-
(
58-
<Button color="secondary">
59-
secondary
60-
</Button>
61-
)
62-
}
63-
</ContentSection>
64-
</div>
65-
);
66-
};
51+
const url = pageMap[page];
52+
const fileName = url.slice(url.lastIndexOf('/') + 1);
53+
const metadata = [
54+
`## Markdown\n [Markdown file](${url}) *(...${fileName})* that you can see on the left was parsed and processed by **BENZIN**! :rocket:`,
55+
'Switch between tabs on the header to explore other markdown templates. :recycle: ',
56+
'Currently **only core features** of markdown function.',
57+
'Templates on the left are being loaded from the [GitHub](https://github.com), though this pane is generated from plaintext. :pen:',
58+
'## How do I use this feature?',
59+
'```',
60+
'import Markdown from \'react-benzin\';',
61+
'const data = \'# Header\\nHello, *world!*\';',
62+
'ReactDOM.render(<Markdown data={data}/>, document.getElementById(\'root\'));',
63+
'```',
64+
].join('\n');
6765

6866
return (
69-
<BenzinThemeProvider>
67+
<Benzin>
7068
<Header
7169
logo={{
7270
icon: Icon,
@@ -78,40 +76,15 @@ const App: React.FC = () => {
7876
/>
7977
<Window type="primary">
8078
<div className={classes.window}>
81-
<ContentSection sectionName="Library preview">
82-
<p>
83-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. Etiam vel tortor sodales tellus ultricies commodo. Suspendisse potenti. Aenean in sem ac leo mollis blandit. Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi. <Link href="#">Phasellus lacus.</Link> Etiam laoreet quam sed arcu. Phasellus at dui in ligula mollis ultricies. Integer placerat tristique nisl. Praesent augue. Fusce commodo.
84-
</p>
85-
<Button color="secondary">
86-
secondary
87-
</Button>
88-
<Button color="primary">
89-
primary
90-
</Button>
91-
</ContentSection>
92-
<ContentSection sectionName="Content section">
93-
<p>
94-
Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere.
95-
</p>
96-
<p>
97-
<Link href="#">Link example</Link>
98-
</p>
99-
</ContentSection>
100-
<ContentSection sectionName="Content section">
101-
<p>
102-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan <Link href="#">nulla</Link>. Nullam rutrum. Nam vestibulum accumsan nisl. Pellentesque dapibus suscipit ligula.
103-
</p>
104-
</ContentSection>
79+
<Markdown url={url} />
10580
</div>
10681
</Window>
107-
<Window type="secondary" name="SmartList preview window">
108-
<SmartList
109-
itemSize={270}
110-
itemCount={100}
111-
renderItem={renderItem}
112-
/>
82+
<Window type="secondary" name="Feature preview">
83+
<div className={classes.window}>
84+
<Markdown data={metadata} />
85+
</div>
11386
</Window>
114-
</BenzinThemeProvider>
87+
</Benzin>
11588
);
11689
};
11790

0 commit comments

Comments
 (0)