Skip to content

Commit d78487d

Browse files
authored
chore: use dumi (#72)
1 parent 30ad10e commit d78487d

28 files changed

+114
-24
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ es/
3333
.storybook
3434
.doc
3535
.history
36+
# umi
37+
.umi
38+
.umi-production
39+
.umi-test

.umirc.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// more config: https://d.umijs.org/config
2+
import { defineConfig } from 'dumi';
3+
4+
export default defineConfig({
5+
title: 'rc-image',
6+
favicon:
7+
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
8+
logo:
9+
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
10+
outputPath: '.doc',
11+
exportStatic: {},
12+
styles: [
13+
`
14+
.markdown table {
15+
width: auto !important;
16+
}
17+
`,
18+
]
19+
});

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# rc-image
22

3-
---
4-
53
React Image.
64

75
[![NPM version][npm-image]][npm-url] [![CircleCI status][circleci-image]][circleci-url] [![Test coverage][codecov-image]][codecov-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
@@ -34,8 +32,6 @@ React Image.
3432
- [x] Fallback
3533
- [x] Multiple Preview
3634

37-
### Keyboard
38-
3935
## install
4036

4137
[![rc-image](https://nodei.co/npm/rc-image.png)](https://npmjs.org/package/rc-image)
@@ -47,7 +43,7 @@ npm install
4743
npm start
4844
```
4945

50-
```jsx
46+
```js
5147
const Image = require('rc-image');
5248

5349
ReactDOM.render(
@@ -70,7 +66,7 @@ ReactDOM.render(
7066

7167
preview the merged src
7268

73-
```jsx
69+
```js
7470
const Image = require('rc-image');
7571

7672
ReactDOM.render(

docs/demo/basic.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## basic
2+
3+
<code src="../examples/basic.tsx">

docs/demo/controlled.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## controlled
2+
3+
<code src="../examples/controlled.tsx">

docs/demo/controlledWithGroup.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## controlledWithGroup
2+
3+
<code src="../examples/controlledWithGroup.tsx">

docs/demo/fallback.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## fallback
2+
3+
<code src="../examples/fallback.tsx">

docs/demo/placeholder.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## placeholder
2+
3+
<code src="../examples/placeholder.tsx">

docs/demo/previewgroup.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## previewgroup
2+
3+
<code src="../examples/previewgroup.tsx">

docs/demo/thumbnail.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## thumbnail
2+
3+
<code src="../examples/thumbnail.tsx">

examples/basic.tsx renamed to docs/examples/basic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import Image from '../src';
3-
import '../assets/index.less';
2+
import Image from 'rc-image';
3+
import '../../assets/index.less';
44

55
export default function Base() {
66
return (

examples/controlled.tsx renamed to docs/examples/controlled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import Image from '../src';
3-
import '../assets/index.less';
2+
import Image from 'rc-image';
3+
import '../../assets/index.less';
44

55
export default function Base() {
66
const [visible, setVisible] = React.useState(false);

examples/controlledWithGroup.tsx renamed to docs/examples/controlledWithGroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable global-require */
22
import * as React from 'react';
3-
import Image from '../src';
4-
import '../assets/index.less';
3+
import Image from 'rc-image';
4+
import '../../assets/index.less';
55

66
export default function Base() {
77
const [visible, setVisible] = React.useState(false);
File renamed without changes.

examples/fallback.tsx renamed to docs/examples/fallback.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import Image from '../src';
3-
import '../assets/index.less';
2+
import Image from 'rc-image';
3+
import '../../assets/index.less';
44

55
export default function Base() {
66
return (
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/placeholder.tsx renamed to docs/examples/placeholder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import Image from '../src';
3-
import '../assets/index.less';
2+
import Image from 'rc-image';
3+
import '../../assets/index.less';
44

55
export default function Base() {
66
const [random, setRandom] = React.useState(Date.now());

examples/previewgroup.tsx renamed to docs/examples/previewgroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable global-require */
22
import * as React from 'react';
3-
import Image from '../src';
4-
import '../assets/index.less';
3+
import Image from 'rc-image';
4+
import '../../assets/index.less';
55

66
export default function PreviewGroup() {
77
return (

examples/thumbnail.tsx renamed to docs/examples/thumbnail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import Image from '../src';
3-
import '../assets/index.less';
2+
import Image from 'rc-image';
3+
import '../../assets/index.less';
44

55
export default function Thumbnail() {
66
return (

docs/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: rc-image
3+
---
4+
5+
<embed src="../README.md"></embed>

now.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"use": "@now/static-build",
88
"config": { "distDir": ".doc" }
99
}
10+
],
11+
"routes": [
12+
{ "src": "/(.*)", "dest": "/dist/$1" }
1013
]
1114
}

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@
2626
},
2727
"license": "MIT",
2828
"scripts": {
29-
"start": "cross-env NODE_ENV=development father doc dev --storybook",
30-
"build": "father doc build --storybook",
29+
"start": "dumi dev",
30+
"docs:build": "dumi build",
31+
"docs:deploy": "gh-pages -d docs-dist",
3132
"compile": "father build && lessc assets/index.less assets/index.css",
3233
"prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
3334
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
3435
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
3536
"test": "father test",
36-
"coverage": "father test --coverage"
37+
"coverage": "father test --coverage",
38+
"now-build": "npm run docs:build"
3739
},
3840
"peerDependencies": {
3941
"react": ">=16.9.0",
@@ -54,11 +56,13 @@
5456
"@types/react-dom": "^16.9.8",
5557
"@umijs/fabric": "^2.2.2",
5658
"cross-env": "^7.0.2",
59+
"dumi": "^1.1.4",
5760
"enzyme": "^3.11.0",
5861
"enzyme-adapter-react-16": "^1.15.2",
5962
"enzyme-to-json": "^3.5.0",
6063
"eslint": "^7.6.0",
6164
"father": "^2.29.6",
65+
"glob": "^7.1.6",
6266
"less": "^3.12.2",
6367
"np": "^7.0.0",
6468
"react": "^16.13.1",

tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"jsx": "preserve",
77
"declaration": true,
88
"skipLibCheck": true,
9-
"esModuleInterop": true
9+
"esModuleInterop": true,
10+
"paths": {
11+
"@/*": ["src/*"],
12+
"@@/*": ["src/.umi/*"],
13+
"rc-image": ["src/index.ts"]
14+
}
1015
}
1116
}

typings.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '*.css';
2+
declare module '*.less';

update-example.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
用于 dumi 改造使用,
3+
可用于将 examples 的文件批量修改为 demo 引入形式,
4+
其他项目根据具体情况使用。
5+
*/
6+
7+
const fs = require('fs');
8+
const glob = require('glob');
9+
10+
const suffix = '.tsx';
11+
12+
const paths = glob.sync(`./docs/examples/*${suffix}`);
13+
14+
paths.forEach(path => {
15+
const name = path.split('/').pop().split('.')[0];
16+
fs.writeFile(
17+
`./docs/demo/${name}.md`,
18+
`## ${name}
19+
20+
<code src="../examples/${name}${suffix}">
21+
`,
22+
'utf8',
23+
function(error) {
24+
if(error){
25+
console.log(error);
26+
return false;
27+
}
28+
console.log(`${name} 更新成功~`);
29+
}
30+
)
31+
});

0 commit comments

Comments
 (0)