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 { 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}
+2 -2
View File
@@ -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'}>
+12 -3
View File
@@ -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',
},
};