Migrate to a monorepo structure (#2909)
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
||||
|
||||
import {
|
||||
keyboardShortcutsGeneral,
|
||||
keyboardShortcutsTable,
|
||||
} from '../constants/keyboardShortcuts';
|
||||
import { useKeyboardShortcutMenu } from '../hooks/useKeyboardShortcutMenu';
|
||||
import { isKeyboardShortcutMenuOpenedState } from '../states/isKeyboardShortcutMenuOpenedState';
|
||||
|
||||
import { KeyboardMenuDialog } from './KeyboardShortcutMenuDialog';
|
||||
import { KeyboardMenuGroup } from './KeyboardShortcutMenuGroup';
|
||||
import { KeyboardMenuItem } from './KeyboardShortcutMenuItem';
|
||||
|
||||
export const KeyboardShortcutMenu = () => {
|
||||
const { toggleKeyboardShortcutMenu, closeKeyboardShortcutMenu } =
|
||||
useKeyboardShortcutMenu();
|
||||
const isKeyboardShortcutMenuOpened = useRecoilValue(
|
||||
isKeyboardShortcutMenuOpenedState,
|
||||
);
|
||||
const { closeCommandMenu } = useCommandMenu();
|
||||
useScopedHotkeys(
|
||||
'shift+?,meta+?',
|
||||
() => {
|
||||
closeCommandMenu();
|
||||
toggleKeyboardShortcutMenu();
|
||||
},
|
||||
AppHotkeyScope.KeyboardShortcutMenu,
|
||||
[toggleKeyboardShortcutMenu],
|
||||
);
|
||||
|
||||
useScopedHotkeys(
|
||||
'esc',
|
||||
() => {
|
||||
closeKeyboardShortcutMenu();
|
||||
},
|
||||
AppHotkeyScope.KeyboardShortcutMenu,
|
||||
[toggleKeyboardShortcutMenu],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{isKeyboardShortcutMenuOpened && (
|
||||
<KeyboardMenuDialog onClose={toggleKeyboardShortcutMenu}>
|
||||
<KeyboardMenuGroup heading="Table">
|
||||
{keyboardShortcutsTable.map((TableShortcut) => (
|
||||
<KeyboardMenuItem shortcut={TableShortcut} />
|
||||
))}
|
||||
</KeyboardMenuGroup>
|
||||
<KeyboardMenuGroup heading="General">
|
||||
{keyboardShortcutsGeneral.map((GeneralShortcut) => (
|
||||
<KeyboardMenuItem shortcut={GeneralShortcut} />
|
||||
))}
|
||||
</KeyboardMenuGroup>
|
||||
</KeyboardMenuDialog>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
import { IconX } from '@/ui/display/icon';
|
||||
import { IconButton } from '@/ui/input/button/components/IconButton';
|
||||
|
||||
import {
|
||||
StyledContainer,
|
||||
StyledDialog,
|
||||
StyledHeading,
|
||||
} from './KeyboardShortcutMenuStyles';
|
||||
|
||||
type KeyboardMenuDialogProps = {
|
||||
onClose: () => void;
|
||||
children: React.ReactNode | React.ReactNode[];
|
||||
};
|
||||
|
||||
export const KeyboardMenuDialog = ({
|
||||
onClose,
|
||||
children,
|
||||
}: KeyboardMenuDialogProps) => {
|
||||
return (
|
||||
<StyledDialog>
|
||||
<StyledHeading>
|
||||
Keyboard shortcuts
|
||||
<IconButton variant="tertiary" Icon={IconX} onClick={onClose} />
|
||||
</StyledHeading>
|
||||
<StyledContainer>{children}</StyledContainer>
|
||||
</StyledDialog>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,18 @@
|
||||
import { StyledGroup, StyledGroupHeading } from './KeyboardShortcutMenuStyles';
|
||||
|
||||
type KeyboardMenuGroupProps = {
|
||||
heading: string;
|
||||
children: React.ReactNode | React.ReactNode[];
|
||||
};
|
||||
|
||||
export const KeyboardMenuGroup = ({
|
||||
heading,
|
||||
children,
|
||||
}: KeyboardMenuGroupProps) => {
|
||||
return (
|
||||
<StyledGroup>
|
||||
<StyledGroupHeading>{heading}</StyledGroupHeading>
|
||||
{children}
|
||||
</StyledGroup>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
import {
|
||||
StyledItem,
|
||||
StyledShortcutKey,
|
||||
StyledShortcutKeyContainer,
|
||||
} from '@/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles';
|
||||
import { Shortcut } from '@/keyboard-shortcut-menu/types/Shortcut';
|
||||
|
||||
type KeyboardMenuItemProps = {
|
||||
shortcut: Shortcut;
|
||||
};
|
||||
|
||||
export const KeyboardMenuItem = ({ shortcut }: KeyboardMenuItemProps) => {
|
||||
return (
|
||||
<StyledItem>
|
||||
{shortcut.label}
|
||||
{shortcut.secondHotKey ? (
|
||||
shortcut.areSimultaneous ? (
|
||||
<StyledShortcutKeyContainer>
|
||||
<StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
|
||||
<StyledShortcutKey>{shortcut.secondHotKey}</StyledShortcutKey>
|
||||
</StyledShortcutKeyContainer>
|
||||
) : (
|
||||
<StyledShortcutKeyContainer>
|
||||
<StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
|
||||
then
|
||||
<StyledShortcutKey>{shortcut.secondHotKey}</StyledShortcutKey>
|
||||
</StyledShortcutKeyContainer>
|
||||
)
|
||||
) : (
|
||||
<StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
|
||||
)}
|
||||
</StyledItem>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,88 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
|
||||
export const StyledDialog = styled.div`
|
||||
background: ${({ theme }) => theme.background.primary};
|
||||
border-radius: ${({ theme }) => theme.border.radius.md};
|
||||
box-shadow: ${({ theme }) => theme.boxShadow.strong};
|
||||
font-family: ${({ theme }) => theme.font.family};
|
||||
left: 50%;
|
||||
max-width: 400px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
padding: ${({ theme }) => theme.spacing(1)};
|
||||
position: fixed;
|
||||
top: 30%;
|
||||
transform: ${() =>
|
||||
useIsMobile() ? 'translateX(-49.5%)' : 'translateX(-50%)'};
|
||||
width: ${() => (useIsMobile() ? 'calc(100% - 40px)' : '100%')};
|
||||
z-index: 1000;
|
||||
`;
|
||||
|
||||
export const StyledHeading = styled.div`
|
||||
align-items: center;
|
||||
border-bottom: 1px solid ${({ theme }) => theme.border.color.medium};
|
||||
color: ${({ theme }) => theme.font.color.primary};
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
||||
justify-content: space-between;
|
||||
padding: ${({ theme }) => theme.spacing(3)};
|
||||
`;
|
||||
|
||||
export const StyledContainer = styled.div`
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
padding-bottom: ${({ theme }) => theme.spacing(4)};
|
||||
padding-left: ${({ theme }) => theme.spacing(4)};
|
||||
padding-right: ${({ theme }) => theme.spacing(4)};
|
||||
padding-top: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
|
||||
export const StyledGroupHeading = styled.label`
|
||||
color: ${({ theme }) => theme.color.gray50};
|
||||
padding-bottom: ${({ theme }) => theme.spacing(1)};
|
||||
padding-top: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
export const StyledGroup = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
`;
|
||||
|
||||
export const StyledItem = styled.div`
|
||||
align-items: center;
|
||||
color: ${({ theme }) => theme.font.color.primary};
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
font-weight: ${({ theme }) => theme.font.weight.regular};
|
||||
height: 24px;
|
||||
justify-content: space-between;
|
||||
`;
|
||||
|
||||
export const StyledShortcutKey = styled.div`
|
||||
align-items: center;
|
||||
background-color: ${({ theme }) => theme.background.secondary};
|
||||
border: 1px solid ${({ theme }) => theme.border.color.strong};
|
||||
border-radius: ${({ theme }) => theme.border.radius.sm};
|
||||
box-shadow: ${({ theme }) => theme.boxShadow.underline};
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: ${({ theme }) => theme.font.size.md};
|
||||
font-weight: ${({ theme }) => theme.font.weight.regular};
|
||||
height: 20px;
|
||||
justify-content: center;
|
||||
padding-left: ${({ theme }) => theme.spacing(1)};
|
||||
padding-right: ${({ theme }) => theme.spacing(1)};
|
||||
text-align: center;
|
||||
`;
|
||||
|
||||
export const StyledShortcutKeyContainer = styled.div`
|
||||
align-items: center;
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
Reference in New Issue
Block a user