Skip to content

Commit 7ac093b

Browse files
committed
fix Active, Focus, Hover bind apis
1 parent e318d88 commit 7ac093b

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

docs/components/Active.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Active } from 'react-powerplug'
99

1010
```jsx
1111
<Active>
12-
{({ isActive, bindActive }) => (
13-
<div {...bindActive}>
12+
{({ isActive, bind }) => (
13+
<div {...bind}>
1414
You are {isActive ? 'clicking' : 'not clicking'} this div.
1515
</div>
1616
)}
@@ -23,18 +23,18 @@ _Don't have props_
2323

2424
## Active Children Props
2525

26-
TL;DR: `{ isActive, bindActive }`
26+
TL;DR: `{ isActive, bind }`
2727

2828
**isActive**
2929
`boolean`
3030
True if is activated (being clicked) the binded element
3131

32-
**bindActive**
32+
**bind**
3333
`{ onMouseUp: () => void, onMouseDown: () => void }`
3434
There are the bind event functions that make `Active` works.
3535
You **must** bind some element to track their events.
3636
You can use spread operator to bind effectively an element.
3737

3838
```jsx
39-
<span {...bindActive}>Binded!</span>
39+
<span {...bind}>Binded!</span>
4040
```

docs/components/Focus.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { Focus } from 'react-powerplug'
99

1010
```jsx
1111
<Focus>
12-
{({ isFocus, bindFocus }) => (
12+
{({ isFocused, bind }) => (
1313
<div>
14-
<input {...bindFocus} placeholder="Focus me" />
15-
<div>You are {isFocus ? 'focusing' : 'not focusing'} the input.</div>
14+
<input {...bind} placeholder="Focus me" />
15+
<div>You are {isFocused ? 'focusing' : 'not focusing'} the input.</div>
1616
</div>
1717
)}
1818
</Focus>
@@ -24,18 +24,18 @@ _Don't have props_
2424

2525
## Focus Children Props
2626

27-
TL;DR: `{ isFocus, bindFocus }`
27+
TL;DR: `{ isFocused, bind }`
2828

29-
**isFocus**
29+
**isFocused**
3030
`boolean`
3131
True if is focusing the binded element
3232

33-
**bindFocus**
33+
**bind**
3434
`{ onFocusIn: () => void, onFocusOut: () => void }`
3535
There are the bind event functions that make `Focus` works.
3636
You **must** bind some element to track their events.
3737
You can use spread operator to bind effectively an element.
3838

3939
```jsx
40-
<button {...bindFocus}>Binded!</button>
40+
<button {...bind}>Binded!</button>
4141
```

docs/components/Hover.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { Hover } from 'react-powerplug'
99

1010
```jsx
1111
<Hover>
12-
{({ isHover, bindHover }) => (
13-
<div {...bindHover}>
14-
You are {isHover ? 'hovering' : 'not hovering'} this div.
12+
{({ isHovered, bind }) => (
13+
<div {...bind}>
14+
You are {isHovered ? 'hovering' : 'not hovering'} this div.
1515
</div>
1616
)}
1717
</Hover>
@@ -23,18 +23,18 @@ _Don't have props_
2323

2424
## Hover Children Props
2525

26-
TL;DR: `{ isHover, bindHover }`
26+
TL;DR: `{ isHovered, bind }`
2727

28-
**isHover**
28+
**isHovered**
2929
`boolean`
3030
True if is hovering the binded element
3131

32-
**bindHover**
32+
**bind**
3333
`{ onMouseEnter: () => void, onMouseLeave: () => void }`
3434
There are the bind event functions that make `Hover` works.
3535
You **must** bind some element to track their events.
3636
You can use spread operator to bind effectively an element.
3737

3838
```jsx
39-
<span {...bindHover}>Binded!</span>
39+
<span {...bind}>Binded!</span>
4040
```

src/components/Active.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const Active = ({ onChange, ...props }) => (
77
{({ state, setState }) =>
88
renderProps(props, {
99
isActive: state.isActive,
10-
bindActive: {
10+
bind: {
1111
onMouseDown: () => setState({ isActive: true }),
1212
onMouseUp: () => setState({ isActive: false }),
1313
},

src/components/Focus.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import State from './State'
33
import renderProps from '../utils/renderProps'
44

55
const Focus = ({ onChange, ...props }) => (
6-
<State initial={{ isFocus: false }} onChange={onChange}>
6+
<State initial={{ isFocused: false }} onChange={onChange}>
77
{({ state, setState }) =>
88
renderProps(props, {
9-
isFocus: state.isFocus,
10-
bindFocus: {
11-
onFocusIn: () => setState({ isFocus: true }),
12-
onFocusOut: () => setState({ isFocus: false }),
9+
isFocused: state.isFocused,
10+
bind: {
11+
onFocus: () => setState({ isFocused: true }),
12+
onBlur: () => setState({ isFocused: false }),
1313
},
1414
})
1515
}

src/components/Hover.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import State from './State'
33
import renderProps from '../utils/renderProps'
44

55
const Hover = ({ onChange, ...props }) => (
6-
<State initial={{ isHover: false }} onChange={onChange}>
6+
<State initial={{ isHovered: false }} onChange={onChange}>
77
{({ state, setState }) =>
88
renderProps(props, {
9-
isHover: state.isHover,
10-
bindHover: {
11-
onMouseEnter: () => setState({ isHover: true }),
12-
onMouseLeave: () => setState({ isHover: false }),
9+
isHovered: state.isHovered,
10+
bind: {
11+
onMouseEnter: () => setState({ isHovered: true }),
12+
onMouseLeave: () => setState({ isHovered: false }),
1313
},
1414
})
1515
}

0 commit comments

Comments
 (0)