Skip to content

Commit

Permalink
chore: Tidy mention menu, remove unneccessary component
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Dec 19, 2024
1 parent 02aa4c2 commit b9f0f67
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
2 changes: 2 additions & 0 deletions app/components/ContextMenu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const Title = styled.div`
${ellipsis()}
flex-grow: 1;
display: flex;
align-items: center;
gap: 8px;
`;

type MenuAnchorProps = {
Expand Down
5 changes: 2 additions & 3 deletions app/editor/components/MentionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import Flex from "~/components/Flex";
import useRequest from "~/hooks/useRequest";
import useStores from "~/hooks/useStores";
import { client } from "~/utils/ApiClient";
import MentionMenuItem from "./MentionMenuItem";
import SuggestionsMenu, {
Props as SuggestionsMenuProps,
} from "./SuggestionsMenu";
import SuggestionsMenuItem from "./SuggestionsMenuItem";

interface MentionItem extends MenuItem {
name: string;
Expand Down Expand Up @@ -122,11 +122,10 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
search={search}
onSelect={handleSelect}
renderMenuItem={(item, _index, options) => (
<MentionMenuItem
<SuggestionsMenuItem
onClick={options.onClick}
selected={options.selected}
title={item.title}
label={item.attrs.label}
icon={
<Flex
align="center"
Expand Down
18 changes: 0 additions & 18 deletions app/editor/components/MentionMenuItem.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions app/editor/components/SuggestionsMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type Props = {
icon?: React.ReactElement;
/** The title of the item */
title: React.ReactNode;
/** An optional subtitle for the item */
subtitle?: React.ReactNode;
/** A string representing the keyboard shortcut for the item */
shortcut?: string;
};
Expand All @@ -24,6 +26,7 @@ function SuggestionsMenuItem({
disabled,
onClick,
title,
subtitle,
shortcut,
icon,
}: Props) {
Expand Down Expand Up @@ -53,11 +56,17 @@ function SuggestionsMenuItem({
icon={icon}
>
{title}
{subtitle && <Subtitle $active={selected}>{subtitle}</Subtitle>}
{shortcut && <Shortcut $active={selected}>{shortcut}</Shortcut>}
</MenuItem>
);
}

const Subtitle = styled.span<{ $active?: boolean }>`
color: ${(props) =>
props.$active ? props.theme.white50 : props.theme.textTertiary};
`;

const Shortcut = styled.span<{ $active?: boolean }>`
color: ${(props) =>
props.$active ? props.theme.white50 : props.theme.textTertiary};
Expand Down
1 change: 1 addition & 0 deletions shared/editor/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type MenuItem = {
icon?: React.ReactElement;
name?: string;
title?: string;
subtitle?: string;
shortcut?: string;
keywords?: string;
tooltip?: string;
Expand Down

0 comments on commit b9f0f67

Please sign in to comment.