mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
✨ Add a simple keybind viewer in about menu #751
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
|
Accordion,
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Anchor,
|
Anchor,
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
createStyles,
|
createStyles,
|
||||||
Divider,
|
|
||||||
Grid,
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
HoverCard,
|
HoverCard,
|
||||||
|
Kbd,
|
||||||
Modal,
|
Modal,
|
||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
@@ -35,6 +36,7 @@ import { useConfigContext } from '../../../../config/provider';
|
|||||||
import { useConfigStore } from '../../../../config/store';
|
import { useConfigStore } from '../../../../config/store';
|
||||||
import { useEditModeInformationStore } from '../../../../hooks/useEditModeInformation';
|
import { useEditModeInformationStore } from '../../../../hooks/useEditModeInformation';
|
||||||
import { usePackageAttributesStore } from '../../../../tools/client/zustands/usePackageAttributesStore';
|
import { usePackageAttributesStore } from '../../../../tools/client/zustands/usePackageAttributesStore';
|
||||||
|
import Tip from '../../../layout/Tip';
|
||||||
import { usePrimaryGradient } from '../../../layout/useGradient';
|
import { usePrimaryGradient } from '../../../layout/useGradient';
|
||||||
import Credits from '../../../Settings/Common/Credits';
|
import Credits from '../../../Settings/Common/Credits';
|
||||||
|
|
||||||
@@ -50,6 +52,21 @@ export const AboutModal = ({ opened, closeModal, newVersionAvailable }: AboutMod
|
|||||||
const informations = useInformationTableItems(newVersionAvailable);
|
const informations = useInformationTableItems(newVersionAvailable);
|
||||||
const { t } = useTranslation(['common', 'layout/modals/about']);
|
const { t } = useTranslation(['common', 'layout/modals/about']);
|
||||||
|
|
||||||
|
const keybinds = [
|
||||||
|
{ key: 'Mod + J', shortcut: 'Toggle light/dark mode' },
|
||||||
|
{ key: 'Mod + K', shortcut: 'Focus on search bar' },
|
||||||
|
{ key: 'Mod + B', shortcut: 'Open docker widget' },
|
||||||
|
{ key: 'Mod + E', shortcut: 'Toggle Edit mode' },
|
||||||
|
];
|
||||||
|
const rows = keybinds.map((element) => (
|
||||||
|
<tr key={element.key}>
|
||||||
|
<td>
|
||||||
|
<Kbd>{element.key}</Kbd>
|
||||||
|
</td>
|
||||||
|
<td>{element.shortcut}</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
onClose={() => closeModal()}
|
onClose={() => closeModal()}
|
||||||
@@ -76,7 +93,7 @@ export const AboutModal = ({ opened, closeModal, newVersionAvailable }: AboutMod
|
|||||||
<Trans i18nKey="layout/modals/about:description" />
|
<Trans i18nKey="layout/modals/about:description" />
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Table mb="lg" striped highlightOnHover withBorder>
|
<Table mb="lg" highlightOnHover withBorder>
|
||||||
<tbody>
|
<tbody>
|
||||||
{informations.map((item, index) => (
|
{informations.map((item, index) => (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
@@ -100,8 +117,24 @@ export const AboutModal = ({ opened, closeModal, newVersionAvailable }: AboutMod
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
<Accordion mb={5} variant="contained" radius="md">
|
||||||
|
<Accordion.Item value="keybinds">
|
||||||
|
<Accordion.Control icon={<IconKey size={20} />}>Keybinds</Accordion.Control>
|
||||||
|
<Accordion.Panel>
|
||||||
|
<Table mb={5}>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Key</th>
|
||||||
|
<th>Shortcut</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{rows}</tbody>
|
||||||
|
</Table>
|
||||||
|
<Tip>Mod refers to your modifier key, it is Ctrl and Command/Super/Windows key</Tip>
|
||||||
|
</Accordion.Panel>
|
||||||
|
</Accordion.Item>
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
<Divider variant="dashed" mb="md" />
|
|
||||||
<Title order={6} mb="xs" align="center">
|
<Title order={6} mb="xs" align="center">
|
||||||
{t('layout/modals/about:contact')}
|
{t('layout/modals/about:contact')}
|
||||||
</Title>
|
</Title>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const ToggleEditModeAction = () => {
|
|||||||
const { config } = useConfigContext();
|
const { config } = useConfigContext();
|
||||||
const { classes } = useCardStyles(true);
|
const { classes } = useCardStyles(true);
|
||||||
|
|
||||||
useHotkeys([['ctrl+E', toggleEditMode]]);
|
useHotkeys([['mod+E', toggleEditMode]]);
|
||||||
|
|
||||||
useWindowEvent('beforeunload', (event: BeforeUnloadEvent) => {
|
useWindowEvent('beforeunload', (event: BeforeUnloadEvent) => {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user