Skip to content

Commit ede6e87

Browse files
committed
update readme
1 parent 63b867a commit ede6e87

6 files changed

Lines changed: 59 additions & 16 deletions

File tree

readme.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
11
# dob-react-devtools [![npm version](https://img.shields.io/npm/v/dob-react-devtools.svg?style=flat)](https://www.npmjs.com/package/dob-react-devtools)
2+
3+
Devtools for dob-react, with action and ui two way binding.
4+
5+
![dob-react-devtools demo](https://user-images.githubusercontent.com/7970947/31849585-433f33d2-b60a-11e7-9a31-da84032b692a.gif)
6+
7+
## Usage
8+
9+
```typescript
10+
import "dob-react-devtools"
11+
import { startDebug } from "dob-react"
12+
13+
startDebug()
14+
```
15+
16+
## Installation
17+
18+
Dob-react-devtools is available as the dob package on [npm](https://www.npmjs.com/package/dob-react-devtools).
19+
20+
```
21+
tnpm i dob-react-devtools
22+
```
23+
24+
## Features
25+
26+
- UI elements that are decorated with Connect, will highlight when dob triggers rerender.
27+
- Visually record the triggered action history and display data changes.
28+
- When UI element rerender, you can see the list of action associated with it.
29+
- View each UI element, that each action triggerd.

src/demo/pages/simple-crud/article/index.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export default class Article extends PureComponent<Props, State> {
1212
return (
1313
<li>
1414
<p>
15-
文章名:{this.props.article.title}
15+
title: {this.props.article.title}
1616
</p>
1717
<p>
18-
作者:{this.props.article.author}
18+
author: {this.props.article.author}
1919
</p>
2020
<input
21-
placeholder="输入修改当前文章名.."
21+
placeholder="change current article's title.."
2222
onChange={event => {
2323
this.props.ArticleAction.changeArticleTitle(this.props.index, event.currentTarget.value)
2424
}}

src/demo/pages/simple-crud/index.component.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ export default class Page1 extends PureComponent<Props, State> {
1919
<div>
2020
<button onClick={() => {
2121
this.props.ArticleAction.addArticle()
22-
}}>添加文章</button>
22+
}}>add article</button>
2323

2424
<button onClick={() => {
25-
this.props.ArticleAction.multipleAction('123')
26-
}}>添加文章并修改文章名为123</button>
25+
this.props.ArticleAction.addArticleAndChangeTitle('custom name')
26+
}}>add article and change name</button>
2727

2828
<button onClick={() => {
2929
this.props.ArticleAction.runAsyncTest()
30-
}}>测试异步方法,值为 {this.props.ArticleStore.a.b.c.d}</button>
30+
}}>test async action {this.props.ArticleStore.a.b.c.d}</button>
31+
32+
<button onClick={() => {
33+
this.props.ArticleAction.runAnonymousTest()
34+
}}>test anonymous action</button>
3135

3236
<ul>
3337
{Articles}

src/demo/stores/article/action.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ArticleAction {
1414
@Action addArticle() {
1515
return this.ArticleStore.articles.push({
1616
id: Math.random(),
17-
title: '测试',
17+
title: 'test dob-react-devtools',
1818
author: 'ascoders'
1919
})
2020
}
@@ -28,7 +28,7 @@ export class ArticleAction {
2828
this.ArticleStore.articles.splice(index, 1)
2929
}
3030

31-
@Action multipleAction(title: string) {
31+
@Action addArticleAndChangeTitle(title: string) {
3232
const index = this.addArticle()
3333
this.changeArticleTitle(index - 1, title)
3434
}
@@ -42,14 +42,17 @@ export class ArticleAction {
4242
}
4343
}
4444
waitOneMinute().then(() => {
45-
Action(() => {
46-
this.ArticleStore.a.b.c.d = 7
47-
this.ArticleStore.a.b.c.d = 8
48-
this.ArticleStore.a.b.c.d = 9
49-
})
5045
this.ArticleStore.a.b.c.d = 7
5146
this.ArticleStore.a.b.c.d = 8
5247
this.ArticleStore.a.b.c.d = 9
5348
})
5449
}
50+
51+
@Action runAnonymousTest() {
52+
this.ArticleStore.a.b.c.d = 7
53+
Action(() => {
54+
this.ArticleStore.a.b.c.d = 8
55+
})
56+
this.ArticleStore.a.b.c.d = 9
57+
}
5558
}

src/tool-box/debug-line/action/action.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class Action extends React.PureComponent<Props, State>{
7070
private renderTitle() {
7171
if (this.props.debugInfo.name === null) {
7272
return (
73-
<S.UnknowTitle>Unknow</S.UnknowTitle>
73+
<S.AnonymousTitle>Anonymous</S.AnonymousTitle>
7474
)
7575
}
7676

src/tool-box/debug-line/action/action.style.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Title = styled.div`
3535
`}
3636
`
3737

38-
export const UnknowTitle = styled.div`
38+
export const AnonymousTitle = styled.div`
3939
text-shadow: 1px 1px #666, 0px 0px #111;
4040
`
4141

@@ -49,6 +49,14 @@ export const ChangeContainer = styled.div`
4949
border-top: 1px solid #111;
5050
border-bottom: 1px solid #404040;
5151
overflow-x: auto;
52+
&::-webkit-scrollbar-thumb {
53+
background-color: #333;
54+
}
55+
&::-webkit-scrollbar {
56+
width: 5px;
57+
height: 8px;
58+
background-color: #666;
59+
}
5260
`
5361

5462
export const ChangeBox = styled.div`

0 commit comments

Comments
 (0)