Skip to content

Commit

Permalink
Add shortcuts for viewing posts and writing sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
0xi4o committed Aug 16, 2024
1 parent 2a39d2c commit 617e452
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 24 deletions.
83 changes: 59 additions & 24 deletions app/components/editor/main-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const MainMenu = ({
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem
className='flex items-center justify-between'
onClick={() =>
triggerShortcut(
EditorShortcuts.NEW_POST
Expand All @@ -82,26 +83,44 @@ const MainMenu = ({
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<CirclePlusIcon className='mr-2 w-4 h-4' />
<span>New Post</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts.NEW_POST
].key,
allShortcuts[
EditorShortcuts.NEW_POST
].modifiers
)}
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
<Link
className='flex items-center justify-between'
prefetch='intent'
to={ROUTES.VIEW.POSTS}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Posts</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts.NEW_POST
EditorShortcuts
.VIEW_ALL_POSTS
].key,
allShortcuts[
EditorShortcuts.NEW_POST
EditorShortcuts
.VIEW_ALL_POSTS
].modifiers
)}
/>
</DropdownMenuShortcut>
</span>
</DropdownMenuItem>
<DropdownMenuItem>
<Link prefetch='intent' to='/posts'>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Posts</span>
</span>
</Link>
</DropdownMenuItem>
</DropdownMenuSubContent>
Expand All @@ -117,6 +136,7 @@ const MainMenu = ({
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem
className='flex items-center justify-between'
onClick={() =>
triggerShortcut(
EditorShortcuts.WRITING_SESSION
Expand All @@ -126,21 +146,21 @@ const MainMenu = ({
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<TimerIcon className='mr-2 w-4 h-4' />
<span>New Writing Session</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.WRITING_SESSION
].key,
allShortcuts[
EditorShortcuts
.WRITING_SESSION
].modifiers
)}
/>
</DropdownMenuShortcut>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.WRITING_SESSION
].key,
allShortcuts[
EditorShortcuts
.WRITING_SESSION
].modifiers
)}
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
{/*<DropdownMenuItem>*/}
{/* <span className='w-full h-full flex items-center justify-start cursor-pointer'>*/}
Expand All @@ -150,13 +170,28 @@ const MainMenu = ({
{/*</DropdownMenuItem>*/}
<DropdownMenuItem>
<Link
className='flex items-center justify-between'
prefetch='intent'
to={ROUTES.VIEW.WRITING_SESSIONS}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Sessions</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].modifiers
)}
/>
</DropdownMenuShortcut>
</Link>
</DropdownMenuItem>
</DropdownMenuSubContent>
Expand Down
10 changes: 10 additions & 0 deletions app/lib/hooks/useKeyboardShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ const allShortcuts: AllShortcuts = {
key: 's',
modifiers: {},
},
[EditorShortcuts.VIEW_ALL_POSTS]: {
description: 'View All Posts',
key: 'p',
modifiers: { alt: true },
},
[EditorShortcuts.VIEW_ALL_WRITING_SESSIONS]: {
description: 'View All Writing Sessions',
key: 'w',
modifiers: { alt: true },
},
[EditorShortcuts.WRITING_SESSION]: {
description: 'New Writing Session',
key: 't',
Expand Down
2 changes: 2 additions & 0 deletions app/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export enum EditorShortcuts {
PREFERENCES = 'preferences',
RESET_EDITOR = 'resetEditor',
SPLASH_DIALOG = 'splashDialog',
VIEW_ALL_POSTS = 'viewAllPosts',
VIEW_ALL_WRITING_SESSIONS = 'viewAllWritingSessions',
WRITING_SESSION = 'writingSession',
}

Expand Down

0 comments on commit 617e452

Please sign in to comment.