Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joepuzzo committed Nov 19, 2020
1 parent 280ee13 commit aa52fe8
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/iframe.html
Expand Up @@ -71,4 +71,4 @@
}</script><style>#root[hidden],
#docs-root[hidden] {
display: none !important;
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.29905a682e2971d1d601.bundle.js"></script><script src="vendors~main.29905a682e2971d1d601.bundle.js"></script><script src="main.29905a682e2971d1d601.bundle.js"></script></body></html>
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.0fb3e2140882113bc1be.bundle.js"></script><script src="vendors~main.0fb3e2140882113bc1be.bundle.js"></script><script src="main.0fb3e2140882113bc1be.bundle.js"></script></body></html>
3 changes: 3 additions & 0 deletions docs/main.0fb3e2140882113bc1be.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/main.0fb3e2140882113bc1be.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions docs/main.29905a682e2971d1d601.bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/main.29905a682e2971d1d601.bundle.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/runtime~main.0fb3e2140882113bc1be.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/runtime~main.29905a682e2971d1d601.bundle.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/vendors~main.0fb3e2140882113bc1be.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/vendors~main.29905a682e2971d1d601.bundle.js.map

This file was deleted.

35 changes: 16 additions & 19 deletions stories/CustomInputs/UseField/README.md
@@ -1,9 +1,12 @@
## What if I want more control!?
# Custom Inputs

**I got you!** Check out the example below:
Sometimes the inputs `informed` provides are not good enough. So we decided to
help you out with that! Informed also gives you access to an useField Hook.

Here we use the hook `useField` instead of the HOC `asField`. This allows us to do things like,
set a default validation function!
## Custom Text Input

Lets say you like `informed`'s text input but you want to show an error and turn
it red when there is an error. You could achieve this with the following code.

<!-- STORY -->

Expand All @@ -12,16 +15,8 @@ set a default validation function!
```jsx
import { Form, useField } from 'informed';

const validate = value => {
return !value || value.length < 5
? 'Field must be at least five characters'
: undefined;
};

const ErrorText = (props) => {

const { fieldState, fieldApi, render, ref, userProps } = useField( { ...props, validate });
// ^^^^^^^^ THIS IS THE BIG DIFFERENCE
const ErrorText = props => {
const { fieldState, fieldApi, render, ref, userProps } = useField(props);

const { value } = fieldState;
const { setValue, setTouched } = fieldApi;
Expand Down Expand Up @@ -53,14 +48,16 @@ const ErrorText = (props) => {
);
};

const validate = value => {
return !value || value.length < 5
? 'Field must be at least five characters'
: undefined;
};

<Form id="custom-form">
<label>
First name:
<ErrorText
field="name"
validateOnChange
validateOnBlur
/>
<ErrorText field="name" validateOnChange validateOnBlur />
</label>
<button type="submit">Submit</button>
</Form>;
Expand Down
8 changes: 4 additions & 4 deletions stories/CustomInputs/index.js
Expand Up @@ -7,10 +7,10 @@ import UseFieldHooked from './UseFieldHooked';

const CreatingCustomInputs = () => (
<div>
<Intro />
<br />
<FromScratch />
<br />
{/* <Intro /> */}
{/* <br /> */}
{/* <FromScratch /> */}
{/* <br /> */}
<UseField />
<br />
<UseFieldHooked />
Expand Down

0 comments on commit aa52fe8

Please sign in to comment.