insane nice typechecking here

This commit is contained in:
talksik
2022-05-30 13:32:48 -05:00
parent ac050deab9
commit 1a133c5a2a
3 changed files with 20 additions and 6 deletions
@@ -1,9 +1,14 @@
import { Box, Paper, Typography } from '@mui/material';
import { KeyboardShortcuts } from '../util/keyboard';
import React from 'react';
import { blueGrey } from '@mui/material/colors';
export default function KeyboardShortcutLabel({ label }: { label: string }) {
export default function KeyboardShortcutLabel({
label,
}: {
label: keyof typeof KeyboardShortcuts;
}) {
return (
<Paper
elevation={0}
+2 -2
View File
@@ -41,7 +41,7 @@ const Navbar = ({
if (searchRef?.current) searchRef.current.focus();
}, [searchRef]);
useKeyPressEvent(KeyboardShortcuts.search, onSearchFocus);
useKeyPressEvent(KeyboardShortcuts.search.shortcutKey, onSearchFocus);
const rendersCount = useRendersCount();
console.warn('RENDER COUNT | NAVBAR | ', rendersCount);
@@ -87,7 +87,7 @@ const Navbar = ({
{isSearching && <CircularProgress size={20} />}
<KeyboardShortcutLabel label={KeyboardShortcuts.search} />
<KeyboardShortcutLabel label={KeyboardShortcuts.search.label} />
</Stack>
<Tooltip title={'Group conversation'}>
+12 -3
View File
@@ -1,3 +1,12 @@
export enum KeyboardShortcuts {
search = '/',
}
type Shortcut = { label: string; shortcutKey: string };
export const KeyboardShortcuts: Record<string, Shortcut> = {
search: {
label: '/',
shortcutKey: '/',
},
escape: {
shortcutKey: 'Escape',
label: 'esc',
},
};