Skip to content

Commit f54aab9

Browse files
author
Christopher Whatley
committed
Fix range widget
1 parent b2656bf commit f54aab9

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@material-ui/core": "^3.5.1",
4747
"@material-ui/icons": "^3.0.1",
48+
"@material-ui/lab": "^3.0.0-alpha.25",
4849
"ajv": "^5.2.3",
4950
"babel-runtime": "^6.26.0",
5051
"core-js": "^2.5.7",

src/ArrayFieldTemplate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function DefaultArrayItem(props) {
4444
fontWeight: "bold",
4545
};
4646
return (
47-
<Grid container spacing="12" key={props.index}>
47+
<Grid container spacing={16} key={props.index}>
4848
<Grid item xs={props.hasToolbar ? 9 : 12}>
4949
{props.children}
5050
</Grid>
@@ -154,15 +154,15 @@ function DefaultNormalArrayFieldTemplate(props) {
154154

155155
<Grid
156156
container
157-
spacing={12}
157+
spacing={16}
158158
className="array-item-list"
159159
key={`array-item-list-${props.idSchema.$id}`}>
160160
{props.items && props.items.map(p => DefaultArrayItem(p))}
161161

162162
{props.canAdd && (
163163
<React.Fragment>
164-
<Grid item xs="10" />
165-
<Grid item xs="2">
164+
<Grid item xs={10} />
165+
<Grid item xs={2}>
166166
<AddButton
167167
className="array-item-add"
168168
onClick={props.onAddClick}

src/FieldTemplate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function DefaultTemplate(props) {
3333
let map = {
3434
textarea: true,
3535
checkboxes: true,
36+
range: true,
3637
};
3738
console.log("mapped", map[l]);
3839
return !map[l];

src/MuiForm.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import mui_fields from "./fields";
99
import mui_widgets from "./widgets";
1010

1111
export default class MuiForm extends Form {
12-
constructor(props) {
13-
let newProps = { ...props };
14-
super(newProps);
15-
this.props.ErrorList = ErrorList;
16-
}
12+
static defaultProps = {
13+
ErrorList: ErrorList,
14+
...Form.defaultProps,
15+
};
1716

1817
getRegistry() {
1918
const { fields, widgets } = getDefaultRegistry();

src/widgets/RangeWidget.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import React from "react";
22
import PropTypes from "prop-types";
3+
import { Slider } from "@material-ui/lab";
4+
import { Grid, Typography } from "@material-ui/core";
35

46
import { rangeSpec } from "react-jsonschema-form/lib/utils";
57

68
function RangeWidget(props) {
7-
const {
8-
schema,
9-
value,
10-
registry: {
11-
widgets: { BaseInput },
12-
},
13-
} = props;
9+
const { schema, value } = props;
10+
1411
return (
15-
<div className="field-range-wrapper">
16-
<BaseInput type="range" {...props} {...rangeSpec(schema)} />
17-
<span className="range-view">{value}</span>
18-
</div>
12+
<Grid container style={{ paddingTop: "12px" }}>
13+
<Grid item xs={11}>
14+
<Slider value={value} {...props} {...rangeSpec(schema)} />
15+
</Grid>
16+
<Grid item xs={1}>
17+
<Typography>{value}</Typography>
18+
</Grid>
19+
</Grid>
1920
);
2021
}
2122

0 commit comments

Comments
 (0)