mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
feat(core): add tooltips to sidebar resize handle (#8717)
close PD-1865 
This commit is contained in:
@@ -40,15 +40,22 @@ export interface TooltipProps {
|
||||
rootOptions?: Omit<RootProps, 'children'>;
|
||||
portalOptions?: TooltipPortalProps;
|
||||
options?: Omit<TooltipContentProps, 'side' | 'align'>;
|
||||
shortcutClassName?: string;
|
||||
}
|
||||
|
||||
const TooltipShortcut = ({ shortcut }: { shortcut: string | string[] }) => {
|
||||
const TooltipShortcut = ({
|
||||
shortcut,
|
||||
className,
|
||||
}: {
|
||||
shortcut: string | string[];
|
||||
className?: string;
|
||||
}) => {
|
||||
const commands = (Array.isArray(shortcut) ? shortcut : [shortcut])
|
||||
.map(cmd => cmd.trim())
|
||||
.map(cmd => getCommand(cmd));
|
||||
|
||||
return (
|
||||
<div className={styles.shortcut}>
|
||||
<div className={clsx(styles.shortcut, className)}>
|
||||
{commands.map((cmd, index) => (
|
||||
<div
|
||||
key={`${index}-${cmd}`}
|
||||
@@ -71,6 +78,7 @@ export const Tooltip = ({
|
||||
options,
|
||||
rootOptions,
|
||||
portalOptions,
|
||||
shortcutClassName,
|
||||
}: TooltipProps) => {
|
||||
if (!content) {
|
||||
return children;
|
||||
@@ -94,7 +102,10 @@ export const Tooltip = ({
|
||||
{shortcut ? (
|
||||
<div className={styles.withShortcut}>
|
||||
<div className={styles.withShortcutContent}>{content}</div>
|
||||
<TooltipShortcut shortcut={shortcut} />
|
||||
<TooltipShortcut
|
||||
shortcut={shortcut}
|
||||
className={shortcutClassName}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
content
|
||||
|
||||
Reference in New Issue
Block a user