Skip to content

Commit f27236e

Browse files
committed
feat: added react-jsonschema-form & form example
1 parent 85d9b14 commit f27236e

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ I prefer to keep this setup trim but feel free to sprinkle some more pixie dust
1717
* Code coverage with [Isparta](https://github.com/douglasduteil/isparta)
1818
* Debug ES6 code with Webpack 2
1919
* ESLint ES6 configuration
20-
* Style guide: [JS Standard Style](docs/style-guide.md) - Want [semicolons?](docs/style-guide.md)
20+
* Style guide: [JS Standard Style](docs/style-guide.md)
2121
* Docker - build & launch your project - [Instructions](docs/docker.md)
2222
* Development: HMR (Hot Module Replacement) for both client & server
2323
* Production ready
24-
* Miscellaneous features: react-router-transition, pre-git, bunyan, mustache, GA tracking code, etc.
24+
* Miscellaneous features: react-router-transition, react-jsonschema-form, pre-git, bunyan, mustache, GA tracking code, etc.
2525

2626
## Documentation
2727

docs/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ NOTES
1717
* koa-better-body: use ^2.0.1 because ^3.0.0 causes issues with session (for login) (10/14/2016). Need investigation.
1818

1919
* postcss-import: pinned to 8.1.0. Newer version causes this error (10/12/2016)
20-
Error: ENOENT: no such file or directory, open '/Users/duc/Documents/wings/wingsui/object-assign'
20+
* https://github.com/postcss/postcss-import/issues/207
2121

2222
```
2323
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/duc/Documents/work/react-setup/object-assign'

docs/style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
React-Setup uses [JS Standard Style](https://github.com/feross/standard)
1010

11-
We don't need semicolons since JS has ASI to take care of that.
11+
We don't need semicolons since Javascript has ASI to take care of that.
1212

1313
But if you really want semicolons, change ".eslintrc" to use: `"semi": [2, "always"]` then you can run this command to insert them automatically:
1414
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-setup",
33
"description": "A Universal React setup with i18n: Babel 6, Koa 2, React, React Router, React Transmit, React Bootstrap, React-intl, Mocha, Webpack HMR, PostCSS, ESLint.",
4-
"version": "3.7.1",
4+
"version": "3.8.0",
55
"author": "Duc Nguyen (https://github.com/ngduc)",
66
"license": "MIT",
77
"homepage": "https://github.com/ngduc/react-setup",
@@ -105,6 +105,7 @@
105105
"react-dom": "^15.3.2",
106106
"react-inline-css": "^2.3.0",
107107
"react-intl": "^2.1.5",
108+
"react-jsonschema-form": "^0.40.0",
108109
"react-motion": "^0.4.5",
109110
"react-router": "^2.8.1",
110111
"react-router-transition": "^0.0.6",

src/containers/About/About.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
import React from 'react'
2+
import Form from 'react-jsonschema-form'
23

34
import { Msg } from './messages'
45

6+
const schema = {
7+
type: 'object',
8+
required: ['name'],
9+
properties: {
10+
name: { type: 'string', title: 'Your name', default: '' },
11+
feedback: { type: 'string', title: 'Feedback', default: '' }
12+
}
13+
}
14+
const uiSchema = {
15+
feedback: { 'ui:widget': 'textarea' }
16+
}
17+
518
export default class About extends React.Component {
19+
20+
onSubmit = (ev) => {
21+
alert(`Thank you ${ev.formData.name}!`)
22+
}
23+
624
render () {
725
return (
826
<section>
927
<h3><Msg s="title"/></h3>
1028

1129
<p><Msg s="intro"/></p>
30+
31+
<div>
32+
<Form schema={schema} uiSchema={uiSchema}
33+
autoFocus={true} showErrorList={false}
34+
onSubmit={this.onSubmit}>
35+
</Form>
36+
</div>
1237
</section>
1338
)
1439
}

src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ try {
2222
app.keys = ['seekreet', 'r3act-s3tup-k3y']
2323

2424
app.use(koaCompress({ flush: zlib.Z_SYNC_FLUSH }))
25-
app.use(koaConvert(koaStaticCache('static', { gzip: true, maxAge: 1 * 24 * 60 * 60 })))
25+
app.use(koaConvert(koaStaticCache('static', { gzip: true, maxAge: 14 * 24 * 60 * 60 }))) // 2 weeks
2626
app.use(koaConvert(koaSession(app)))
2727
app.use(koaBetterBody({ textLimit: '5mb', formLimit: '5mb', jsonLimit: '5mb' }))
2828

0 commit comments

Comments
 (0)