-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from pfgray/better_demos
Adding better demos
- Loading branch information
Showing
11 changed files
with
222 additions
and
262 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
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,31 @@ | ||
import * as React from 'react'; | ||
import { withState } from '../../src/lib/withState'; | ||
import { all, Do, ChainableComponent } from '../../src/ChainableComponent'; | ||
import Step from '../Step'; | ||
|
||
export const DoDemo = () => | ||
Do(function*() { | ||
const a = yield withState({initial: 'string value'}); | ||
const b = yield withState({initial: 8432}); | ||
return [a, b]; | ||
}) | ||
.ap(([a, b]) => ( | ||
<div> | ||
{/* a.value is inferred as a string */} | ||
<div>a: {a.value} <button onClick={() => a.update(a.value + 1)}>+</button></div> | ||
|
||
{/* b.value through f.value is inferred as a number */} | ||
<div>b: {b.value} <button onClick={() => b.update(b.value + 1)}>+</button></div> | ||
</div> | ||
)); | ||
|
||
export default () => ( | ||
<Step title="Do Demo"> | ||
<pre className='code-sample'> | ||
{`import { withState, all } from 'chainable-components';`} | ||
</pre> | ||
<DoDemo /> | ||
</Step> | ||
); | ||
|
||
|
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,25 @@ | ||
import * as React from 'react'; | ||
import { withState } from '../../src/lib/withState'; | ||
import { all, fromAp } from '../../src/ChainableComponent'; | ||
import Step from '../Step'; | ||
|
||
export const WithStateDemo = | ||
fromAp((ap: (a: number) => React.ReactNode) => ( | ||
function() { | ||
return <div>Applied: {ap(5)}</div> | ||
} | ||
)) | ||
.ap(a => ( | ||
<div>wait, wuuuut: {a}</div> | ||
)); | ||
|
||
export default () => ( | ||
<Step title="FromAp Demo"> | ||
<pre className='code-sample'> | ||
{`import { withState, all } from 'chainable-components';`} | ||
</pre> | ||
{WithStateDemo} | ||
</Step> | ||
); | ||
|
||
|
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
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
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
Oops, something went wrong.