Skip to content

chore: use dumi #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ es/
.storybook
.doc
.history
# umi
.umi
.umi-production
.umi-test
19 changes: 19 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// more config: https://d.umijs.org/config
import { defineConfig } from 'dumi';

export default defineConfig({
title: 'rc-image',
favicon:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
logo:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
outputPath: '.doc',
exportStatic: {},
styles: [
`
.markdown table {
width: auto !important;
}
`,
]
});
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# rc-image

---

React Image.

[![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]
Expand Down Expand Up @@ -34,8 +32,6 @@ React Image.
- [x] Fallback
- [x] Multiple Preview

### Keyboard

## install

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

```jsx
```js
const Image = require('rc-image');

ReactDOM.render(
Expand All @@ -70,7 +66,7 @@ ReactDOM.render(

preview the merged src

```jsx
```js
const Image = require('rc-image');

ReactDOM.render(
Expand Down
3 changes: 3 additions & 0 deletions docs/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## basic

<code src="../examples/basic.tsx">
3 changes: 3 additions & 0 deletions docs/demo/controlled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## controlled

<code src="../examples/controlled.tsx">
3 changes: 3 additions & 0 deletions docs/demo/controlledWithGroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## controlledWithGroup

<code src="../examples/controlledWithGroup.tsx">
3 changes: 3 additions & 0 deletions docs/demo/fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## fallback

<code src="../examples/fallback.tsx">
3 changes: 3 additions & 0 deletions docs/demo/placeholder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## placeholder

<code src="../examples/placeholder.tsx">
3 changes: 3 additions & 0 deletions docs/demo/previewgroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## previewgroup

<code src="../examples/previewgroup.tsx">
3 changes: 3 additions & 0 deletions docs/demo/thumbnail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## thumbnail

<code src="../examples/thumbnail.tsx">
4 changes: 2 additions & 2 deletions examples/basic.tsx → docs/examples/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Base() {
return (
Expand Down
4 changes: 2 additions & 2 deletions examples/controlled.tsx → docs/examples/controlled.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Base() {
const [visible, setVisible] = React.useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require */
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Base() {
const [visible, setVisible] = React.useState(false);
Expand Down
File renamed without changes
4 changes: 2 additions & 2 deletions examples/fallback.tsx → docs/examples/fallback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Base() {
return (
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions examples/placeholder.tsx → docs/examples/placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Base() {
const [random, setRandom] = React.useState(Date.now());
Expand Down
4 changes: 2 additions & 2 deletions examples/previewgroup.tsx → docs/examples/previewgroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require */
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function PreviewGroup() {
return (
Expand Down
4 changes: 2 additions & 2 deletions examples/thumbnail.tsx → docs/examples/thumbnail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Image from '../src';
import '../assets/index.less';
import Image from 'rc-image';
import '../../assets/index.less';

export default function Thumbnail() {
return (
Expand Down
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: rc-image
---

<embed src="../README.md"></embed>
3 changes: 3 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"use": "@now/static-build",
"config": { "distDir": ".doc" }
}
],
"routes": [
{ "src": "/(.*)", "dest": "/dist/$1" }
]
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
},
"license": "MIT",
"scripts": {
"start": "cross-env NODE_ENV=development father doc dev --storybook",
"build": "father doc build --storybook",
"start": "dumi dev",
"docs:build": "dumi build",
"docs:deploy": "gh-pages -d docs-dist",
"compile": "father build && lessc assets/index.less assets/index.css",
"prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"test": "father test",
"coverage": "father test --coverage"
"coverage": "father test --coverage",
"now-build": "npm run docs:build"
},
"peerDependencies": {
"react": ">=16.9.0",
Expand All @@ -54,11 +56,13 @@
"@types/react-dom": "^16.9.8",
"@umijs/fabric": "^2.2.2",
"cross-env": "^7.0.2",
"dumi": "^1.1.4",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.5.0",
"eslint": "^7.6.0",
"father": "^2.29.6",
"glob": "^7.1.6",
"less": "^3.12.2",
"np": "^7.0.0",
"react": "^16.13.1",
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true
"esModuleInterop": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"],
"rc-image": ["src/index.ts"]
}
}
}
2 changes: 2 additions & 0 deletions typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '*.css';
declare module '*.less';
31 changes: 31 additions & 0 deletions update-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
用于 dumi 改造使用,
可用于将 examples 的文件批量修改为 demo 引入形式,
其他项目根据具体情况使用。
*/

const fs = require('fs');
const glob = require('glob');

const suffix = '.tsx';

const paths = glob.sync(`./docs/examples/*${suffix}`);

paths.forEach(path => {
const name = path.split('/').pop().split('.')[0];
fs.writeFile(
`./docs/demo/${name}.md`,
`## ${name}

<code src="../examples/${name}${suffix}">
`,
'utf8',
function(error) {
if(error){
console.log(error);
return false;
}
console.log(`${name} 更新成功~`);
}
)
});