mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
```[tasklist] ### Tasks - [x] Migrate components from [design](https://github.com/toeverything/design) - [x] Replace all imports from `@toeverything/components` - [x] Clean up `@toeverything/components` dependencies - [x] Storybook ``` ### Influence Here are all the components that are influenced by `@toeverything/components` - `@affine/component` - App update `Button` `Tooltip` - App sidebar header `IconButton`, `Tooltip` - Back `Button` - Auth - Change email page save `Button` - Change password page all `Button`s (Save, Later, Open) - Confirm change email `Button` - Set password page `Button` - Sign in success page `Button` - Sign up page `Button` - Auth `Modal` - Workspace card `Avatar`, `Divider`, `Tooltip`, `IconButton` - Share - Disable shared public link `Modal` - Import page `IconButton`, `Tooltip` - Accept invite page `Avatar`, `Button` - Invite member `Modal` - 404 Page `Avatar`, `Button`, `IconButton`, `Tooltip` - Notification center `IconButton` - Page list - operation cell `IconButton`, `Menu`, `ConfirmModal`, `Tooltip` - tags more `Menu` - favorite `IconButton`, `Tooltip` - new page dropdown `Menu` - filter `Menu`, `Button`, `IconButton` - Page operation `Menu` - export `MenuItem` - move to trash `MenuItem`, `ConfirmModal` - Workspace header filter `Menu`, `Button` - Collection bar `Button`, `Tooltip` (*⚠️ seems not used*) - Collection operation `Menu`, `MenuItem` - Create collection `Modal`, `Button` - Edit collection `Modal`, `Button` - Page mode filter `Menu` - Page mode `Button`, `Menu` - Setting modal - storage usage progress `Button`, `Tooltip` - On boarding tour `Modal` - `@affine/core` - Bookmark `Menu` - Affine error boundary `Button` - After sign in send email `Button` - After sign up send email `Button` - Send email `Button` - Sign in `Button` - Subscription redirect `Loading`, `Button` - Setting `Modal` - User plan button `Tooltip` - Members `Avatar`, `Button`, `IconButton`, `Loading`, `Tooltip`, `Menu` - Profile `Button`, `Avatar` - Workspace - publish panel `Button`, `Tooltip` - export panel `Button` - storage panel `Button`, `Tooltip` - delete `ConfirmModal` - Language `Menu` - Account setting `Avatar`, `Button` - Date format setting `Menu` - Billing `Button`, `IconButton`, `Loading` - Payment plans `Button`, `ConfirmModal`, `Modal`, `Tooltip` - Create workspace `Modal`, `ConfirmModal`, `Button` - Payment disabled `ConfirmModal` - Share/Export `Menu`, `Button`, `Divider` - Sign out `ConfirmModal` - Temp disable affine cloud `Modal` - Page detail operation `Menu` - Blocksuite mode switch `Tooltip` - Login card `Avatar` - Help island `Tooltip` - `plugin` - copilot - hello world - image preview - outline
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { ArrowRightSmallIcon } from '@blocksuite/icons';
|
|
import type {
|
|
DropdownMenuSubProps,
|
|
MenuPortalProps,
|
|
MenuSubContentProps,
|
|
} from '@radix-ui/react-dropdown-menu';
|
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
import clsx from 'clsx';
|
|
import type { ReactNode } from 'react';
|
|
import { useMemo } from 'react';
|
|
|
|
import type { MenuItemProps } from './menu.types';
|
|
import { MenuIcon } from './menu-icon';
|
|
import * as styles from './styles.css';
|
|
import { useMenuItem } from './use-menu-item';
|
|
export interface MenuSubProps {
|
|
children: ReactNode;
|
|
items: ReactNode;
|
|
triggerOptions?: Omit<MenuItemProps, 'onSelect' | 'children'>;
|
|
portalOptions?: Omit<MenuPortalProps, 'children'>;
|
|
subOptions?: Omit<DropdownMenuSubProps, 'children'>;
|
|
subContentOptions?: Omit<MenuSubContentProps, 'children'>;
|
|
}
|
|
|
|
export const MenuSub = ({
|
|
children: propsChildren,
|
|
items,
|
|
portalOptions,
|
|
subOptions,
|
|
triggerOptions: {
|
|
className: propsClassName,
|
|
preFix,
|
|
endFix,
|
|
type,
|
|
...otherTriggerOptions
|
|
} = {},
|
|
subContentOptions: {
|
|
className: subContentClassName = '',
|
|
...otherSubContentOptions
|
|
} = {},
|
|
}: MenuSubProps) => {
|
|
const { className, children } = useMenuItem({
|
|
children: propsChildren,
|
|
className: propsClassName,
|
|
type,
|
|
preFix,
|
|
endFix,
|
|
});
|
|
|
|
return (
|
|
<DropdownMenu.Sub {...subOptions}>
|
|
<DropdownMenu.SubTrigger className={className} {...otherTriggerOptions}>
|
|
{children}
|
|
<MenuIcon position="end">
|
|
<ArrowRightSmallIcon />
|
|
</MenuIcon>
|
|
</DropdownMenu.SubTrigger>
|
|
<DropdownMenu.Portal {...portalOptions}>
|
|
<DropdownMenu.SubContent
|
|
sideOffset={10}
|
|
className={useMemo(
|
|
() => clsx(styles.menuContent, subContentClassName),
|
|
[subContentClassName]
|
|
)}
|
|
{...otherSubContentOptions}
|
|
>
|
|
{items}
|
|
</DropdownMenu.SubContent>
|
|
</DropdownMenu.Portal>
|
|
</DropdownMenu.Sub>
|
|
);
|
|
};
|