insane nice typechecking here
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
import { Box, Paper, Typography } from '@mui/material';
|
import { Box, Paper, Typography } from '@mui/material';
|
||||||
|
|
||||||
|
import { KeyboardShortcuts } from '../util/keyboard';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { blueGrey } from '@mui/material/colors';
|
import { blueGrey } from '@mui/material/colors';
|
||||||
|
|
||||||
export default function KeyboardShortcutLabel({ label }: { label: string }) {
|
export default function KeyboardShortcutLabel({
|
||||||
|
label,
|
||||||
|
}: {
|
||||||
|
label: keyof typeof KeyboardShortcuts;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
elevation={0}
|
elevation={0}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const Navbar = ({
|
|||||||
if (searchRef?.current) searchRef.current.focus();
|
if (searchRef?.current) searchRef.current.focus();
|
||||||
}, [searchRef]);
|
}, [searchRef]);
|
||||||
|
|
||||||
useKeyPressEvent(KeyboardShortcuts.search, onSearchFocus);
|
useKeyPressEvent(KeyboardShortcuts.search.shortcutKey, onSearchFocus);
|
||||||
|
|
||||||
const rendersCount = useRendersCount();
|
const rendersCount = useRendersCount();
|
||||||
console.warn('RENDER COUNT | NAVBAR | ', rendersCount);
|
console.warn('RENDER COUNT | NAVBAR | ', rendersCount);
|
||||||
@@ -87,7 +87,7 @@ const Navbar = ({
|
|||||||
|
|
||||||
{isSearching && <CircularProgress size={20} />}
|
{isSearching && <CircularProgress size={20} />}
|
||||||
|
|
||||||
<KeyboardShortcutLabel label={KeyboardShortcuts.search} />
|
<KeyboardShortcutLabel label={KeyboardShortcuts.search.label} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Tooltip title={'Group conversation'}>
|
<Tooltip title={'Group conversation'}>
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
export enum KeyboardShortcuts {
|
type Shortcut = { label: string; shortcutKey: string };
|
||||||
search = '/',
|
|
||||||
}
|
export const KeyboardShortcuts: Record<string, Shortcut> = {
|
||||||
|
search: {
|
||||||
|
label: '/',
|
||||||
|
shortcutKey: '/',
|
||||||
|
},
|
||||||
|
escape: {
|
||||||
|
shortcutKey: 'Escape',
|
||||||
|
label: 'esc',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user