-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minimal setup docz * chore: remove and ignore docz build folder * chore: add logo and primary color * fix: update dependencies * add more mdx to docz * add Touch.mdx to docz * add Hover.mdx to docz * add Focus.mdx to docz * add Active.mdx to docz * add FocusManager.mdx to docz * add State.mdx and Interval.mdx to docz * add Form.mdx to docz * add Counter.mdx to docz * add Compose.mdx to docz * add compose.mdx and composeEvents.mdx to docz * add Introduction and Guide to docz * add ordering to menus * deployment scripts * add setOn setOff to Toggle docs * remove FocusManager.mdx * edit readme
- Loading branch information
Showing
44 changed files
with
5,659 additions
and
2,560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.flow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.log | ||
.docz | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
name: Guide | ||
route: /guide | ||
order: 19 | ||
--- | ||
|
||
# Guide | ||
|
||
## Creating a Dumb Component | ||
|
||
Dumb Component, Presentational Component or (sometimes) Controlled Component is a component | ||
responsible **only for displaying content without any logic behind**. Usually they | ||
receive specific props, and if they are interactive, it exposes events like onClick, onChange, etc. | ||
|
||
A Styled Component a good example. | ||
|
||
```jsx | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
const DumbCheckbox = styled("div")` | ||
cursor: pointer; | ||
&:before { | ||
content: '${props => (props.checked ? "■" : "□")} '; | ||
} | ||
`; | ||
|
||
const App = () => ( | ||
<DumbCheckbox>Check me</DumbCheckbox> | ||
); | ||
``` | ||
|
||
## Using React PowerPlug | ||
|
||
Now that you have your Dumb Component, you can pass state to it. | ||
Using react-powerplug this step is trivial and pretty simple. | ||
|
||
```jsx | ||
import { Toggle } from "react-powerplug"; | ||
|
||
<Toggle> | ||
{({ on, toggle }) => ( | ||
<DumbCheckbox checked={on} onClick={toggle}> | ||
Check me | ||
</DumbCheckbox> | ||
)} | ||
</Toggle> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: Introduction | ||
route: / | ||
order: 20 | ||
--- | ||
|
||
# Introduction | ||
|
||
**React PowerPlug is a set of pluggable renderless components and utils** that provides | ||
different types of state and logics so you can use with your dumb components. It creates | ||
a state and pass down the logic to the children, so you can handle your data. | ||
Read about [Render Props](https://reactjs.org/docs/render-props.html) pattern. | ||
|
||
- Dependency free | ||
- Super tiny (~3kb) | ||
- Plug and play | ||
- Tree shaking friendly (ESM, no side effects) | ||
- Well documented | ||
- Bunch of awesome utilities | ||
|
||
## Quick Examples | ||
|
||
```jsx | ||
import { State, Toggle } from 'react-powerplug' | ||
import { Pagination, Tabs, Checkbox } from './MyDumbComponents' | ||
``` | ||
|
||
```jsx | ||
<State initial={{ offset: 0, limit: 10, totalCount: 200 }}> | ||
{({ state, setState }) => ( | ||
<Pagination {...state} onChange={(offset) => setState({ offset })} /> | ||
)} | ||
</State> | ||
``` | ||
|
||
```jsx | ||
<Toggle initial={true}> | ||
{({ on, toggle }) => ( | ||
<Checkbox checked={on} onChange={toggle} /> | ||
)} | ||
</Toggle> | ||
``` | ||
|
||
You can also use a `render` prop instead | ||
|
||
```jsx | ||
<Toggle | ||
initial={false} | ||
render={({ on, toggle }) => ( | ||
<Checkbox checked={on} onChange={toggle} /> | ||
)} | ||
/> | ||
``` |
Oops, something went wrong.