Skip to content

Commit

Permalink
Merge branch 'support/migrate-to-father-doc' into v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys026 committed Jan 14, 2020
2 parents 6fc9ecc + 367fbc8 commit 9a5c58f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/coverage
.doc
.DS_Store
src/.umi
13 changes: 13 additions & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
extraBabelPlugins: [[
'babel-plugin-import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
},
]],
doc: {
locales: [['en-US', 'English'], ['zh-CN', '中文']]
}
}
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"homepage": "https://github.com/umijs/hooks",
"scripts": {
"start": "npm run dev",
"dev": "father doc dev",
"dev": "father-doc dev",
"dev:zh-cn": "LAN=zh-CN father doc dev",
"js": "node ./.ts2js.js",
"build": "node ./scripts/clean-old-build.js && father build && tsc --declarationDir ./lib && tsc --declarationDir ./es && node ./scripts/build-wind-up.js",
Expand Down Expand Up @@ -58,6 +58,7 @@
"docz-theme-umi-hooks": "^0.0.7",
"enzyme": "^3.10.0",
"father": "^2.13.3",
"father-doc": "^1.0.0-alpha.15",
"jackbox": "^0.2.0",
"now": "^16.2.0",
"raw-loader": "^3.1.0",
Expand Down
32 changes: 0 additions & 32 deletions src/useBoolean/demo/demo1.jsx

This file was deleted.

7 changes: 6 additions & 1 deletion src/useBoolean/demo/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/**
* title: Default usage
* desc: Default as a switch function,or accept a parameter to change state
*/

import React from 'react';
import { Button, Switch } from 'antd';
import useBoolean from '..';
import { useBoolean } from '@umijs/hooks';

export default () => {
const { state, toggle, setTrue, setFalse } = useBoolean(true);
Expand Down
20 changes: 6 additions & 14 deletions src/useBoolean/index_en.mdx → src/useBoolean/index.en-US.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
---
name: useBoolean
route: /useBoolean
menu: 'State'
edit: false
sidebar: true
title: useBoolean
group:
title: State Hooks
path: /state
---
import JackBox from 'jackbox';

import Demo1 from './demo/demo1';
import Demo1CodeTsx from '!raw-loader!./demo/demo1.tsx';
import Demo1CodeJsx from '!raw-loader!./demo/demo1.jsx';

# useBoolean

Expand All @@ -19,9 +13,7 @@ A hook that elegantly manages boolean values.

### Default usage

<JackBox jsCode={Demo1CodeJsx} tsCode={Demo1CodeTsx} demoName='Default usage' description='Default as a switch function,or accept a parameter to change state'>
<Demo1 />
</JackBox>
<code src="./demo/demo1.tsx" />

## API

Expand Down Expand Up @@ -49,4 +41,4 @@ const {

| Property | Description | Type | Default |
|---------|----------------------------------------------|------------------------|--------|
| defaultValue | Optional,set a default value | boolean \| undefined | false |
| defaultValue | Optional,set a default value | boolean \| undefined | false |
43 changes: 43 additions & 0 deletions src/useBoolean/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: useBoolean
group:
title: State Hooks
path: /state
---

# useBoolean

优雅的管理 boolean 值的 Hook。

## 代码演示

<code src="./demo/demo1.tsx" />

## API

```javascript
const {
state,
toggle,
setTrue,
setFalse
} = useBoolean(
defaultValue?: boolean,
);
```

### Result

| 参数 | 说明 | 类型 |
|----------|--------------------------------------|----------------------|
| state | 状态值 | boolean |
| toggle | 触发状态更改的函数,可以接受一个可选参数修改状态值 | (value?: any) => void |
| setTrue | 设置状态值为 true | () => void |
| setFalse | 设置状态值为 false | () => void |

### Params

| 参数 | 说明 | 类型 | 默认值 |
|---------|----------------------------------------------|------------------------|--------|
| defaultValue | 可选项,传入默认的状态值 | boolean \| undefined | false |

0 comments on commit 9a5c58f

Please sign in to comment.