Skip to content

Commit

Permalink
feat: shortcut h to show shortcuts modal (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban authored Sep 12, 2024
1 parent a2457a7 commit e9dc7b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/renderer/src/constants/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const shortcuts = {
name: "Show/Hide Feed Sidebar",
key: "Meta+B",
},
showShortcuts: {
name: "Show Shortcuts",
key: "H",
},
},
entries: {
refetch: {
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/src/pages/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CornerPlayer } from "@renderer/modules/feed-column/corner-player"
import { CmdF } from "@renderer/modules/panel/cmdf"
import { SearchCmdK } from "@renderer/modules/panel/cmdk"
import { CmdNTrigger } from "@renderer/modules/panel/cmdn"
import { useSettingModal } from "@renderer/modules/settings/modal/hooks"
import { throttle } from "lodash-es"
import type { PropsWithChildren } from "react"
import React, { useEffect, useRef, useState } from "react"
Expand Down Expand Up @@ -168,6 +169,16 @@ const FeedResponsiveResizerContainer = ({
scopes: HotKeyScopeMap.Home,
},
)
const settingModalPresent = useSettingModal()
useHotkeys(
shortcuts.layout.showShortcuts.key,
() => {
settingModalPresent("shortcuts")
},
{
scopes: HotKeyScopeMap.Home,
},
)

const [delayShowSplitter, setDelayShowSplitter] = useState(feedColumnShow)

Expand Down
5 changes: 4 additions & 1 deletion src/renderer/src/pages/settings/(settings)/shortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KbdCombined } from "@renderer/components/ui/kbd/Kbd"
import { Kbd, KbdCombined } from "@renderer/components/ui/kbd/Kbd"
import { shortcuts } from "@renderer/constants/shortcuts"
import { cn } from "@renderer/lib/utils"
import { SettingsTitle } from "@renderer/modules/settings/title"
Expand All @@ -17,6 +17,9 @@ export function Component() {
return (
<>
<SettingsTitle />
<p className="text-sm">
Press <Kbd>H</Kbd> to show this Shortcuts modal.
</p>
<div className="mt-4 space-y-6">
{Object.keys(shortcuts).map((type) => (
<section key={type}>
Expand Down

0 comments on commit e9dc7b2

Please sign in to comment.