diff --git a/src/components/settings/SidebarSettings.tsx b/src/components/settings/SidebarSettings.tsx
index f46422c..e2139cc 100644
--- a/src/components/settings/SidebarSettings.tsx
+++ b/src/components/settings/SidebarSettings.tsx
@@ -1,79 +1,29 @@
-import { Button, TextInput } from '@primer/react'
+import { Box, Button, FormControl, TextInput } from '@primer/react'
import { SimpleToggleField } from 'components/SimpleToggleField'
import { useConfigs } from 'containers/ConfigsContext'
import * as React from 'react'
import { friendlyFormatShortcut, noop } from 'utils/general'
import { useStateIO } from 'utils/hooks/useStateIO'
import * as keyHelper from 'utils/keyHelper'
-import { Field } from './Field'
import { SettingsSection } from './SettingsSection'
export function SidebarSettings() {
const configContext = useConfigs()
- const useToggleShowSideBarShortcut = useStateIO(configContext.value.shortcut)
- const { value: toggleShowSideBarShortcut } = useToggleShowSideBarShortcut
- const focused = useStateIO(false)
-
- React.useEffect(() => {
- useToggleShowSideBarShortcut.onChange(configContext.value.shortcut)
- }, [configContext.value.shortcut]) // eslint-disable-line react-hooks/exhaustive-deps
+ const { sidebarToggleMode } = configContext.value
return (
-
+
- configContext.value.sidebarToggleMode === 'float' ? false : enabled === null,
+ value: enabled => (sidebarToggleMode === 'float' ? false : enabled === null),
onChange: checked => (checked ? null : true),
},
}}
@@ -81,3 +31,61 @@ export function SidebarSettings() {
)
}
+
+function ToggleSidebarShortcutSettings() {
+ const configContext = useConfigs()
+ const { shortcut } = configContext.value
+ const id = 'toggle-show-sidebar-shortcut'
+
+ React.useEffect(() => {
+ useToggleShowSideBarShortcut.onChange(shortcut)
+ }, [shortcut]) // eslint-disable-line react-hooks/exhaustive-deps
+
+ const useToggleShowSideBarShortcut = useStateIO(shortcut)
+ const { value: toggleShowSideBarShortcut } = useToggleShowSideBarShortcut
+ const focused = useStateIO(false)
+
+ return (
+
+ Keyboard shortcut to toggle visibility
+
+ focused.onChange(true)}
+ onBlur={() => focused.onChange(false)}
+ placeholder={focused.value ? 'Press key combination' : 'Click here to set'}
+ value={friendlyFormatShortcut(toggleShowSideBarShortcut)}
+ onChange={noop}
+ onKeyDown={React.useCallback((e: React.KeyboardEvent) => {
+ e.preventDefault()
+ e.stopPropagation()
+ // Clear shortcut with backspace
+ const shortcut = e.key === 'Backspace' ? '' : keyHelper.parseEvent(e)
+ useToggleShowSideBarShortcut.onChange(shortcut)
+ }, [])} // eslint-disable-line react-hooks/exhaustive-deps
+ />
+ {shortcut === toggleShowSideBarShortcut ? (
+
+ ) : (
+
+ )}
+
+
+ )
+}
diff --git a/src/styles/index.scss b/src/styles/index.scss
index 7d0c128..0145491 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -938,12 +938,6 @@ $minimal-z-index: max(
flex: 1;
}
}
- .toggle-shortcut-input-control {
- display: flex;
- .toggle-shortcut-input {
- flex: 1;
- }
- }
}
.gitako-footer {