feat: replace tooltip with new design (#3969)

This commit is contained in:
Qi
2023-08-28 14:15:12 +08:00
committed by GitHub
parent b9c4b88a6b
commit 1e87707b2e
28 changed files with 138 additions and 148 deletions

View File

@@ -39,7 +39,7 @@
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@mui/material": "^5.14.6", "@mui/material": "^5.14.6",
"@react-hookz/web": "^23.1.0", "@react-hookz/web": "^23.1.0",
"@toeverything/components": "^0.0.17", "@toeverything/components": "^0.0.19",
"async-call-rpc": "^6.3.1", "async-call-rpc": "^6.3.1",
"cmdk": "^0.2.0", "cmdk": "^0.2.0",
"css-spring": "^4.1.0", "css-spring": "^4.1.0",

View File

@@ -158,6 +158,9 @@ function createSetupImpl(rootStore: ReturnType<typeof createStore>) {
'@toeverything/components/button': import( '@toeverything/components/button': import(
'@toeverything/components/button' '@toeverything/components/button'
), ),
'@toeverything/components/tooltip': import(
'@toeverything/components/tooltip'
),
}); });
// pluginName -> module -> importName -> updater[] // pluginName -> module -> importName -> updater[]

View File

@@ -4,19 +4,19 @@ import {
ModalCloseButton, ModalCloseButton,
ModalWrapper, ModalWrapper,
toast, toast,
Tooltip,
} from '@affine/component'; } from '@affine/component';
import { DebugLogger } from '@affine/debug'; import { DebugLogger } from '@affine/debug';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { HelpIcon } from '@blocksuite/icons'; import { HelpIcon } from '@blocksuite/icons';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import type { import type {
LoadDBFileResult, LoadDBFileResult,
SelectDBFileLocationResult, SelectDBFileLocationResult,
} from '@toeverything/infra/type'; } from '@toeverything/infra/type';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import type { KeyboardEvent } from 'react'; import type { KeyboardEvent } from 'react';
import { useEffect } from 'react'; import { useEffect, useRef } from 'react';
import { useLayoutEffect } from 'react'; import { useLayoutEffect } from 'react';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
@@ -125,6 +125,7 @@ const SetDBLocationContent = ({
onConfirmLocation, onConfirmLocation,
}: SetDBLocationContentProps) => { }: SetDBLocationContentProps) => {
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
const ref = useRef(null);
const defaultDBLocation = useDefaultDBLocation(); const defaultDBLocation = useDefaultDBLocation();
const [opening, setOpening] = useState(false); const [opening, setOpening] = useState(false);
@@ -161,11 +162,12 @@ const SetDBLocationContent = ({
{t['Customize']()} {t['Customize']()}
</Button> </Button>
<Tooltip <Tooltip
zIndex={1000}
content={t['Default db location hint']({ content={t['Default db location hint']({
location: defaultDBLocation, location: defaultDBLocation,
})} })}
placement="top-start" portalOptions={{
container: ref.current,
}}
> >
<Button <Button
data-testid="create-workspace-default-location-button" data-testid="create-workspace-default-location-button"
@@ -175,6 +177,7 @@ const SetDBLocationContent = ({
}} }}
icon={<HelpIcon />} icon={<HelpIcon />}
iconPosition="end" iconPosition="end"
ref={ref}
> >
{t['Default Location']()} {t['Default Location']()}
</Button> </Button>

View File

@@ -1,4 +1,4 @@
import { FlexWrapper, Switch, Tooltip } from '@affine/component'; import { FlexWrapper, Switch } from '@affine/component';
import { SettingRow } from '@affine/component/setting-components'; import { SettingRow } from '@affine/component/setting-components';
import { Unreachable } from '@affine/env/constant'; import { Unreachable } from '@affine/env/constant';
import type { import type {
@@ -8,6 +8,7 @@ import type {
import { WorkspaceFlavour } from '@affine/env/workspace'; import { WorkspaceFlavour } from '@affine/env/workspace';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name'; import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
@@ -93,10 +94,7 @@ const FakePublishPanelAffine = (_props: FakePublishPanelAffineProps) => {
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
return ( return (
<Tooltip <Tooltip content={t['com.affine.settings.workspace.publish-tooltip']()}>
content={t['com.affine.settings.workspace.publish-tooltip']()}
placement="top"
>
<div className={style.fakeWrapper}> <div className={style.fakeWrapper}>
<SettingRow name={t['Publish']()} desc={t['Unpublished hint']()}> <SettingRow name={t['Publish']()} desc={t['Unpublished hint']()}>
<Switch checked={false} /> <Switch checked={false} />

View File

@@ -1,7 +1,8 @@
import { FlexWrapper, toast, Tooltip } from '@affine/component'; import { FlexWrapper, toast } from '@affine/component';
import { SettingRow } from '@affine/component/setting-components'; import { SettingRow } from '@affine/component/setting-components';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import type { MoveDBFileResult } from '@toeverything/infra/type'; import type { MoveDBFileResult } from '@toeverything/infra/type';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
@@ -75,9 +76,9 @@ export const StoragePanel = ({ workspace }: StoragePanelProps) => {
secondaryPath ? ( secondaryPath ? (
<FlexWrapper justifyContent="space-between"> <FlexWrapper justifyContent="space-between">
<Tooltip <Tooltip
zIndex={1000}
content={t['com.affine.settings.storage.db-location.change-hint']()} content={t['com.affine.settings.storage.db-location.change-hint']()}
placement="top-start" side="top"
align="start"
> >
<Button <Button
data-testid="move-folder" data-testid="move-folder"

View File

@@ -1,4 +1,4 @@
import { ScrollableContainer, Tooltip } from '@affine/component'; import { ScrollableContainer } from '@affine/component';
import { import {
WorkspaceListItemSkeleton, WorkspaceListItemSkeleton,
WorkspaceListSkeleton, WorkspaceListSkeleton,
@@ -7,11 +7,12 @@ import { WorkspaceAvatar } from '@affine/component/workspace-avatar';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import type { RootWorkspaceMetadata } from '@affine/workspace/atom'; import type { RootWorkspaceMetadata } from '@affine/workspace/atom';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom'; import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { Tooltip } from '@toeverything/components/tooltip';
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name'; import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react'; import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
import clsx from 'clsx'; import clsx from 'clsx';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { Suspense } from 'react'; import { Suspense, useRef } from 'react';
import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace'; import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace';
import type { import type {
@@ -136,6 +137,7 @@ const WorkspaceListItem = ({
}: WorkspaceListItemProps) => { }: WorkspaceListItemProps) => {
const workspace = useStaticBlockSuiteWorkspace(meta.id); const workspace = useStaticBlockSuiteWorkspace(meta.id);
const [workspaceName] = useBlockSuiteWorkspaceName(workspace); const [workspaceName] = useBlockSuiteWorkspaceName(workspace);
const ref = useRef(null);
return ( return (
<div <div
@@ -143,16 +145,17 @@ const WorkspaceListItem = ({
title={workspaceName} title={workspaceName}
onClick={onClick} onClick={onClick}
data-testid="workspace-list-item" data-testid="workspace-list-item"
ref={ref}
> >
<WorkspaceAvatar size={14} workspace={workspace} className="icon" /> <WorkspaceAvatar size={14} workspace={workspace} className="icon" />
<span className="setting-name">{workspaceName}</span> <span className="setting-name">{workspaceName}</span>
{isCurrent ? ( {isCurrent ? (
<Tooltip <Tooltip
content="Current" content="Current"
title="Current" side="top"
offset={[0, -5]} portalOptions={{
placement="top" container: ref.current,
disablePortal={false} }}
> >
<div <div
className={currentWorkspaceLabel} className={currentWorkspaceLabel}

View File

@@ -1,10 +1,10 @@
import { Tooltip } from '@affine/component';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { Tooltip } from '@toeverything/components/tooltip';
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta'; import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
import { useAtom } from 'jotai'; import { useAtom } from 'jotai';
import type { CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import { useEffect } from 'react'; import { useEffect, useRef } from 'react';
import { pageSettingFamily } from '../../../atoms'; import { pageSettingFamily } from '../../../atoms';
import type { BlockSuiteWorkspace } from '../../../shared'; import type { BlockSuiteWorkspace } from '../../../shared';
@@ -21,12 +21,12 @@ export type EditorModeSwitchProps = {
const TooltipContent = () => { const TooltipContent = () => {
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
return ( return (
<div> <>
{t['Switch']()} {t['Switch']()}
<StyledKeyboardItem> <StyledKeyboardItem>
{!environment.isServer && environment.isMacOs ? '⌥ + S' : 'Alt + S'} {!environment.isServer && environment.isMacOs ? '⌥ + S' : 'Alt + S'}
</StyledKeyboardItem> </StyledKeyboardItem>
</div> </>
); );
}; };
export const EditorModeSwitch = ({ export const EditorModeSwitch = ({
@@ -40,6 +40,7 @@ export const EditorModeSwitch = ({
meta => meta.id === pageId meta => meta.id === pageId
); );
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
const ref = useRef(null);
assertExists(pageMeta); assertExists(pageMeta);
const { trash } = pageMeta; const { trash } = pageMeta;
useEffect(() => { useEffect(() => {
@@ -70,11 +71,17 @@ export const EditorModeSwitch = ({
}, [setSetting, t, trash]); }, [setSetting, t, trash]);
return ( return (
<Tooltip content={<TooltipContent />}> <Tooltip
content={<TooltipContent />}
portalOptions={{
container: ref.current,
}}
>
<StyledEditorModeSwitch <StyledEditorModeSwitch
style={style} style={style}
switchLeft={currentMode === 'page'} switchLeft={currentMode === 'page'}
showAlone={trash} showAlone={trash}
ref={ref}
> >
<PageSwitchItem <PageSwitchItem
data-testid="switch-page-mode-button" data-testid="switch-page-mode-button"

View File

@@ -1,6 +1,7 @@
import { MuiFade, Tooltip } from '@affine/component'; import { MuiFade } from '@affine/component';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { CloseIcon, NewIcon, UserGuideIcon } from '@blocksuite/icons'; import { CloseIcon, NewIcon, UserGuideIcon } from '@blocksuite/icons';
import { Tooltip } from '@toeverything/components/tooltip';
import { useSetAtom } from 'jotai/react'; import { useSetAtom } from 'jotai/react';
import { useAtomValue } from 'jotai/react'; import { useAtomValue } from 'jotai/react';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
@@ -60,11 +61,7 @@ export const HelpIsland = ({
style={{ height: spread ? `${showList.length * 40 + 4}px` : 0 }} style={{ height: spread ? `${showList.length * 40 + 4}px` : 0 }}
> >
{showList.includes('whatNew') && ( {showList.includes('whatNew') && (
<Tooltip <Tooltip content={t["Discover what's new!"]()} side="left">
content={t["Discover what's new!"]()}
placement="left-end"
showArrow={true}
>
<StyledIconWrapper <StyledIconWrapper
data-testid="right-bottom-change-log-icon" data-testid="right-bottom-change-log-icon"
onClick={() => { onClick={() => {
@@ -76,11 +73,7 @@ export const HelpIsland = ({
</Tooltip> </Tooltip>
)} )}
{showList.includes('contact') && ( {showList.includes('contact') && (
<Tooltip <Tooltip content={t['Contact Us']()} side="left">
content={t['Contact Us']()}
placement="left-end"
showArrow={true}
>
<StyledIconWrapper <StyledIconWrapper
data-testid="right-bottom-contact-us-icon" data-testid="right-bottom-contact-us-icon"
onClick={openAbout} onClick={openAbout}
@@ -90,11 +83,7 @@ export const HelpIsland = ({
</Tooltip> </Tooltip>
)} )}
{showList.includes('shortcuts') && ( {showList.includes('shortcuts') && (
<Tooltip <Tooltip content={t['Keyboard Shortcuts']()} side="left">
content={t['Keyboard Shortcuts']()}
placement="left-end"
showArrow={true}
>
<StyledIconWrapper <StyledIconWrapper
data-testid="shortcuts-icon" data-testid="shortcuts-icon"
onClick={() => { onClick={() => {
@@ -109,8 +98,7 @@ export const HelpIsland = ({
{showList.includes('guide') && ( {showList.includes('guide') && (
<Tooltip <Tooltip
content={t['com.affine.helpIsland.gettingStarted']()} content={t['com.affine.helpIsland.gettingStarted']()}
placement="left-end" side="left"
showArrow={true}
> >
<StyledIconWrapper <StyledIconWrapper
data-testid="easy-guide" data-testid="easy-guide"
@@ -125,11 +113,7 @@ export const HelpIsland = ({
)} )}
</StyledAnimateWrapper> </StyledAnimateWrapper>
<Tooltip <Tooltip content={t['Help and Feedback']()} side="left">
content={t['Help and Feedback']()}
placement={'left-end'}
showArrow={true}
>
<MuiFade in={!spread} data-testid="faq-icon"> <MuiFade in={!spread} data-testid="faq-icon">
<StyledTriggerWrapper> <StyledTriggerWrapper>
<HelpIcon /> <HelpIcon />

View File

@@ -1,4 +1,4 @@
import { toast, Tooltip } from '@affine/component'; import { toast } from '@affine/component';
import { BlockCard } from '@affine/component/card/block-card'; import { BlockCard } from '@affine/component/card/block-card';
import { WorkspaceCard } from '@affine/component/card/workspace-card'; import { WorkspaceCard } from '@affine/component/card/workspace-card';
import { WorkspaceFlavour } from '@affine/env/workspace'; import { WorkspaceFlavour } from '@affine/env/workspace';
@@ -10,6 +10,7 @@ import {
PageIcon, PageIcon,
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { Tooltip } from '@toeverything/components/tooltip';
export default { export default {
title: 'AFFiNE/Card', title: 'AFFiNE/Card',

View File

@@ -1,7 +1,7 @@
import { Tooltip } from '@affine/component';
import { isBrowser, Unreachable } from '@affine/env/constant'; import { isBrowser, Unreachable } from '@affine/env/constant';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { CloseIcon, NewIcon, ResetIcon } from '@blocksuite/icons'; import { CloseIcon, NewIcon, ResetIcon } from '@blocksuite/icons';
import { Tooltip } from '@toeverything/components/tooltip';
import clsx from 'clsx'; import clsx from 'clsx';
import { atom, useAtomValue, useSetAtom } from 'jotai'; import { atom, useAtomValue, useSetAtom } from 'jotai';
import { startTransition, useCallback, useState } from 'react'; import { startTransition, useCallback, useState } from 'react';
@@ -115,7 +115,7 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
} }
return ( return (
<Tooltip content={tooltip} placement="top-start"> <Tooltip content={tooltip} side="top">
{node} {node}
</Tooltip> </Tooltip>
); );

View File

@@ -1,14 +1,16 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { SidebarIcon } from '@blocksuite/icons'; import { SidebarIcon } from '@blocksuite/icons';
import { IconButton } from '@toeverything/components/button'; import { IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useAtom } from 'jotai'; import { useAtom } from 'jotai';
import { useRef } from 'react';
import { Tooltip } from '../../../';
import { appSidebarOpenAtom } from '../index.jotai'; import { appSidebarOpenAtom } from '../index.jotai';
export const SidebarSwitch = () => { export const SidebarSwitch = () => {
const [open, setOpen] = useAtom(appSidebarOpenAtom); const [open, setOpen] = useAtom(appSidebarOpenAtom);
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
const ref = useRef(null);
const tooltipContent = open ? t['Collapse sidebar']() : t['Expand sidebar'](); const tooltipContent = open ? t['Collapse sidebar']() : t['Expand sidebar']();
const collapseKeyboardShortcuts = const collapseKeyboardShortcuts =
environment.isBrowser && environment.isMacOs ? ' ⌘+/' : ' Ctrl+/'; environment.isBrowser && environment.isMacOs ? ' ⌘+/' : ' Ctrl+/';
@@ -16,8 +18,10 @@ export const SidebarSwitch = () => {
return ( return (
<Tooltip <Tooltip
content={tooltipContent + ' ' + collapseKeyboardShortcuts} content={tooltipContent + ' ' + collapseKeyboardShortcuts}
placement="right" side="right"
zIndex={1000} portalOptions={{
container: ref.current,
}}
> >
<IconButton <IconButton
size="large" size="large"
@@ -26,6 +30,7 @@ export const SidebarSwitch = () => {
zIndex: 1, zIndex: 1,
}} }}
onClick={() => setOpen(open => !open)} onClick={() => setOpen(open => !open)}
ref={ref}
> >
<SidebarIcon /> <SidebarIcon />
</IconButton> </IconButton>

View File

@@ -5,9 +5,9 @@ import {
NewIcon, NewIcon,
NotionIcon, NotionIcon,
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import { Tooltip } from '@toeverything/components/tooltip';
import { ModalCloseButton } from '../../ui/modal'; import { ModalCloseButton } from '../../ui/modal';
import { Tooltip } from '../../ui/tooltip';
import { BlockCard } from '../card/block-card'; import { BlockCard } from '../card/block-card';
import { import {
importPageBodyStyle, importPageBodyStyle,
@@ -58,7 +58,6 @@ export const ImportPage = ({
right={ right={
<Tooltip <Tooltip
content={'Learn how to Import your Notion pages into AFFiNE.'} content={'Learn how to Import your Notion pages into AFFiNE.'}
placement="top-start"
> >
<HelpIcon width={20} height={20} /> <HelpIcon width={20} height={20} />
</Tooltip> </Tooltip>

View File

@@ -4,10 +4,9 @@ import {
IconButton, IconButton,
type IconButtonProps, type IconButtonProps,
} from '@toeverything/components/button'; } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { Tooltip } from '../../..';
export const FavoriteTag = forwardRef< export const FavoriteTag = forwardRef<
HTMLButtonElement, HTMLButtonElement,
{ {
@@ -16,10 +15,7 @@ export const FavoriteTag = forwardRef<
>(({ active, onClick, ...props }, ref) => { >(({ active, onClick, ...props }, ref) => {
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
return ( return (
<Tooltip <Tooltip content={active ? t['Favorited']() : t['Favorite']()} side="top">
content={active ? t['Favorited']() : t['Favorite']()}
placement="top-start"
>
<IconButton <IconButton
ref={ref} ref={ref}
active={active} active={active}

View File

@@ -9,9 +9,10 @@ import {
ResetIcon, ResetIcon,
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import { IconButton } from '@toeverything/components/button'; import { IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useState } from 'react'; import { useState } from 'react';
import { Confirm, FlexWrapper, Menu, MenuItem, Tooltip } from '../../..'; import { Confirm, FlexWrapper, Menu, MenuItem } from '../../..';
import { DisablePublicSharing, MoveToTrash } from './operation-menu-items'; import { DisablePublicSharing, MoveToTrash } from './operation-menu-items';
export interface OperationCellProps { export interface OperationCellProps {
@@ -125,7 +126,7 @@ export const TrashOperationCell = ({
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return ( return (
<FlexWrapper> <FlexWrapper>
<Tooltip content={t['Restore it']()} placement="top-start"> <Tooltip content={t['Restore it']()} side="top">
<IconButton <IconButton
style={{ marginRight: '12px' }} style={{ marginRight: '12px' }}
onClick={() => { onClick={() => {
@@ -135,7 +136,7 @@ export const TrashOperationCell = ({
<ResetIcon /> <ResetIcon />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
<Tooltip content={t['Delete permanently']()} placement="top-start"> <Tooltip content={t['Delete permanently']()} side="top" align="end">
<IconButton <IconButton
onClick={() => { onClick={() => {
setOpen(true); setOpen(true);

View File

@@ -1,10 +1,10 @@
import { Tooltip } from '@affine/component';
import { EditCollectionModel } from '@affine/component/page-list'; import { EditCollectionModel } from '@affine/component/page-list';
import type { PropertiesMeta } from '@affine/env/filter'; import type { PropertiesMeta } from '@affine/env/filter';
import type { GetPageInfoById } from '@affine/env/page-info'; import type { GetPageInfoById } from '@affine/env/page-info';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ViewLayersIcon } from '@blocksuite/icons'; import { ViewLayersIcon } from '@blocksuite/icons';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import clsx from 'clsx'; import clsx from 'clsx';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
@@ -53,7 +53,9 @@ export const CollectionBar = (props: CollectionBarProps) => {
/> />
<Tooltip <Tooltip
content={setting.currentCollection.name} content={setting.currentCollection.name}
pointerEnterDelay={1500} rootOptions={{
delayDuration: 1500,
}}
> >
<div <div
style={{ style={{
@@ -68,11 +70,7 @@ export const CollectionBar = (props: CollectionBarProps) => {
</Tooltip> </Tooltip>
{actions.map(action => { {actions.map(action => {
return ( return (
<Tooltip <Tooltip key={action.name} content={action.tooltip}>
key={action.name}
content={action.tooltip}
placement="top-start"
>
<div <div
data-testid={`collection-bar-option-${action.name}`} data-testid={`collection-bar-option-${action.name}`}
onClick={action.click} onClick={action.click}

View File

@@ -6,11 +6,12 @@ import type { GetPageInfoById } from '@affine/env/page-info';
import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { FilteredIcon, FolderIcon, ViewLayersIcon } from '@blocksuite/icons'; import { FilteredIcon, FolderIcon, ViewLayersIcon } from '@blocksuite/icons';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import clsx from 'clsx'; import clsx from 'clsx';
import type { MouseEvent } from 'react'; import type { MouseEvent } from 'react';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { MenuItem, Tooltip } from '../../..'; import { MenuItem } from '../../..';
import Menu from '../../../ui/menu/menu'; import Menu from '../../../ui/menu/menu';
import { CreateFilterMenu } from '../filter/vars'; import { CreateFilterMenu } from '../filter/vars';
import type { useCollectionManager } from '../use-collection-manager'; import type { useCollectionManager } from '../use-collection-manager';
@@ -46,8 +47,10 @@ const CollectionOption = ({
> >
<Tooltip <Tooltip
content={collection.name} content={collection.name}
placement="right" side="right"
pointerEnterDelay={1500} rootOptions={{
delayDuration: 1500,
}}
> >
<div <div
style={{ style={{
@@ -171,7 +174,9 @@ export const CollectionList = ({
> >
<Tooltip <Tooltip
content={setting.currentCollection.name} content={setting.currentCollection.name}
pointerEnterDelay={1500} rootOptions={{
delayDuration: 1500,
}}
> >
<>{setting.currentCollection.name}</> <>{setting.currentCollection.name}</>
</Tooltip> </Tooltip>

View File

@@ -15,5 +15,4 @@ export * from './ui/shared/container';
export * from './ui/switch'; export * from './ui/switch';
export * from './ui/table'; export * from './ui/table';
export * from './ui/toast'; export * from './ui/toast';
export * from './ui/tooltip';
export * from './ui/tree-view'; export * from './ui/tree-view';

View File

@@ -1 +0,0 @@
export * from './tooltip';

View File

@@ -1,40 +0,0 @@
import { NoSsr } from '@mui/material';
import type { ReactElement } from 'react';
import { styled } from '../../styles';
import { Popper, type PopperProps } from '../popper';
import StyledPopperContainer from '../shared/container';
const StyledTooltip = styled(StyledPopperContainer)(() => {
return {
display: 'inline-flex',
minHeight: '38px',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
flexShrink: 0,
backgroundColor: 'var(--affine-tooltip)',
borderRadius: '4px',
color: 'var(--affine-white)',
padding: '5px 12px',
};
});
interface TooltipProps {
content: string | ReactElement<any, any>;
placement?: PopperProps['placement'];
children: ReactElement<any, any>;
}
export const Tooltip = (props: PopperProps & Omit<TooltipProps, 'title'>) => {
const { content, placement = 'top-start', children } = props;
return (
<NoSsr>
<Popper
{...props}
content={<StyledTooltip placement={placement}>{content}</StyledTooltip>}
>
{children}
</Popper>
</NoSsr>
);
};

View File

@@ -16,7 +16,7 @@
"dependencies": { "dependencies": {
"@affine/component": "workspace:*", "@affine/component": "workspace:*",
"@affine/sdk": "workspace:*", "@affine/sdk": "workspace:*",
"@toeverything/components": "^0.0.17", "@toeverything/components": "^0.0.19",
"idb": "^7.1.1", "idb": "^7.1.1",
"langchain": "^0.0.134", "langchain": "^0.0.134",
"marked": "^7.0.4", "marked": "^7.0.4",

View File

@@ -1,7 +1,7 @@
import { Tooltip } from '@affine/component';
import { deleteLayoutAtom, pushLayoutAtom } from '@affine/sdk/entry'; import { deleteLayoutAtom, pushLayoutAtom } from '@affine/sdk/entry';
import { AiIcon } from '@blocksuite/icons'; import { AiIcon } from '@blocksuite/icons';
import { IconButton } from '@toeverything/components/button'; import { IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import type { ComponentType, PropsWithChildren, ReactElement } from 'react'; import type { ComponentType, PropsWithChildren, ReactElement } from 'react';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
@@ -18,7 +18,7 @@ export const HeaderItem = ({
const pushLayout = useSetAtom(pushLayoutAtom); const pushLayout = useSetAtom(pushLayoutAtom);
const deleteLayout = useSetAtom(deleteLayoutAtom); const deleteLayout = useSetAtom(deleteLayoutAtom);
return ( return (
<Tooltip content="Chat with AI" placement="bottom-end"> <Tooltip content="Chat with AI" side="bottom">
<IconButton <IconButton
onClick={useCallback(() => { onClick={useCallback(() => {
if (!open) { if (!open) {

View File

@@ -18,7 +18,7 @@
"@affine/component": "workspace:*", "@affine/component": "workspace:*",
"@affine/sdk": "workspace:*", "@affine/sdk": "workspace:*",
"@blocksuite/icons": "^2.1.31", "@blocksuite/icons": "^2.1.31",
"@toeverything/components": "^0.0.17" "@toeverything/components": "^0.0.19"
}, },
"devDependencies": { "devDependencies": {
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"

View File

@@ -1,6 +1,6 @@
import { Tooltip } from '@affine/component';
import { Logo1Icon } from '@blocksuite/icons'; import { Logo1Icon } from '@blocksuite/icons';
import { IconButton } from '@toeverything/components/button'; import { IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useCallback } from 'react'; import { useCallback } from 'react';
export const HeaderItem = () => { export const HeaderItem = () => {

View File

@@ -17,7 +17,7 @@
"@affine/component": "workspace:*", "@affine/component": "workspace:*",
"@affine/sdk": "workspace:*", "@affine/sdk": "workspace:*",
"@blocksuite/icons": "^2.1.31", "@blocksuite/icons": "^2.1.31",
"@toeverything/components": "^0.0.17", "@toeverything/components": "^0.0.19",
"@toeverything/theme": "^0.7.12", "@toeverything/theme": "^0.7.12",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"foxact": "^0.2.20", "foxact": "^0.2.20",

View File

@@ -1,4 +1,3 @@
import { Tooltip } from '@affine/component';
import type { ImageBlockModel } from '@blocksuite/blocks'; import type { ImageBlockModel } from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { import {
@@ -13,6 +12,7 @@ import {
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import type { Workspace } from '@blocksuite/store'; import type { Workspace } from '@blocksuite/store';
import { Button, IconButton } from '@toeverything/components/button'; import { Button, IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import clsx from 'clsx'; import clsx from 'clsx';
import { useErrorBoundary } from 'foxact/use-error-boundary'; import { useErrorBoundary } from 'foxact/use-error-boundary';
import { useAtom } from 'jotai'; import { useAtom } from 'jotai';
@@ -336,7 +336,7 @@ const ImagePreviewModalImpl = (
) : null} ) : null}
<div className={imagePreviewActionBarStyle}> <div className={imagePreviewActionBarStyle}>
<div> <div>
<Tooltip content={'Previous'} placement={'top'} showArrow={true}> <Tooltip content={'Previous'}>
<IconButton <IconButton
data-testid="previous-image-button" data-testid="previous-image-button"
icon={<ArrowLeftSmallIcon />} icon={<ArrowLeftSmallIcon />}
@@ -348,7 +348,7 @@ const ImagePreviewModalImpl = (
}} }}
/> />
</Tooltip> </Tooltip>
<Tooltip content={'Next'} placement={'top'} showArrow={true}> <Tooltip content={'Next'}>
<IconButton <IconButton
data-testid="next-image-button" data-testid="next-image-button"
icon={<ArrowRightSmallIcon />} icon={<ArrowRightSmallIcon />}
@@ -362,7 +362,7 @@ const ImagePreviewModalImpl = (
</Tooltip> </Tooltip>
</div> </div>
<div className={groupStyle}></div> <div className={groupStyle}></div>
<Tooltip content={'Fit to Screen'} placement={'top'} showArrow={true}> <Tooltip content={'Fit to Screen'}>
<IconButton <IconButton
data-testid="fit-to-screen-button" data-testid="fit-to-screen-button"
icon={<ViewBarIcon />} icon={<ViewBarIcon />}
@@ -371,7 +371,7 @@ const ImagePreviewModalImpl = (
onClick={() => resetZoom()} onClick={() => resetZoom()}
/> />
</Tooltip> </Tooltip>
<Tooltip content={'Zoom out'} placement={'top'} showArrow={true}> <Tooltip content={'Zoom out'}>
<IconButton <IconButton
data-testid="zoom-out-button" data-testid="zoom-out-button"
icon={<MinusIcon />} icon={<MinusIcon />}
@@ -380,7 +380,7 @@ const ImagePreviewModalImpl = (
onClick={zoomOut} onClick={zoomOut}
/> />
</Tooltip> </Tooltip>
<Tooltip content={'Reset Scale'} placement={'top'} showArrow={true}> <Tooltip content={'Reset Scale'}>
<Button <Button
data-testid="reset-scale-button" data-testid="reset-scale-button"
type="plain" type="plain"
@@ -391,7 +391,7 @@ const ImagePreviewModalImpl = (
{`${(currentScale * 100).toFixed(0)}%`} {`${(currentScale * 100).toFixed(0)}%`}
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip content={'Zoom in'} placement={'top'} showArrow={true}> <Tooltip content={'Zoom in'}>
<IconButton <IconButton
data-testid="zoom-in-button" data-testid="zoom-in-button"
icon={<PlusIcon />} icon={<PlusIcon />}
@@ -401,7 +401,7 @@ const ImagePreviewModalImpl = (
/> />
</Tooltip> </Tooltip>
<div className={groupStyle}></div> <div className={groupStyle}></div>
<Tooltip content={'Download'} placement={'top'} showArrow={true}> <Tooltip content={'Download'}>
<IconButton <IconButton
data-testid="download-button" data-testid="download-button"
icon={<DownloadIcon />} icon={<DownloadIcon />}
@@ -415,11 +415,7 @@ const ImagePreviewModalImpl = (
}} }}
/> />
</Tooltip> </Tooltip>
<Tooltip <Tooltip content={'Copy to clipboard'}>
content={'Copy to clipboard'}
placement={'top'}
showArrow={true}
>
<IconButton <IconButton
data-testid="copy-to-clipboard-button" data-testid="copy-to-clipboard-button"
icon={<CopyIcon />} icon={<CopyIcon />}
@@ -460,7 +456,7 @@ const ImagePreviewModalImpl = (
/> />
</Tooltip> </Tooltip>
<div className={groupStyle}></div> <div className={groupStyle}></div>
<Tooltip content={'Delete'} placement={'top'} showArrow={true}> <Tooltip content={'Delete'}>
<IconButton <IconButton
data-testid="delete-button" data-testid="delete-button"
icon={<DeleteIcon />} icon={<DeleteIcon />}

View File

@@ -18,7 +18,7 @@
"@affine/component": "workspace:*", "@affine/component": "workspace:*",
"@affine/sdk": "workspace:*", "@affine/sdk": "workspace:*",
"@blocksuite/icons": "^2.1.31", "@blocksuite/icons": "^2.1.31",
"@toeverything/components": "^0.0.17" "@toeverything/components": "^0.0.19"
}, },
"devDependencies": { "devDependencies": {
"@affine/plugin-cli": "workspace:*", "@affine/plugin-cli": "workspace:*",

View File

@@ -1,4 +1,3 @@
import { Tooltip } from '@affine/component';
import { import {
currentPageAtom, currentPageAtom,
deleteLayoutAtom, deleteLayoutAtom,
@@ -8,6 +7,7 @@ import { TOCNotesPanel } from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { RightSidebarIcon } from '@blocksuite/icons'; import { RightSidebarIcon } from '@blocksuite/icons';
import { IconButton } from '@toeverything/components/button'; import { IconButton } from '@toeverything/components/button';
import { Tooltip } from '@toeverything/components/tooltip';
import { useAtomValue, useSetAtom } from 'jotai'; import { useAtomValue, useSetAtom } from 'jotai';
import type { ComponentType, PropsWithChildren } from 'react'; import type { ComponentType, PropsWithChildren } from 'react';
import { useCallback, useRef, useState } from 'react'; import { useCallback, useRef, useState } from 'react';

View File

@@ -196,7 +196,7 @@ __metadata:
"@affine/component": "workspace:*" "@affine/component": "workspace:*"
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@toeverything/components": ^0.0.17 "@toeverything/components": ^0.0.19
"@types/marked": ^5.0.1 "@types/marked": ^5.0.1
idb: ^7.1.1 idb: ^7.1.1
jotai: ^2.4.0 jotai: ^2.4.0
@@ -246,7 +246,7 @@ __metadata:
"@sentry/webpack-plugin": ^2.7.0 "@sentry/webpack-plugin": ^2.7.0
"@svgr/webpack": ^8.1.0 "@svgr/webpack": ^8.1.0
"@swc/core": ^1.3.80 "@swc/core": ^1.3.80
"@toeverything/components": ^0.0.17 "@toeverything/components": ^0.0.19
"@types/lodash.debounce": ^4.0.7 "@types/lodash.debounce": ^4.0.7
"@types/webpack-env": ^1.18.1 "@types/webpack-env": ^1.18.1
async-call-rpc: ^6.3.1 async-call-rpc: ^6.3.1
@@ -417,7 +417,7 @@ __metadata:
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@blocksuite/icons": ^2.1.31 "@blocksuite/icons": ^2.1.31
"@toeverything/components": ^0.0.17 "@toeverything/components": ^0.0.19
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -443,7 +443,7 @@ __metadata:
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@blocksuite/icons": ^2.1.31 "@blocksuite/icons": ^2.1.31
"@toeverything/components": ^0.0.17 "@toeverything/components": ^0.0.19
"@toeverything/theme": ^0.7.12 "@toeverything/theme": ^0.7.12
clsx: ^2.0.0 clsx: ^2.0.0
foxact: ^0.2.20 foxact: ^0.2.20
@@ -562,7 +562,7 @@ __metadata:
"@affine/plugin-cli": "workspace:*" "@affine/plugin-cli": "workspace:*"
"@affine/sdk": "workspace:*" "@affine/sdk": "workspace:*"
"@blocksuite/icons": ^2.1.31 "@blocksuite/icons": ^2.1.31
"@toeverything/components": ^0.0.17 "@toeverything/components": ^0.0.19
jotai: ^2.4.0 jotai: ^2.4.0
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0 react-dom: 18.2.0
@@ -9137,6 +9137,37 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@radix-ui/react-tooltip@npm:^1.0.6":
version: 1.0.6
resolution: "@radix-ui/react-tooltip@npm:1.0.6"
dependencies:
"@babel/runtime": ^7.13.10
"@radix-ui/primitive": 1.0.1
"@radix-ui/react-compose-refs": 1.0.1
"@radix-ui/react-context": 1.0.1
"@radix-ui/react-dismissable-layer": 1.0.4
"@radix-ui/react-id": 1.0.1
"@radix-ui/react-popper": 1.1.2
"@radix-ui/react-portal": 1.0.3
"@radix-ui/react-presence": 1.0.1
"@radix-ui/react-primitive": 1.0.3
"@radix-ui/react-slot": 1.0.2
"@radix-ui/react-use-controllable-state": 1.0.1
"@radix-ui/react-visually-hidden": 1.0.3
peerDependencies:
"@types/react": "*"
"@types/react-dom": "*"
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
peerDependenciesMeta:
"@types/react":
optional: true
"@types/react-dom":
optional: true
checksum: 8220f103432e9ad9ff8a828ca890e14bf3323864a0bb145d1ef689cf446ab5ca0af18e5fed5da89db957065c504e79ec12fbe5e551d6e7b84b470fbd672c918d
languageName: node
linkType: hard
"@radix-ui/react-use-callback-ref@npm:1.0.0": "@radix-ui/react-use-callback-ref@npm:1.0.0":
version: 1.0.0 version: 1.0.0
resolution: "@radix-ui/react-use-callback-ref@npm:1.0.0" resolution: "@radix-ui/react-use-callback-ref@npm:1.0.0"
@@ -11700,17 +11731,18 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@toeverything/components@npm:^0.0.17": "@toeverything/components@npm:^0.0.19":
version: 0.0.17 version: 0.0.19
resolution: "@toeverything/components@npm:0.0.17" resolution: "@toeverything/components@npm:0.0.19"
dependencies: dependencies:
"@blocksuite/icons": ^2.1.30 "@blocksuite/icons": ^2.1.30
"@radix-ui/react-tooltip": ^1.0.6
peerDependencies: peerDependencies:
"@radix-ui/react-avatar": ^1 "@radix-ui/react-avatar": ^1
clsx: ^2 clsx: ^2
react: ^18 react: ^18
react-dom: ^18 react-dom: ^18
checksum: 3dc1eb4a8f7aebc8423f7ac1dda0f51db892ea25922b0c8b2d5f81bd987030fac796ac6950f364d3591e68ee3b19cf80bf0add02ecaff631c920a32440e1981b checksum: 705bd025d958866b4615348cd6b127e305fd8c0a837a024da82fda2f5dad8d9aaa26f939956ec52bfca404fa2086cc15d6ae08b2eb75e26db2651798c1bfe766
languageName: node languageName: node
linkType: hard linkType: hard