Skip to content

Commit df53800

Browse files
committed
New art
1 parent 30730b6 commit df53800

File tree

6 files changed

+10
-24
lines changed

6 files changed

+10
-24
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Typed React form [![NPM](https://img.shields.io/npm/v/typed-react-form.svg)](https://www.npmjs.com/package/typed-react-form) [![NPM Size](https://img.shields.io/bundlephobia/minzip/typed-react-form)](https://bundlephobia.com/result?p=typed-react-form)
22

3-
![vscode typescript](https://github.com/CodeStix/typed-react-form/raw/master/testing/public/thumb.png)
3+
4+
<p align="center" width="100%">
5+
<img width="33%" src="https://github.com/CodeStix/typed-react-form/raw/master/docs/images/thumbextrasmall.png">
6+
</p>
47

58
A fast, completely type-checked React form builder, focussed on typescript integration and minimal rerenders. Featuring:
69

docs/images/thumb.pdn

115 KB
Binary file not shown.

docs/images/thumb.png

42.3 KB
Loading

docs/images/thumbextrasmall.png

11.3 KB
Loading

docs/images/thumbsmall.png

13.1 KB
Loading

docs/reference/Field.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,29 +149,12 @@ You should only use the `errorStyle`, `dirtyStyle`, `errorClassName` and `dirtyC
149149

150150
You should pass a custom component to the `as` prop of `Field`. The props required by your component will be placed on the `Field` component (will be type-checked).
151151

152-
```tsx
153-
function CustomInput(props: { value: any; onChange: React.ChangeEventHandler }) {
154-
return <input value={props.value} onChange={props.onChange} style={%raw%}{{ padding: "0.3em" }}{%endraw%} />;
155-
}
156-
157-
// The value and onChange props are handled by Field
158-
<Field as={CustomInput} />;
159-
160-
function StyledCustomInput(props: { value: any; onChange: React.ChangeEventHandler; style: React.CSSProperties }) {
161-
return <input value={props.value} onChange={props.onChange} style={%raw%}{{ ...props.style, padding: "0.3em" }}{%endraw%} />;
162-
}
163-
164-
// Style prop must be given (because it is required on the CustomInput component), typescript error otherwise
165-
<Field as={StyledCustomInput} style={%raw%}{{ color: "gray" }}{%endraw%} />;
166-
167-
// The field prop is passed by the Field component
168-
function CustomInput(props: { value: any; onChange: React.ChangeEventHandler; field: FormField }) {
169-
return <input value={props.value} onChange={props.onChange} style={%raw%}{{ padding: "0.3em", color: props.field.error ? "red" : "gray" }}{%endraw%} />;
170-
}
171-
172-
// The value and onChange props are handled by Field
173-
<Field as={CustomInput} />;
174-
```
152+
<iframe src="https://codesandbox.io/embed/custom-input-typed-react-form-example-ck21d?fontsize=14&theme=dark"
153+
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
154+
title="custom input typed-react-form example"
155+
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
156+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
157+
></iframe>
175158
176159
Some props of your custom component will be filled in automatically by the `Field` component:
177160

0 commit comments

Comments
 (0)