1
1
import React from "react" ;
2
+ import PropTypes from "prop-types" ;
2
3
import { withStyles , createStyles } from "@material-ui/core/styles" ;
3
4
import Typography from "@material-ui/core/Typography" ;
4
5
import TextField from "@material-ui/core/TextField" ;
@@ -9,6 +10,8 @@ import Divider from "@material-ui/core/Divider";
9
10
import LoadIcon from "@material-ui/icons/Unarchive" ;
10
11
import SaveIcon from "@material-ui/icons/Save" ;
11
12
import SubmitButton from "./SubmitButton" ;
13
+ import styleOptions from "../utils/styleOptions" ;
14
+ import PrefPropType from "../utils/prefPropType" ;
12
15
13
16
class PreferenceForm extends React . Component {
14
17
handleCIDChange = evt => {
@@ -46,23 +49,9 @@ class PreferenceForm extends React.Component {
46
49
< Divider className = { classes . divider } />
47
50
< form onSubmit = { this . props . onSave } >
48
51
< TextField
49
- label = "one"
50
- value = { preferences . one }
51
- onChange = { this . handlePrefChange ( "one" ) }
52
- fullWidth
53
- className = { classes . input }
54
- />
55
- < TextField
56
- label = "two"
57
- value = { preferences . two }
58
- onChange = { this . handlePrefChange ( "two" ) }
59
- fullWidth
60
- className = { classes . input }
61
- />
62
- < TextField
63
- label = "three"
64
- value = { preferences . three }
65
- onChange = { this . handlePrefChange ( "three" ) }
52
+ label = "username"
53
+ value = { preferences . username }
54
+ onChange = { this . handlePrefChange ( "username" ) }
66
55
fullWidth
67
56
className = { classes . input }
68
57
/>
@@ -91,22 +80,17 @@ class PreferenceForm extends React.Component {
91
80
}
92
81
}
93
82
94
- const styleOptions = [
95
- "arduinoLight" ,
96
- "codepenEmbed" ,
97
- "darcula" ,
98
- "docco" ,
99
- "github" ,
100
- "googlecode" ,
101
- "hybrid" ,
102
- "monokaiSublime" ,
103
- "nord" ,
104
- "ocean" ,
105
- "pojoaque" ,
106
- "tomorrow" ,
107
- "tomorrowNight" ,
108
- "vs"
109
- ] ;
83
+ PreferenceForm . propTypes = {
84
+ cid : PropTypes . string . isRequired ,
85
+ preferences : PrefPropType . isRequired ,
86
+ justSaved : PropTypes . bool . isRequired ,
87
+ justLoaded : PropTypes . bool . isRequired ,
88
+ onCIDChange : PropTypes . func . isRequired ,
89
+ onPrefChange : PropTypes . func . isRequired ,
90
+ onLoad : PropTypes . func . isRequired ,
91
+ onSave : PropTypes . func . isRequired ,
92
+ classes : PropTypes . objectOf ( PropTypes . string )
93
+ } ;
110
94
111
95
const styles = theme =>
112
96
createStyles ( {
0 commit comments