@@ -14,6 +14,7 @@ import Header from '../../components/mobile/Header';
14
14
import PreferencePicker from '../../components/mobile/PreferencePicker' ;
15
15
import { ExitIcon } from '../../common/icons' ;
16
16
import { remSize , prop } from '../../theme' ;
17
+ import { optionsOnOff , optionsPickOne , preferenceOnOff } from '../../common/helpers/PreferenceCreators' ;
17
18
18
19
const Content = styled . div `
19
20
z-index: 0;
@@ -29,23 +30,6 @@ const SectionSubeader = styled.h3`
29
30
color: ${ prop ( 'primaryTextColor' ) } ;
30
31
` ;
31
32
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
-
49
33
50
34
const MobilePreferences = ( props ) => {
51
35
const {
@@ -62,56 +46,19 @@ const MobilePreferences = (props) => {
62
46
options : optionsPickOne ( 'theme' , 'light' , 'dark' , 'contrast' ) ,
63
47
onSelect : x => setTheme ( x ) // setTheme
64
48
} ,
65
-
66
- {
67
- title : 'Autosave' ,
68
- value : autosave ,
69
- options : optionsOnOff ( 'autosave' ) ,
70
- onSelect : x => setAutosave ( x ) // setAutosave
71
- } ,
72
-
73
- {
74
- title : 'Word Wrap' ,
75
- value : linewrap ,
76
- options : optionsOnOff ( 'linewrap' ) ,
77
- onSelect : x => setLinewrap ( x )
78
- }
49
+ preferenceOnOff ( 'Autosave' , autosave , setAutosave , 'autosave' ) ,
50
+ preferenceOnOff ( 'Word Wrap' , linewrap , setLinewrap , 'linewrap' )
79
51
] ;
80
52
81
53
const outputSettings = [
82
- {
83
- title : 'Plain-text' ,
84
- value : textOutput ,
85
- options : optionsOnOff ( 'text output' ) ,
86
- onSelect : x => setTextOutput ( x )
87
- } ,
88
- {
89
- title : 'Table-text' ,
90
- value : gridOutput ,
91
- options : optionsOnOff ( 'table output' ) ,
92
- onSelect : x => setGridOutput ( x )
93
- } ,
94
- {
95
- title : 'Sound' ,
96
- value : soundOutput ,
97
- options : optionsOnOff ( 'sound output' ) ,
98
- onSelect : x => setSoundOutput ( x )
99
- } ,
54
+ preferenceOnOff ( 'Plain-text' , textOutput , setTextOutput , 'text output' ) ,
55
+ preferenceOnOff ( 'Table-text' , gridOutput , setGridOutput , 'table output' ) ,
56
+ preferenceOnOff ( 'Lint Warning Sound' , soundOutput , setSoundOutput , 'sound output' )
100
57
] ;
101
58
102
59
const accessibilitySettings = [
103
- {
104
- title : 'Line Numbers' ,
105
- value : lineNumbers ,
106
- options : optionsOnOff ( 'line numbers' ) ,
107
- onSelect : x => setLineNumbers ( x )
108
- } ,
109
- {
110
- title : 'Lint Warning Sound' ,
111
- value : lintWarning ,
112
- options : optionsOnOff ( 'lint warning' ) ,
113
- onSelect : x => setLintWarning ( x )
114
- } ,
60
+ preferenceOnOff ( 'Line Numbers' , lineNumbers , setLineNumbers ) ,
61
+ preferenceOnOff ( 'Lint Warning Sound' , lintWarning , setLintWarning )
115
62
] ;
116
63
117
64
return (
0 commit comments