Skip to content

Commit 27372bf

Browse files
committed
fix: 修改文档及打包信息
1 parent 47947ed commit 27372bf

File tree

12 files changed

+68
-69
lines changed

12 files changed

+68
-69
lines changed

Diff for: .npmignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
src/
2-
packages/
1+
demo/
2+
example/
33
scripts/
44
dist/
55
index.html

Diff for: .npmrc

-1
This file was deleted.

Diff for: .yarnrc

-2
This file was deleted.

Diff for: components/button/bg.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import React, { FunctionComponent, ReactNode } from 'react';
5050
import { View, Platform } from 'react-native';
5151
import { isLinearGradient, getLinearParam } from '../utils/color';
5252

53-
import LinearGradient from 'react-native-linear-gradient';
53+
// import LinearGradient from 'react-native-linear-gradient';
5454

5555
// 位置坐标
5656
type Pos = {
@@ -162,13 +162,13 @@ const Background: FunctionComponent<Props> = ({
162162
}
163163

164164
return (
165-
<LinearGradient
165+
<View
166166
style={[...style, { borderWidth: 0 }]}
167167
{...restProps}
168168
{...toLinear(color)}
169169
>
170170
{children}
171-
</LinearGradient>
171+
</View>
172172
);
173173
};
174174

Diff for: components/configprovider/configprovider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const getDefaultConfig = () => {
3737
};
3838

3939
export const useConfig = () => {
40-
return useContext(ConfigContext) ?? getDefaultConfig();
40+
return useContext(ConfigContext) ? useContext(ConfigContext) : getDefaultConfig();
4141
};
4242

4343
// 创建一个 Context 对象

Diff for: index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</head>
1414
<body>
1515
<div id="doc"></div>
16-
<script async src="https://snack.expo.dev/embed.js"></script>
16+
<script async src="https://storage.360buyimg.com/pandoracdn/js/expo/embed.js"></script>
1717
<script type="module" src="/sites/main.tsx"></script>
1818

1919
</body>

Diff for: package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "nutui-rn",
3-
"version": "0.0.4",
4-
"type": "module",
3+
"version": "0.0.8",
54
"scripts": {
65
"generate:docs": "node scripts/generate-nutui.js",
76
"generate:jd:docs": "node scripts/generate-jd-nutui.js",
@@ -13,10 +12,8 @@
1312
},
1413
"author": "jdf2e",
1514
"license": "MIT",
16-
"main": "lib/commonjs/index.js",
1715
"dependencies": {
1816
"@bem-react/classname": "^1.5.12",
19-
"react-native": "^0.71.0",
2017
"react-native-linear-gradient": "^2.6.2",
2118
"react-native-root-portal": "^1.0.9"
2219
},
@@ -40,6 +37,7 @@
4037
"react": "^18.2.0",
4138
"react-dom": "^18.2.0",
4239
"react-markdown": "^8.0.3",
40+
"react-native": "^0.71.0",
4341
"react-native-builder-bob": "^0.20.3",
4442
"react-router-dom": "^5.3.4",
4543
"react-syntax-highlighter": "^15.4.5",
@@ -50,11 +48,12 @@
5048
"typescript": "^4.6.4",
5149
"vite": "^3.2.3"
5250
},
53-
"react-native": "src/index.ts",
51+
"main": "lib/commonjs/index.js",
52+
"react-native": "components/index.ts",
5453
"module": "lib/module/index.js",
5554
"types": "lib/typescript/index.d.ts",
5655
"files": [
57-
"packages",
56+
"components",
5857
"lib",
5958
"!**/__tests__",
6059
"!**/__fixtures__",

Diff for: scripts/generate-jd-nutui.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import glob from 'glob'
2-
import path from 'path';
3-
import fs from 'fs-extra'
4-
// 直接用node 中的__dirname报错
5-
// __dirname is not defined in ES module scope
6-
let __dirname = path.resolve('scripts');
1+
const glob = require('glob')
2+
const path = require('path')
3+
const fs = require('fs-extra')
74

85
const config = JSON.parse(fs.readFileSync(path.resolve('sites', 'config.json')));
96

Diff for: scripts/generate-nutui.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import glob from 'glob'
2-
import path from 'path';
3-
import fs from 'fs-extra'
4-
// 直接用node 中的__dirname报错
5-
// __dirname is not defined in ES module scope
6-
let __dirname = path.resolve('scripts');
1+
const glob = require('glob')
2+
const path = require('path')
3+
const fs = require('fs-extra')
74

85
const config = JSON.parse(fs.readFileSync(path.resolve('sites', 'config.json')));
96

Diff for: sites/App.tsx

+5-40
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
import React, { useEffect, useState } from 'react';
22
import { HashRouter, Switch, Route } from 'react-router-dom';
3-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
4-
import ReactMarkdown from 'react-markdown';
5-
import rehypeRaw from 'rehype-raw';
6-
import remarkDirective from 'remark-directive';
7-
import remarkGfm from 'remark-gfm';
83

94
import useLocale from './assets/locale/useLocale';
10-
import { routers, raws } from './docs';
5+
import { routers } from './docs';
116
import Header from './components/header';
127
import Nav from './components/nav';
138
import Title from './components/title';
149
import Issue from './components/issue';
15-
import myRemarkPlugin from './markdown-plugin/my-remark-plugin';
16-
import snackPlayer from './markdown-plugin/remark-snackplayer';
1710
import DemoPreview from './components/demo-preview';
1811

1912
import './App.scss';
13+
import Remark from './components/remark';
2014

2115
function App() {
2216
const [lang] = useLocale();
2317

2418
const [fixed, setFixed] = useState(false);
2519
const [hidden, setHidden] = useState(false);
2620

27-
const getMarkdownByLang = (ru: string) => {
28-
if (lang === 'zh-CN' || lang === '') {
29-
// @ts-ignore
30-
return raws[ru];
31-
} else {
32-
// @ts-ignore
33-
return raws[`${ru}${lang.replace('-', '')}`];
34-
}
35-
};
36-
3721
const scrollTitle = () => {
3822
let top = document.documentElement.scrollTop;
3923
if (top > 127) {
@@ -50,8 +34,8 @@ function App() {
5034
};
5135

5236
useEffect(() => {
53-
document.addEventListener('scroll', scrollTitle)
54-
}, [])
37+
document.addEventListener('scroll', scrollTitle);
38+
}, []);
5539

5640
return (
5741
<div>
@@ -79,26 +63,7 @@ function App() {
7963
key={k}
8064
path={`${lang ? `/${lang}` : ''}/component/${ru}`}
8165
>
82-
<ReactMarkdown
83-
children={getMarkdownByLang(ru)}
84-
remarkPlugins={[
85-
snackPlayer,
86-
remarkGfm,
87-
remarkDirective,
88-
myRemarkPlugin,
89-
]}
90-
rehypePlugins={[rehypeRaw]}
91-
components={{
92-
code({ node, inline, className, children, ...props }) {
93-
const match = /language-(\w+)/.exec(className || '');
94-
return (
95-
<code className={className} {...props}>
96-
{children}
97-
</code>
98-
);
99-
},
100-
}}
101-
/>
66+
<Remark ru={ru} />
10267
</Route>
10368
);
10469
})}

