@@ -4,7 +4,12 @@ import './Preferences.scss'
4
4
import Icon from '../Icon/Icon'
5
5
import Button from '../Button/Button'
6
6
import Modal from '../Modal/Modal'
7
- import { MOUSE , TRACKPAD } from '../../redux/ephemeral/local-preferences/reducer'
7
+ import {
8
+ COORDINATES ,
9
+ MODAL ,
10
+ MOUSE ,
11
+ TRACKPAD ,
12
+ } from '../../redux/ephemeral/local-preferences/reducer'
8
13
import PreferenceSelect , {
9
14
PreferenceSelectExtra ,
10
15
PreferenceSelectOption ,
@@ -52,7 +57,7 @@ function Descriptions({ navigation }) {
52
57
)
53
58
}
54
59
55
- function Internal ( { navigation, setNavigationSelected, save } ) {
60
+ function NavigationModeInternal ( { navigation, setNavigationSelected } ) {
56
61
const options = (
57
62
< >
58
63
< PreferenceSelectOption
@@ -73,7 +78,6 @@ function Internal({ navigation, setNavigationSelected, save }) {
73
78
)
74
79
return (
75
80
< div className = "preferences-content-wrapper" >
76
- < div className = "preferences-title" > Preferences</ div >
77
81
< PreferenceSelect
78
82
iconName = "panning.svg"
79
83
title = "Navigation Mode"
@@ -82,41 +86,87 @@ function Internal({ navigation, setNavigationSelected, save }) {
82
86
options = { options }
83
87
descriptions = { < Descriptions navigation = { navigation } /> }
84
88
/>
85
- < div className = "preferences-save-button" >
86
- < Button onClick = { save } text = "Save Changes" />
87
- </ div >
89
+ </ div >
90
+ )
91
+ }
92
+
93
+ function KeyboardNavigationModeInternal ( {
94
+ keyboardNavigation,
95
+ setKeyboardNavigationSelected,
96
+ } ) {
97
+ const options = (
98
+ < >
99
+ < PreferenceSelectOption
100
+ active = { keyboardNavigation === MODAL }
101
+ onClick = { ( ) => setKeyboardNavigationSelected ( MODAL ) }
102
+ iconName = "trackpad.svg"
103
+ iconExtraClassName = "navigation-mode-option-icon-trackpad"
104
+ title = "Use a Modal"
105
+ />
106
+ < PreferenceSelectOption
107
+ active = { keyboardNavigation === COORDINATES }
108
+ onClick = { ( ) => setKeyboardNavigationSelected ( COORDINATES ) }
109
+ iconName = "mouse.svg"
110
+ iconExtraClassName = "navigation-mode-option-icon-mouse"
111
+ title = "Use Coordinates"
112
+ />
113
+ </ >
114
+ )
115
+ return (
116
+ < div className = "preferences-content-wrapper" >
117
+ < PreferenceSelect
118
+ iconName = "panning.svg"
119
+ title = "Keyboard Navigation Mode"
120
+ subtitle = "Select your preferred method of using the keyboard to navigate from parent to child, and vice-versa"
121
+ options = { options }
122
+ />
88
123
</ div >
89
124
)
90
125
}
91
126
92
127
export default function Preferences ( {
93
128
navigation,
129
+ keyboardNavigation,
94
130
setNavigationPreference,
131
+ setKeyboardNavigationPreference,
95
132
showPreferences,
96
133
setShowPreferences,
97
134
} ) {
98
135
// hold an internal version of the preferences state, so that we can toggle it, before saving it
99
136
const [ navigationSelected , setNavigationSelected ] = useState ( navigation )
137
+ const [ keyboardNavigationSelected , setKeyboardNavigationSelected ] = useState (
138
+ keyboardNavigation
139
+ )
100
140
101
141
const save = ( ) => {
102
142
setNavigationPreference ( navigationSelected )
143
+ setKeyboardNavigationPreference ( keyboardNavigationSelected )
103
144
setShowPreferences ( false )
104
145
}
105
146
const close = ( ) => {
106
147
// reset navigation selected to
107
148
// whatever the canonical state of navigation preference
108
149
// is equal to
109
150
setNavigationSelected ( navigation )
151
+ setKeyboardNavigationSelected ( keyboardNavigation )
110
152
setShowPreferences ( false )
111
153
}
112
154
113
155
return (
114
156
< Modal white active = { showPreferences } onClose = { close } >
115
- < Internal
157
+ < div className = "preferences-title" > Preferences</ div >
158
+ < NavigationModeInternal
116
159
navigation = { navigationSelected }
117
160
setNavigationSelected = { setNavigationSelected }
118
- save = { save }
119
161
/>
162
+ < KeyboardNavigationModeInternal
163
+ keyboardNavigation = { keyboardNavigationSelected }
164
+ setKeyboardNavigationSelected = { setKeyboardNavigationSelected }
165
+ />
166
+
167
+ < div className = "preferences-save-button" >
168
+ < Button onClick = { save } text = "Save Changes" />
169
+ </ div >
120
170
</ Modal >
121
171
)
122
172
}
0 commit comments