@@ -20,11 +20,6 @@ const Content = styled.div`
20
20
margin-top: ${ remSize ( 68 ) } ;
21
21
` ;
22
22
23
-
24
- const SettingsHeader = styled ( Header ) `
25
- background: transparent;
26
- ` ;
27
-
28
23
const SectionHeader = styled . h2 `
29
24
color: ${ prop ( 'primaryTextColor' ) } ;
30
25
padding-top: ${ remSize ( 32 ) } ;
@@ -34,6 +29,23 @@ const SectionSubeader = styled.h3`
34
29
color: ${ prop ( 'primaryTextColor' ) } ;
35
30
` ;
36
31
32
+ const optionsOnOff = ( name , onLabel = 'On' , offLabel = 'Off' ) => [
33
+ {
34
+ value : true , label : onLabel , ariaLabel : `${ name } on` , name : `${ name } ` , id : `${ name } -on` . replace ( ' ' , '-' )
35
+ } ,
36
+ {
37
+ value : false , label : offLabel , ariaLabel : `${ name } off` , name : `${ name } ` , id : `${ name } -off` . replace ( ' ' , '-' )
38
+ } ,
39
+ ] ;
40
+
41
+ const optionsPickOne = ( name , ...options ) => options . map ( option => ( {
42
+ value : option ,
43
+ label : option ,
44
+ ariaLabel : `${ option } ${ name } on` ,
45
+ name : `${ option } ${ name } ` ,
46
+ id : `${ option } -${ name } -on` . replace ( ' ' , '-' )
47
+ } ) ) ;
48
+
37
49
38
50
const MobilePreferences = ( props ) => {
39
51
const {
@@ -47,49 +59,21 @@ const MobilePreferences = (props) => {
47
59
{
48
60
title : 'Theme' ,
49
61
value : theme ,
50
- options : [
51
- {
52
- value : 'light' , label : 'light' , ariaLabel : 'light theme on' , name : 'light theme' , id : 'light-theme-on'
53
- } ,
54
- {
55
- value : 'dark' , label : 'dark' , ariaLabel : 'dark theme on' , name : 'dark theme' , id : 'dark-theme-on'
56
- } ,
57
- {
58
- value : 'contrast' ,
59
- label : 'contrast' ,
60
- ariaLabel : 'contrast theme on' ,
61
- name : 'contrast theme' ,
62
- id : 'contrast-theme-on'
63
- }
64
- ] ,
62
+ options : optionsPickOne ( 'theme' , 'light' , 'dark' , 'contrast' ) ,
65
63
onSelect : x => setTheme ( x ) // setTheme
66
64
} ,
67
65
68
66
{
69
67
title : 'Autosave' ,
70
68
value : autosave ,
71
- options : [
72
- {
73
- value : true , label : 'On' , ariaLabel : 'autosave on' , name : 'autosave' , id : 'autosave-on'
74
- } ,
75
- {
76
- value : false , label : 'Off' , ariaLabel : 'autosave off' , name : 'autosave' , id : 'autosave-off'
77
- } ,
78
- ] ,
69
+ options : optionsOnOff ( 'autosave' ) ,
79
70
onSelect : x => setAutosave ( x ) // setAutosave
80
71
} ,
81
72
82
73
{
83
74
title : 'Word Wrap' ,
84
75
value : linewrap ,
85
- options : [
86
- {
87
- value : true , label : 'On' , ariaLabel : 'linewrap on' , name : 'linewrap' , id : 'linewrap-on'
88
- } ,
89
- {
90
- value : false , label : 'Off' , ariaLabel : 'linewrap off' , name : 'linewrap' , id : 'linewrap-off'
91
- } ,
92
- ] ,
76
+ options : optionsOnOff ( 'linewrap' ) ,
93
77
onSelect : x => setLinewrap ( x )
94
78
}
95
79
] ;
@@ -98,40 +82,19 @@ const MobilePreferences = (props) => {
98
82
{
99
83
title : 'Plain-text' ,
100
84
value : textOutput ,
101
- options : [
102
- {
103
- value : true , label : 'On' , ariaLabel : 'text output on' , name : 'text output' , id : 'text-output-on'
104
- } ,
105
- {
106
- value : false , label : 'Off' , ariaLabel : 'text output off' , name : 'text output' , id : 'text-output-off'
107
- } ,
108
- ] ,
85
+ options : optionsOnOff ( 'text output' ) ,
109
86
onSelect : x => setTextOutput ( x )
110
87
} ,
111
88
{
112
89
title : 'Table-text' ,
113
90
value : gridOutput ,
114
- options : [
115
- {
116
- value : true , label : 'On' , ariaLabel : 'table output on' , name : 'table output' , id : 'table-output-on'
117
- } ,
118
- {
119
- value : false , label : 'Off' , ariaLabel : 'table output off' , name : 'table output' , id : 'table-output-off'
120
- } ,
121
- ] ,
91
+ options : optionsOnOff ( 'table output' ) ,
122
92
onSelect : x => setGridOutput ( x )
123
93
} ,
124
94
{
125
95
title : 'Sound' ,
126
96
value : soundOutput ,
127
- options : [
128
- {
129
- value : true , label : 'On' , ariaLabel : 'sound output on' , name : 'sound output' , id : 'sound-output-on'
130
- } ,
131
- {
132
- value : false , label : 'Off' , ariaLabel : 'sound output off' , name : 'sound output' , id : 'sound-output-off'
133
- } ,
134
- ] ,
97
+ options : optionsOnOff ( 'sound output' ) ,
135
98
onSelect : x => setSoundOutput ( x )
136
99
} ,
137
100
] ;
@@ -140,38 +103,23 @@ const MobilePreferences = (props) => {
140
103
{
141
104
title : 'Line Numbers' ,
142
105
value : lineNumbers ,
143
- options : [
144
- {
145
- value : true , label : 'On' , ariaLabel : 'line numbers on' , name : 'line numbers' , id : 'line-numbers-on'
146
- } ,
147
- {
148
- value : false , label : 'Off' , ariaLabel : 'line numbers off' , name : 'line numbers' , id : 'line-numbers-off'
149
- } ,
150
- ] ,
106
+ options : optionsOnOff ( 'line numbers' ) ,
151
107
onSelect : x => setLineNumbers ( x )
152
108
} ,
153
109
{
154
110
title : 'Lint Warning Sound' ,
155
111
value : lintWarning ,
156
- options : [
157
- {
158
- value : true , label : 'On' , ariaLabel : 'lint warning on' , name : 'lint warning' , id : 'lint-warning-on'
159
- } ,
160
- {
161
- value : false , label : 'Off' , ariaLabel : 'lint warning off' , name : 'lint warning' , id : 'lint-warning-off'
162
- } ,
163
- ] ,
112
+ options : optionsOnOff ( 'lint warning' ) ,
164
113
onSelect : x => setLintWarning ( x )
165
114
} ,
166
115
] ;
167
116
168
117
return (
169
118
< Screen fullscreen >
170
119
< section >
171
- < SettingsHeader transparent title = "Preferences" >
172
-
120
+ < Header transparent title = "Preferences" >
173
121
< IconButton to = "/mobile" icon = { ExitIcon } aria-label = "Return to ide view" />
174
- </ SettingsHeader >
122
+ </ Header >
175
123
< section className = "preferences" >
176
124
< Content >
177
125
< SectionHeader > General Settings</ SectionHeader >
0 commit comments