@@ -14,7 +14,7 @@ import {
1414} from "../../../controllers/sound-controller" ;
1515import { useLocalStorage } from "../../../hooks/useLocalStorage" ;
1616import { useSavedIndicator } from "../../../hooks/useSavedIndicator" ;
17- import { isAuthenticated } from "../../../states/core" ;
17+ import { getActivePage , isAuthenticated } from "../../../states/core" ;
1818import { showModal } from "../../../states/modals" ;
1919import { showSimpleModal } from "../../../states/simple-modal" ;
2020// import { hotkeys } from "../../../states/hotkeys";
@@ -60,197 +60,200 @@ export function Settings(): JSXElement {
6060 ( ) => fileStorage . track ( "LocalBackgroundFile" ) ,
6161 async ( ) => fileStorage . hasFile ( "LocalBackgroundFile" ) ,
6262 ) ;
63+ const isOpen = ( ) : boolean => getActivePage ( ) === "settings" ;
6364
6465 return (
65- < div class = "grid gap-8" >
66- < QuickNav />
67- < Show when = { getConfig . showKeyTips } >
68- < div class = "text-center text-sub" >
69- tip: You can also change all these settings quickly using the command
70- line
71- < br /> ( < CommandlineHotkey /> )
66+ < Show when = { isOpen ( ) } >
67+ < div class = "grid gap-8" >
68+ < QuickNav />
69+ < Show when = { getConfig . showKeyTips } >
70+ < div class = "text-center text-sub" >
71+ tip: You can also change all these settings quickly using the
72+ command line
73+ < br /> ( < CommandlineHotkey /> )
74+ </ div >
75+ </ Show >
76+ < AccountSettingsNotice />
77+ < div >
78+ < Section title = "behavior" >
79+ < Show when = { isAuthenticated ( ) } >
80+ < Tags />
81+ < Presets />
82+ < AutoSetting key = "resultSaving" />
83+ </ Show >
84+ < AutoSetting key = "difficulty" />
85+ < AutoSetting key = "quickRestart" />
86+ < AutoSetting key = "repeatQuotes" />
87+ < AutoSetting key = "blindMode" />
88+ < AutoSetting key = "alwaysShowWordsHistory" />
89+ < AutoSetting key = "singleListCommandLine" />
90+ < MinSpeed />
91+ < MinAcc />
92+ < MinBurst />
93+ < AutoSetting key = "britishEnglish" />
94+ < Language />
95+ < Funbox />
96+ < CustomLayoutfluid />
97+ < CustomPolyglot />
98+ </ Section >
99+ < Section title = "input" >
100+ < AutoSetting key = "freedomMode" />
101+ < AutoSetting key = "strictSpace" />
102+ < AutoSetting key = "oppositeShiftMode" />
103+ < AutoSetting key = "stopOnError" />
104+ < AutoSetting key = "confidenceMode" />
105+ < AutoSetting key = "quickEnd" />
106+ < AutoSetting key = "indicateTypos" />
107+ < AutoSetting key = "hideExtraLetters" />
108+ < AutoSetting key = "compositionDisplay" />
109+ < AutoSetting key = "lazyMode" />
110+ < Layout />
111+ < AutoSetting key = "codeUnindentOnBackspace" />
112+ </ Section >
113+ < Section title = "sound" >
114+ < SoundVolume />
115+ < AutoSetting
116+ key = "playSoundOnClick"
117+ wide
118+ onOptionClick = { ( option ) => {
119+ if ( option === "off" ) return ;
120+ void previewClick ( option ) ;
121+ } }
122+ />
123+ < AutoSetting
124+ key = "playSoundOnError"
125+ wide
126+ onOptionClick = { ( option ) => {
127+ if ( option === "off" ) return ;
128+ void previewError ( option ) ;
129+ } }
130+ />
131+ < AutoSetting
132+ key = "playTimeWarning"
133+ wide
134+ onOptionClick = { ( option ) => {
135+ if ( option === "off" ) return ;
136+ void playTimeWarning ( ) ;
137+ } }
138+ />
139+ </ Section >
140+ < Section title = "caret" >
141+ < AutoSetting key = "smoothCaret" />
142+ < AutoSetting key = "caretStyle" wide />
143+ < PaceCaret />
144+ < AutoSetting key = "repeatedPace" />
145+ < AutoSetting key = "paceCaretStyle" wide />
146+ </ Section >
147+ < Section title = "appearance" >
148+ < AutoSetting key = "timerStyle" wide />
149+ < AutoSetting key = "liveSpeedStyle" />
150+ < AutoSetting key = "liveAccStyle" />
151+ < AutoSetting key = "liveBurstStyle" />
152+ < AutoSetting key = "timerColor" />
153+ < AutoSetting key = "timerOpacity" />
154+ < AutoSetting key = "highlightMode" wide />
155+ < AutoSetting key = "typedEffect" />
156+ < AutoSetting key = "tapeMode" />
157+ < AutoSetting key = "tapeMargin" />
158+ < AutoSetting key = "smoothLineScroll" />
159+ < AutoSetting key = "showAllLines" />
160+ < AutoSetting key = "alwaysShowDecimalPlaces" />
161+ < AutoSetting key = "typingSpeedUnit" />
162+ < AutoSetting key = "startGraphsAtZero" />
163+ < MaxLineWidth />
164+ < AutoSetting key = "fontSize" />
165+ < FontFamily />
166+ < AutoSetting key = "keymapMode" />
167+ < Show when = { getConfig . keymapMode !== "off" } >
168+ < KeymapLayout />
169+ < AutoSetting key = "keymapStyle" wide />
170+ < AutoSetting key = "keymapLegendStyle" wide />
171+ < AutoSetting key = "keymapShowTopRow" wide />
172+ < KeymapSize />
173+ </ Show >
174+ </ Section >
175+ < Section title = "theme" >
176+ < AutoSetting key = "flipTestColors" />
177+ < AutoSetting key = "colorfulMode" />
178+ < CustomBackground />
179+ < Show when = { getConfig . customBackground !== "" || hasLocalBg ( ) } >
180+ < CustomBackgroundFilters />
181+ </ Show >
182+ < AutoSwitchTheme />
183+ < AutoSetting key = "randomTheme" wide />
184+ < Theme />
185+ </ Section >
186+ < Section title = "hide elements" >
187+ < AutoSetting key = "showKeyTips" />
188+ < AutoSetting key = "showOutOfFocusWarning" />
189+ < AutoSetting key = "capsLockWarning" />
190+ < AutoSetting key = "showAverage" />
191+ </ Section >
192+ < Section title = "danger zone" >
193+ < ImportExport />
194+ < AutoSetting key = "ads" />
195+ < Setting
196+ key = "cookies"
197+ title = "update cookie preferences"
198+ description = "If you changed your mind about which cookies you consent to, you can change your preferences here."
199+ fa = { {
200+ icon : "fa-cookie-bite" ,
201+ } }
202+ inputs = {
203+ < Button
204+ class = "w-full"
205+ onClick = { ( ) => {
206+ showModal ( "Cookies" ) ;
207+ } }
208+ >
209+ open
210+ </ Button >
211+ }
212+ />
213+ < AnimationFpsLimit />
214+ < Setting
215+ key = "resetSettings"
216+ title = "reset settings"
217+ description = {
218+ < div >
219+ Resets settings to the default (but doesn't touch your
220+ tags and presets).
221+ < br />
222+ < div class = "text-error" > You can't undo this!</ div >
223+ </ div >
224+ }
225+ fa = { {
226+ icon : "fa-undo" ,
227+ } }
228+ inputs = {
229+ < Button
230+ class = "w-full"
231+ danger
232+ onClick = { ( ) => {
233+ showSimpleModal ( {
234+ title : "Are you sure?" ,
235+ buttonText : "reset" ,
236+ execFn : async ( ) => {
237+ await resetConfig ( ) ;
238+ await fileStorage . deleteFile ( "LocalBackgroundFile" ) ;
239+ return {
240+ status : "success" ,
241+ message : "Settings reset" ,
242+ } ;
243+ } ,
244+ } ) ;
245+ } }
246+ >
247+ reset settings
248+ </ Button >
249+ }
250+ />
251+ </ Section >
72252 </ div >
73- </ Show >
74- < AccountSettingsNotice />
75- < div >
76- < Section title = "behavior" >
77- < Show when = { isAuthenticated ( ) } >
78- < Tags />
79- < Presets />
80- < AutoSetting key = "resultSaving" />
81- </ Show >
82- < AutoSetting key = "difficulty" />
83- < AutoSetting key = "quickRestart" />
84- < AutoSetting key = "repeatQuotes" />
85- < AutoSetting key = "blindMode" />
86- < AutoSetting key = "alwaysShowWordsHistory" />
87- < AutoSetting key = "singleListCommandLine" />
88- < MinSpeed />
89- < MinAcc />
90- < MinBurst />
91- < AutoSetting key = "britishEnglish" />
92- < Language />
93- < Funbox />
94- < CustomLayoutfluid />
95- < CustomPolyglot />
96- </ Section >
97- < Section title = "input" >
98- < AutoSetting key = "freedomMode" />
99- < AutoSetting key = "strictSpace" />
100- < AutoSetting key = "oppositeShiftMode" />
101- < AutoSetting key = "stopOnError" />
102- < AutoSetting key = "confidenceMode" />
103- < AutoSetting key = "quickEnd" />
104- < AutoSetting key = "indicateTypos" />
105- < AutoSetting key = "hideExtraLetters" />
106- < AutoSetting key = "compositionDisplay" />
107- < AutoSetting key = "lazyMode" />
108- < Layout />
109- < AutoSetting key = "codeUnindentOnBackspace" />
110- </ Section >
111- < Section title = "sound" >
112- < SoundVolume />
113- < AutoSetting
114- key = "playSoundOnClick"
115- wide
116- onOptionClick = { ( option ) => {
117- if ( option === "off" ) return ;
118- void previewClick ( option ) ;
119- } }
120- />
121- < AutoSetting
122- key = "playSoundOnError"
123- wide
124- onOptionClick = { ( option ) => {
125- if ( option === "off" ) return ;
126- void previewError ( option ) ;
127- } }
128- />
129- < AutoSetting
130- key = "playTimeWarning"
131- wide
132- onOptionClick = { ( option ) => {
133- if ( option === "off" ) return ;
134- void playTimeWarning ( ) ;
135- } }
136- />
137- </ Section >
138- < Section title = "caret" >
139- < AutoSetting key = "smoothCaret" />
140- < AutoSetting key = "caretStyle" wide />
141- < PaceCaret />
142- < AutoSetting key = "repeatedPace" />
143- < AutoSetting key = "paceCaretStyle" wide />
144- </ Section >
145- < Section title = "appearance" >
146- < AutoSetting key = "timerStyle" wide />
147- < AutoSetting key = "liveSpeedStyle" />
148- < AutoSetting key = "liveAccStyle" />
149- < AutoSetting key = "liveBurstStyle" />
150- < AutoSetting key = "timerColor" />
151- < AutoSetting key = "timerOpacity" />
152- < AutoSetting key = "highlightMode" wide />
153- < AutoSetting key = "typedEffect" />
154- < AutoSetting key = "tapeMode" />
155- < AutoSetting key = "tapeMargin" />
156- < AutoSetting key = "smoothLineScroll" />
157- < AutoSetting key = "showAllLines" />
158- < AutoSetting key = "alwaysShowDecimalPlaces" />
159- < AutoSetting key = "typingSpeedUnit" />
160- < AutoSetting key = "startGraphsAtZero" />
161- < MaxLineWidth />
162- < AutoSetting key = "fontSize" />
163- < FontFamily />
164- < AutoSetting key = "keymapMode" />
165- < Show when = { getConfig . keymapMode !== "off" } >
166- < KeymapLayout />
167- < AutoSetting key = "keymapStyle" wide />
168- < AutoSetting key = "keymapLegendStyle" wide />
169- < AutoSetting key = "keymapShowTopRow" wide />
170- < KeymapSize />
171- </ Show >
172- </ Section >
173- < Section title = "theme" >
174- < AutoSetting key = "flipTestColors" />
175- < AutoSetting key = "colorfulMode" />
176- < CustomBackground />
177- < Show when = { getConfig . customBackground !== "" || hasLocalBg ( ) } >
178- < CustomBackgroundFilters />
179- </ Show >
180- < AutoSwitchTheme />
181- < AutoSetting key = "randomTheme" wide />
182- < Theme />
183- </ Section >
184- < Section title = "hide elements" >
185- < AutoSetting key = "showKeyTips" />
186- < AutoSetting key = "showOutOfFocusWarning" />
187- < AutoSetting key = "capsLockWarning" />
188- < AutoSetting key = "showAverage" />
189- </ Section >
190- < Section title = "danger zone" >
191- < ImportExport />
192- < AutoSetting key = "ads" />
193- < Setting
194- key = "cookies"
195- title = "update cookie preferences"
196- description = "If you changed your mind about which cookies you consent to, you can change your preferences here."
197- fa = { {
198- icon : "fa-cookie-bite" ,
199- } }
200- inputs = {
201- < Button
202- class = "w-full"
203- onClick = { ( ) => {
204- showModal ( "Cookies" ) ;
205- } }
206- >
207- open
208- </ Button >
209- }
210- />
211- < AnimationFpsLimit />
212- < Setting
213- key = "resetSettings"
214- title = "reset settings"
215- description = {
216- < div >
217- Resets settings to the default (but doesn't touch your tags
218- and presets).
219- < br />
220- < div class = "text-error" > You can't undo this!</ div >
221- </ div >
222- }
223- fa = { {
224- icon : "fa-undo" ,
225- } }
226- inputs = {
227- < Button
228- class = "w-full"
229- danger
230- onClick = { ( ) => {
231- showSimpleModal ( {
232- title : "Are you sure?" ,
233- buttonText : "reset" ,
234- execFn : async ( ) => {
235- await resetConfig ( ) ;
236- await fileStorage . deleteFile ( "LocalBackgroundFile" ) ;
237- return {
238- status : "success" ,
239- message : "Settings reset" ,
240- } ;
241- } ,
242- } ) ;
243- } }
244- >
245- reset settings
246- </ Button >
247- }
248- />
249- </ Section >
250- </ div >
251253
252- < AccountSettingsNotice />
253- </ div >
254+ < AccountSettingsNotice />
255+ </ div >
256+ </ Show >
254257 ) ;
255258}
256259
0 commit comments