-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathsettings-tab.tsx
More file actions
200 lines (190 loc) · 6.06 KB
/
settings-tab.tsx
File metadata and controls
200 lines (190 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import { Show } from 'solid-js'
import {
Checkbox,
Input,
MainPanel,
Section,
SectionDescription,
SectionIcon,
SectionTitle,
Select,
} from '@tanstack/devtools-ui'
import {
GeoTag,
Keyboard,
Link,
SettingsCog,
} from '@tanstack/devtools-ui/icons'
import { useDevtoolsSettings } from '../context/use-devtools-context'
import { useStyles } from '../styles/use-styles'
import { HotkeyConfig } from './hotkey-config'
import type { Modifier } from '@tanstack/solid-hotkeys'
export const SettingsTab = () => {
const { setSettings, settings } = useDevtoolsSettings()
const styles = useStyles()
const modifiers: Array<Modifier> = ['Mod', 'Alt', 'Shift']
return (
<MainPanel withPadding>
<Section>
<SectionTitle>
<SectionIcon>
<SettingsCog />
</SectionIcon>
General
</SectionTitle>
<SectionDescription>
Configure general behavior of the devtools panel.
</SectionDescription>
<div class={styles().settingsGroup}>
<Checkbox
label="Default open"
description="Automatically open the devtools panel when the page loads"
onChange={() =>
setSettings({ defaultOpen: !settings().defaultOpen })
}
checked={settings().defaultOpen}
/>
<Checkbox
label="Hide trigger until hovered"
description="Keep the devtools trigger button hidden until you hover over its area"
onChange={() =>
setSettings({ hideUntilHover: !settings().hideUntilHover })
}
checked={settings().hideUntilHover}
/>
<Checkbox
label="Completely hide trigger"
description="Completely removes the trigger from the DOM (you can still open it with the hotkey)"
onChange={() =>
setSettings({ triggerHidden: !settings().triggerHidden })
}
checked={settings().triggerHidden}
/>
<Select
label="Theme"
description="Choose the theme for the devtools panel"
value={settings().theme}
options={[
{ label: 'Dark', value: 'dark' },
{ label: 'Light', value: 'light' },
]}
onChange={(value) => setSettings({ theme: value })}
/>
</div>
</Section>
{/* URL Flag Settings */}
<Section>
<SectionTitle>
<SectionIcon>
<Link />
</SectionIcon>
URL Configuration
</SectionTitle>
<SectionDescription>
Control when devtools are available based on URL parameters.
</SectionDescription>
<div class={styles().settingsGroup}>
<Checkbox
label="Require URL Flag"
description="Only show devtools when a specific URL parameter is present"
checked={settings().requireUrlFlag}
onChange={(checked) =>
setSettings({
requireUrlFlag: checked,
})
}
/>
<Show when={settings().requireUrlFlag}>
<div class={styles().conditionalSetting}>
<Input
label="URL flag"
description="Enter the URL parameter name (e.g., 'debug' for ?debug=true)"
placeholder="debug"
value={settings().urlFlag}
onChange={(e) =>
setSettings({
urlFlag: e,
})
}
/>
</div>
</Show>
</div>
</Section>
{/* Keyboard Settings */}
<Section>
<SectionTitle>
<SectionIcon>
<Keyboard />
</SectionIcon>
Keyboard
</SectionTitle>
<SectionDescription>
Customize keyboard shortcuts for quick access.
</SectionDescription>
<div class={styles().settingsStack}>
<HotkeyConfig
title="Open/Close Devtools"
description="Hotkey to open/close devtools"
hotkey={settings().openHotkey}
modifiers={modifiers}
onHotkeyChange={(hotkey) => setSettings({ openHotkey: hotkey })}
/>
<HotkeyConfig
title="Source Inspector"
description="Hotkey to open source inspector"
hotkey={settings().inspectHotkey}
modifiers={modifiers}
onHotkeyChange={(hotkey) => setSettings({ inspectHotkey: hotkey })}
/>
</div>
</Section>
{/* Position Settings */}
<Section>
<SectionTitle>
<SectionIcon>
<GeoTag />
</SectionIcon>
Position
</SectionTitle>
<SectionDescription>
Adjust the position of the trigger button and devtools panel.
</SectionDescription>
<div class={styles().settingsGroup}>
<div class={styles().settingRow}>
<Select
label="Trigger Position"
options={[
{ label: 'Bottom Right', value: 'bottom-right' },
{ label: 'Bottom Left', value: 'bottom-left' },
{ label: 'Top Right', value: 'top-right' },
{ label: 'Top Left', value: 'top-left' },
{ label: 'Middle Right', value: 'middle-right' },
{ label: 'Middle Left', value: 'middle-left' },
]}
value={settings().position}
onChange={(value) =>
setSettings({
position: value,
})
}
/>
<Select
label="Panel Position"
value={settings().panelLocation}
options={[
{ label: 'Top', value: 'top' },
{ label: 'Bottom', value: 'bottom' },
]}
onChange={(value) =>
setSettings({
panelLocation: value,
})
}
/>
</div>
</div>
</Section>
</MainPanel>
)
}