Skip to content

Commit f6bba85

Browse files
authored
Update sample code for version 2.0.0
1 parent 533b43d commit f6bba85

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

README.md

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# React Eureka [![npm](https://img.shields.io/npm/v/react-eureka.svg)](https://www.npmjs.com/package/react-eureka) [![npm](https://img.shields.io/npm/dm/react-eureka.svg)](https://www.npmjs.com/package/react-eureka)
22

3-
<img src="./src/logo.png" style="max-width: 250px">
3+
<img src="./src/logo.png" style="width: 250px">
44

55
A minimalistic form wizard component for React
66

@@ -17,59 +17,42 @@ import React, { Component } from 'react';
1717

1818
import { EurekaForm } from 'react-eureka';
1919

20-
const questions = [
21-
{
22-
title: "What's your email?",
23-
inputType: "email"
24-
},
25-
{
26-
title: "Where do you live?",
27-
},
28-
{
29-
title: "What time do you go to work?",
30-
},
31-
{
32-
title: "How do you like your veggies?",
33-
},
34-
{
35-
title: "What book inspires you?",
36-
},
37-
{
38-
title: "What's your profession?",
39-
},
40-
];
41-
4220
class EurekaDemo extends Component {
4321
constructor(props) {
4422
super(props);
4523

4624
this.state = {
25+
current: -1,
26+
values: {},
4727
formSubmitted: false
4828
};
4929
}
5030

5131
render() {
52-
const { formSubmitted } = this.state;
32+
const { formSubmitted, values } = this.state;
5333

5434
return (
5535
<div>
5636
{!formSubmitted &&
57-
<EurekaForm
58-
id="my-form"
59-
className="my-custom-class"
60-
questions={questions}
61-
autoFocus={true}
62-
onSubmit={el => {
63-
this.setState({
64-
...this.state,
65-
formSubmitted: true
66-
});
67-
}}
68-
/>
37+
<EurekaForm autoFocus
38+
onSubmit={this._onSubmit}
39+
onUpdate={(state) => this.setState(state)}>
40+
<span type='name'>
41+
What's your name
42+
</span>
43+
44+
<span type='email'>
45+
Hello <b>{values.name}</b>, and your email?
46+
</span>
47+
48+
<span type='tel'>
49+
Phone Number?
50+
</span>
51+
</EurekaForm>
6952
}
7053
7154
{formSubmitted &&
72-
<div>
55+
<div className="submit-message">
7356
Thank you for your response!
7457
</div>
7558
}
@@ -88,10 +71,11 @@ export default EurekaDemo;
8871
| className | string | "my-custom-class my-2nd-class" |
8972
| questions | array | `[{ title: "What's your email?", inputType: "email" }, { title: "Where do you live?", }]` |
9073
| autoFocus | boolean | true |
91-
| onSubmit | function | `(element, values) => console.log(values);` |
74+
| onUpdate | function | `(state) => this.setState(state);` |
75+
| onSubmit | function | `() => console.log("Make API calls!");` |
9276
9377
## Credits
9478
The implementation of the component is based on the work of
9579
[Mary Lou from Tympanus](https://tympanus.net/Development/MinimalForm/)
9680
97-
Logo is made by [Patrick Morrison](http://www.patrickmorrison.co.uk/)
81+
Logo is made by [Patrick Morrison](http://www.patrickmorrison.co.uk/)

0 commit comments

Comments
 (0)