Skip to content

Commit

Permalink
Update data-table and main-menu - use trigger global shortcut from co…
Browse files Browse the repository at this point in the history
…ntext
  • Loading branch information
0xi4o committed Aug 14, 2024
1 parent 59d976f commit 0d40951
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 12 additions & 2 deletions app/components/common/data-table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useContext, useState } from 'react'

import {
ColumnDef,
Expand All @@ -21,6 +21,7 @@ import {
TableRow,
} from '~/components/ui/table'
import { allShortcuts } from '~/lib/hooks/useKeyboardShortcuts'
import { AureliusContext, AureliusProviderData } from '~/lib/providers/aurelius'
import { useTheme } from '~/lib/providers/theme'
import { EditorShortcuts } from '~/lib/types'
import { getShortcutWithModifiers } from '~/lib/utils'
Expand All @@ -39,6 +40,9 @@ export function DataTable<TData, TValue>({
data,
effort,
}: DataTableProps<TData, TValue>) {
const { triggerGlobalShortcut } =
useContext<AureliusProviderData>(AureliusContext)

const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([])
const [sorting, setSorting] = useState<SortingState>([])

Expand Down Expand Up @@ -75,7 +79,13 @@ export function DataTable<TData, TValue>({
/>
<div />
<div className='flex items-center justify-end'>
<Button className='gap-2' size='sm'>
<Button
className='gap-2'
onClick={() =>
triggerGlobalShortcut(EditorShortcuts.NEW_POST)
}
size='sm'
>
New Post
<KeyboardShortcut
keys={getShortcutWithModifiers(
Expand Down
4 changes: 1 addition & 3 deletions app/components/editor/main-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Dispatch, SetStateAction } from 'react'

import { Link } from '@remix-run/react'

import {
Expand Down Expand Up @@ -43,7 +41,7 @@ import { getShortcutWithModifiers } from '~/lib/utils'
type MainMenuProps = {
focusMode?: boolean
mainMenuOpen: boolean
setMainMenuOpen: Dispatch<SetStateAction<boolean>>
setMainMenuOpen: (open: boolean) => void
triggerShortcut: (shortcutName: string) => void
}

Expand Down

0 comments on commit 0d40951

Please sign in to comment.