Diff for: sites/components/demo-preview/demo-preview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const DemoPreview = (props: any) => {
1616

1717
return (
1818
<div className={`doc-demo-preview ${props.className}`}>
19-
<iframe src={`/react/demo.html#${URL}`} frameBorder='0'></iframe>
19+
<iframe src={`https://nutui.jd.com/react/demo.html#${URL}`} frameBorder='0'></iframe>
2020
</div>
2121
);
2222
};

Diff for: sites/components/remark/index.tsx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { memo } from 'react';
2+
import ReactMarkdown from 'react-markdown';
3+
import rehypeRaw from 'rehype-raw';
4+
import remarkDirective from 'remark-directive';
5+
import remarkGfm from 'remark-gfm';
6+
7+
import myRemarkPlugin from '../../markdown-plugin/my-remark-plugin';
8+
import snackPlayer from '../../markdown-plugin/remark-snackplayer';
9+
import useLocale from '../../assets/locale/useLocale';
10+
import { raws } from '../../docs';
11+
12+
const Remark = ({ ru }: { ru: any }) => {
13+
const [lang] = useLocale();
14+
const getMarkdownByLang = (ru: string) => {
15+
if (lang === 'zh-CN' || lang === '') {
16+
// @ts-ignore
17+
return raws[ru];
18+
} else {
19+
// @ts-ignore
20+
return raws[`${ru}${lang.replace('-', '')}`];
21+
}
22+
};
23+
return (
24+
<ReactMarkdown
25+
children={getMarkdownByLang(ru)}
26+
remarkPlugins={[snackPlayer, remarkGfm, remarkDirective, myRemarkPlugin]}
27+
rehypePlugins={[rehypeRaw]}
28+
components={{
29+
code({ node, inline, className, children, ...props }) {
30+
const match = /language-(\w+)/.exec(className || '');
31+
return (
32+
<code className={className} {...props}>
33+
{children}
34+
</code>
35+
);
36+
},
37+
}}
38+
/>
39+
);
40+
};
41+
42+
export default memo(Remark, (prev, next) => {
43+
return prev.ru === next.ru;
44+
});

0 commit comments

Comments
 (0)