Skip to content

Commit 8a56c97

Browse files
committed
Added default stylesheet.
1 parent 72c3f28 commit 8a56c97

File tree

12 files changed

+234
-11
lines changed

12 files changed

+234
-11
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ $ npm install react-jsonschema-form --save
1818
As a script dependency served from a CDN:
1919

2020
```html
21-
<script src="https://npmcdn.com/react-jsonschema-form@0.4.1/dist/react-jsonschema-form-0.4.1.js"></script>
21+
<script src="https://npmcdn.com/react-jsonschema-form@0.5.0/dist/react-jsonschema-form.js"></script>
2222
```
2323

24-
Source maps are available at [this url](https://npmcdn.com/react-jsonschema-form@0.4.1/dist/react-jsonschema-form-0.4.1.js.map).
24+
Source maps are available at [this url](https://npmcdn.com/react-jsonschema-form@0.5.0/dist/react-jsonschema-form.js.map).
2525

2626
Note that the CDN version **does not** embed *react* nor *react-dom*.
2727

28+
A default, very basic CSS stylesheet is provided, though you're encouraged to build your own.
29+
30+
```html
31+
<link rel="stylesheet" href="https://npmcdn.com/[email protected]/dist/react-jsonschema-form.css">
32+
```
33+
2834
## Usage
2935

3036
```js
@@ -43,7 +49,7 @@ const schema = {
4349
}
4450
};
4551

46-
const formData =  {
52+
const formData = {
4753
title: "First task",
4854
done: true
4955
};
@@ -59,6 +65,10 @@ render((
5965
), document.getElementById("app"));
6066
```
6167

68+
That should give something like this (if you use the default stylesheet):
69+
70+
![](http://i.imgur.com/qKFvod6.png)
71+
6272
### Alternative widgets
6373

6474
JSONSchema is limited for describing how a given data type should be rendered as an input component, that's why this lib introduces the concept of *UI schema*. A UI schema is basically an object literal describing which UI widget should be used to render a certain field
@@ -100,6 +110,9 @@ $ npm start
100110

101111
A [Cosmos development server](https://github.com/skidding/cosmos) showcasing components with hot reload enabled is available at [localhost:8080](http://localhost:8080).
102112

113+
![](http://i.imgur.com/51KtbqO.png)
114+
115+
103116
## Tests
104117

105118
```

css/react-jsonschema-form.css

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.rjsf * {
2+
box-sizing: border-box;
3+
}
4+
5+
.rjsf {
6+
padding: 0;
7+
font-size: .8em;
8+
color: #555;
9+
}
10+
11+
.rjsf fieldset {
12+
border: 1px solid #aaa;
13+
border-radius: 4px;
14+
margin-top: .5em;
15+
}
16+
17+
.rjsf fieldset legend {
18+
font-weight: bold;
19+
margin-left: -.2em;
20+
}
21+
22+
.rjsf button {
23+
display: inline-block;
24+
color: #FFF;
25+
background-color: #286090;
26+
border-color: #122B40;
27+
padding: 2px 8px;
28+
font-size: 14px;
29+
font-weight: 400;
30+
line-height: 1.5em;
31+
white-space: nowrap;
32+
vertical-align: middle;
33+
cursor: pointer;
34+
border: 1px solid transparent;
35+
border-radius: 4px;
36+
}
37+
38+
.rjsf input[type=text] {
39+
display: block;
40+
width: 100%;
41+
height: 34px;
42+
padding: 3px 6px;
43+
font-size: 14px;
44+
color: #555;
45+
border: 1px solid #ccc;
46+
border-radius: 4px;
47+
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;
48+
}
49+
50+
.rjsf .errors {
51+
color: red;
52+
}
53+
54+
.rjsf .field {
55+
padding-top: 1em;
56+
}
57+
58+
.rjsf .field label {
59+
display: block;
60+
font-weight: bold;
61+
}
62+
63+
.rjsf .field input[type=text] {
64+
}
65+
66+
.rjsf .field select {
67+
display: block;
68+
}
69+
70+
.rjsf .array-item-list {
71+
}
72+
73+
.rjsf .array-item-add button,
74+
.rjsf .array-item-remove button {
75+
width: 32px;
76+
height: 32px;
77+
}
78+
79+
.rjsf .array-item-add {
80+
margin-bottom: 0;
81+
}
82+
83+
.rjsf .array-item-remove {
84+
margin: .2em 0;
85+
}
86+
87+
.rjsf .field-array-of-string input[type=text] {
88+
width: calc(100% - 38px);
89+
}
90+
91+
.rjsf .field-array-of-string .array-item-remove {
92+
float: right;
93+
width: 30px;
94+
margin-top: -2.3em;
95+
}

devServer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ app.get("/", function(req, res) {
1919
res.sendFile(path.join(__dirname, "index.html"));
2020
});
2121

22+
app.get("/react-jsonschema-form.css", function(req, res) {
23+
res.sendFile(path.join(__dirname, "css", "react-jsonschema-form.css"));
24+
});
25+
2226
app.listen(port, "localhost", function(err) {
2327
if (err) {
2428
console.log(err);
2529
return;
2630
}
2731

28-
console.log("Listening at localhost:" + port);
32+
console.log("Listening at http://localhost:" + port);
2933
});

dist/react-jsonschema-form-0.4.1.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/react-jsonschema-form.css

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.rjsf * {
2+
box-sizing: border-box;
3+
}
4+
5+
.rjsf {
6+
padding: 0;
7+
font-size: .8em;
8+
color: #555;
9+
}
10+
11+
.rjsf fieldset {
12+
border: 1px solid #aaa;
13+
border-radius: 4px;
14+
margin-top: .5em;
15+
}
16+
17+
.rjsf fieldset legend {
18+
font-weight: bold;
19+
margin-left: -.2em;
20+
}
21+
22+
.rjsf button {
23+
display: inline-block;
24+
color: #FFF;
25+
background-color: #286090;
26+
border-color: #122B40;
27+
padding: 2px 8px;
28+
font-size: 14px;
29+
font-weight: 400;
30+
line-height: 1.5em;
31+
white-space: nowrap;
32+
vertical-align: middle;
33+
cursor: pointer;
34+
border: 1px solid transparent;
35+
border-radius: 4px;
36+
}
37+
38+
.rjsf input[type=text] {
39+
display: block;
40+
width: 100%;
41+
height: 34px;
42+
padding: 3px 6px;
43+
font-size: 14px;
44+
color: #555;
45+
border: 1px solid #ccc;
46+
border-radius: 4px;
47+
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;
48+
}
49+
50+
.rjsf .errors {
51+
color: red;
52+
}
53+
54+
.rjsf .field {
55+
padding-top: 1em;
56+
}
57+
58+
.rjsf .field label {
59+
display: block;
60+
font-weight: bold;
61+
}
62+
63+
.rjsf .field input[type=text] {
64+
}
65+
66+
.rjsf .field select {
67+
display: block;
68+
}
69+
70+
.rjsf .array-item-list {
71+
}
72+
73+
.rjsf .array-item-add button,
74+
.rjsf .array-item-remove button {
75+
width: 32px;
76+
height: 32px;
77+
}
78+
79+
.rjsf .array-item-add {
80+
margin-bottom: 0;
81+
}
82+
83+
.rjsf .array-item-remove {
84+
margin: .2em 0;
85+
}
86+
87+
.rjsf .field-array-of-string input[type=text] {
88+
width: calc(100% - 38px);
89+
}
90+
91+
.rjsf .field-array-of-string .array-item-remove {
92+
float: right;
93+
width: 30px;
94+
margin-top: -2.3em;
95+
}

0 commit comments

Comments
 (0)