refactor: migrate all antd Tooltip components to HeroUI Tooltip (#10295)
* refactor: migrate tooltip components to @cherrystudio/ui - Replace all antd Tooltip + InfoCircleOutlined patterns with InfoTooltip component - Replace all antd Tooltip + QuestionCircleOutlined patterns with HelpTooltip component - Migrate all WarnTooltip imports to @cherrystudio/ui - Add onClick support to InfoTooltip and HelpTooltip components - Remove local tooltip components from renderer - Update eslint config to restrict antd Tooltip imports - Clean up unused imports and styled components 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: replace tooltip * fix: yarn format * fix: type check * Update QuickModelPopup.tsx * fix: yarn test * fix: ci error * Update TabContainer.tsx * fix: ci error * fix: ci error * fix: issue * fix: ci * fix: again * refactor(ui): replace Tooltip title prop with content for consistency * refactor(Tooltip): improve Tooltip component by extending props and simplifying implementation - Extend TooltipProps from HeroUITooltipProps instead of redefining - Remove redundant props and use spread operator for classNames - Export TooltipProps type for better type support * refactor(HelpTooltip): rename title prop to content and simplify component Update HelpTooltip component to use TooltipProps interface and rename title prop to content for consistency Update all instances where HelpTooltip is used to reflect the prop name change * refactor(IconTooltips): consolidate tooltip components into unified module Move HelpTooltip, InfoTooltip, and WarnTooltip into a single IconTooltips directory with shared types Update exports in components index to use new module structure * refactor(tooltip): update InfoTooltip prop from title to content and simplify component Consolidate tooltip props interface and update all instances to use content prop instead of title for consistency. Remove redundant interface definitions and simplify InfoTooltip component implementation. * refactor(ui): rename WarnTooltip prop from title to content for consistency Update all instances of WarnTooltip component to use content prop instead of title for better consistency with Tooltip component interface. Also simplify the component props by extending IconTooltipProps type. * fix(tooltip): update tooltip usage - Replace deprecated props like `mouseEnterDelay` and `mouseLeaveDelay` with `delay` and `closeDelay` - Rename `arrow` prop to `showArrow` for better semantics - Update styling props to use `classNames` instead of inline styles - Remove unnecessary props like `fresh` and `destroyOnHidden` * refactor(components): remove redundant placement="top" from Tooltip components The placement="top" prop was removed from all Tooltip components since it's the default value and redundant. This change improves code cleanliness without affecting functionality. * fix(HeaderNavbar): add tooltip placement for sidebar toggle buttons * fix(ui): add delay to tooltip components for better user experience * refactor(tooltip): adjust tooltip behavior and styling across components - Remove default delay values from base Tooltip component - Add delay and closeDelay props to specific tooltip instances - Fix tooltip compatibility issue with Antd Dropdown - Adjust tooltip placement and styling in various components * fix(ui): set closeDelay to 0 for Tooltip components to improve responsiveness Prevent tooltip delay from causing poor user experience by making them close immediately when mouse leaves the element * refactor(ui): remove redundant tooltip placement prop The 'placement="top"' prop was removed from Tooltip components as it's the default value and doesn't need to be explicitly set. * fix(ui): adjust tooltip delays for better user experience - Set consistent default delay of 1000ms for window controls - Increase delay for sidebar toggle tooltips to 2000ms - Adjust various message action tooltip delays between 600-1200ms * fix(SelectModelPopup): add delay props to provider settings tooltip Add delay and closeDelay props to Tooltip component to improve user experience by preventing accidental triggers * style(HelpTooltip): add cursor help style to improve UX * fix(components): add tooltip delay and placement props for better UX Add delay prop to CustomTag and ModelIdWithTags tooltips to prevent flickering Set placement prop for LocalBackupManager tooltip to top-start Add closeDelay prop to HelpTooltip in SaveToKnowledgePopup for immediate closing * refactor(ModelSelectButton): simplify tooltip props by using TooltipProps type Replace individual tooltip placement props with TooltipProps type from ui library for better maintainability * fix(ui): remove tooltip close delay for better user experience * docs(tooltip): add jsdoc comments explaining tooltip wrapper behavior * refactor(Tooltip): clarify showArrow prop * fix(Inputbar): set closeDelay to 0 for pause tooltip to improve UX Prevent tooltip from staying visible after interaction by removing the close delay * style(InputbarTools): improve tooltip consistency and css formatting - Add closeDelay to new topic tooltip for consistency - Remove redundant line breaks in tooltip props - Format css transition properties for better readability * chore: add tailwindCSS class attributes to vscode settings * fix(tooltips): improve tooltip behavior and styling across components - Add closeDelay=0 to most tooltips for instant closing - Add custom styling to CitationTooltip and ChatFlowHistory tooltips - Adjust delay times for navigation tooltips - Remove conflicting Tooltip wrappers around Popconfirm actions * refactor(ui): adjust tooltip delays and placements across components - Remove redundant isOpen prop from CustomNode tooltip - Standardize tooltip delays and placements in MessageGroupMenuBar, MessageTokens, ChatNavbar - Simplify tooltip wrapper structure in HeaderNavbar - Add consistent tooltip delays in MessageGroupModelList - Set tooltip placements in MinimalToolbar * refactor(Tooltip): enhance tooltip structure and props - Add className prop to Tooltip component for better customization - Wrap children in a div with relative positioning to improve layout * refactor(Tooltip): enhance props structure for improved customization - Update Tooltip component to allow optional classNames with a placeholder property - Modify child wrapper to utilize classNames for better styling control * refactor(IconTooltips): consolidate icon props into single iconProps object Replace individual icon styling props (iconColor, iconSize, iconStyle) with a unified iconProps object using LucideProps type. This simplifies the component API and improves maintainability by using a standardized props structure across all icon tooltip components. * feat(JoplinSettings): add help button to open Joplin documentation Add a help button in Joplin settings that opens the official Joplin documentation in a minapp popup when clicked. This provides users with quick access to Joplin's help resources. * feat(NotionSettings): add help link click handler for notion title Add click handler to open help documentation when clicking on Notion title in settings * feat(S3Settings): add help link to S3 settings title Add click handler to open documentation for S3 settings when title is clicked * feat(settings): add help button for siyuan integration Add click handler to open help documentation for siyuan integration settings * feat(yuque-settings): add help button to open yuque token guide Add a help button in Yuque settings that opens a minapp popup with Yuque's token guide. This helps users easily access documentation for generating API tokens. * fix(ui): adjust tooltip delay settings for better user experience Set closeDelay to 0 for reset button tooltip to prevent lingering Add delay of 500ms for api key list tooltip to avoid accidental triggers * fix(ModelList): set closeDelay to 0 for all Tooltip components Prevent tooltips from staying open longer than necessary by immediately closing them on mouse leave * fix(ui): improve tooltip placement and delay settings adjust tooltip placement and delay for better user experience * refactor(tests): update tooltip mock implementation and snapshots - Consolidate tooltip mock to handle both title and content props - Remove deprecated placement attributes from snapshots - Clean up test tooltip content assertions * refactor: remove unnecessary whitespace and simplify tooltip components clean up code by removing redundant whitespace and simplifying tooltip component usage across multiple files --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: icarus <eurfelux@gmail.com> Co-authored-by: MyPrototypeWhat <daoquqiexing@gmail.com>
This commit is contained in:
@@ -10,14 +10,7 @@ interface EmojiAvatarProps {
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
const EmojiAvatar = ({
|
||||
children,
|
||||
size = 31,
|
||||
fontSize,
|
||||
onClick,
|
||||
className,
|
||||
style
|
||||
}: EmojiAvatarProps) => (
|
||||
const EmojiAvatar = ({ children, size = 31, fontSize, onClick, className, style }: EmojiAvatarProps) => (
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
@@ -40,4 +33,4 @@ const EmojiAvatar = ({
|
||||
|
||||
EmojiAvatar.displayName = 'EmojiAvatar'
|
||||
|
||||
export default memo(EmojiAvatar)
|
||||
export default memo(EmojiAvatar)
|
||||
|
||||
@@ -76,7 +76,7 @@ const CustomTag: FC<CustomTagProps> = ({
|
||||
)
|
||||
|
||||
return tooltip ? (
|
||||
<Tooltip content={tooltip} placement="top" delay={300}>
|
||||
<Tooltip content={tooltip} delay={300}>
|
||||
{tagContent}
|
||||
</Tooltip>
|
||||
) : (
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { TooltipProps as HeroUITooltipProps } from '@heroui/react'
|
||||
import { cn, Tooltip as HeroUITooltip } from '@heroui/react'
|
||||
|
||||
export interface TooltipProps extends HeroUITooltipProps {}
|
||||
|
||||
/**
|
||||
* Tooltip wrapper that applies consistent styling and arrow display.
|
||||
* Differences from raw HeroUI Tooltip:
|
||||
* 1. Defaults showArrow={true}
|
||||
* 2. Merges a default max-w-60 class into the content slot, capping width at 240px.
|
||||
* All other HeroUI Tooltip props/behaviors remain unchanged.
|
||||
*
|
||||
* @see https://www.heroui.com/docs/components/tooltip
|
||||
*/
|
||||
export const Tooltip = ({
|
||||
children,
|
||||
classNames,
|
||||
showArrow,
|
||||
...rest
|
||||
}: Omit<TooltipProps, 'classNames'> & {
|
||||
classNames?: TooltipProps['classNames'] & { placeholder?: string }
|
||||
}) => {
|
||||
return (
|
||||
<HeroUITooltip
|
||||
classNames={{
|
||||
...classNames,
|
||||
content: cn('max-w-60', classNames?.content)
|
||||
}}
|
||||
showArrow={showArrow ?? true}
|
||||
{...rest}>
|
||||
<div className={cn('relative z-10', classNames?.placeholder)}>{children}</div>
|
||||
</HeroUITooltip>
|
||||
)
|
||||
}
|
||||
@@ -43,7 +43,7 @@ const ListItem = ({
|
||||
<div className="flex items-center gap-0.5 overflow-hidden text-xs">
|
||||
{icon && <span className="flex items-center justify-center mr-2">{icon}</span>}
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
<Tooltip content={title} placement="top">
|
||||
<Tooltip content={title}>
|
||||
<div className="truncate text-gray-900 dark:text-gray-100" style={titleStyle}>
|
||||
{title}
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ToolsCallingIconProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
const ToolsCallingIcon = ({ className, iconClassName, TooltipProps, ...props }: ToolsCallingIconProps) => {
|
||||
return (
|
||||
<div className={cn('flex justify-center items-center', className)} {...props}>
|
||||
<Tooltip placement="top" {...TooltipProps}>
|
||||
<Tooltip {...TooltipProps}>
|
||||
<Wrench className={cn('w-4 h-4 mr-1.5 text-[#00b96b]', iconClassName)} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,7 @@ export { ErrorTag, InfoTag, StatusTag, SuccessTag, WarnTag } from './base/Status
|
||||
export { DescriptionSwitch, Switch } from './base/Switch'
|
||||
export { default as TextBadge } from './base/TextBadge'
|
||||
export { getToastUtilities, type ToastUtilities } from './base/Toast'
|
||||
export { Tooltip, type TooltipProps } from './base/Tooltip'
|
||||
|
||||
// Display Components
|
||||
export { default as Ellipsis } from './display/Ellipsis'
|
||||
@@ -80,15 +81,12 @@ export { DraggableList, useDraggableReorder } from './interactive/DraggableList'
|
||||
export type { EditableNumberProps } from './interactive/EditableNumber'
|
||||
// EditableNumber
|
||||
export { default as EditableNumber } from './interactive/EditableNumber'
|
||||
export { default as HelpTooltip } from './interactive/HelpTooltip'
|
||||
// Tooltip variants
|
||||
export { HelpTooltip, type IconTooltipProps, InfoTooltip, WarnTooltip } from './interactive/IconTooltips'
|
||||
// ImageToolButton
|
||||
export { default as ImageToolButton } from './interactive/ImageToolButton'
|
||||
// InfoTooltip
|
||||
export { default as InfoTooltip } from './interactive/InfoTooltip'
|
||||
// Sortable
|
||||
export { Sortable } from './interactive/Sortable'
|
||||
// WarnTooltip
|
||||
export { default as WarnTooltip } from './interactive/WarnTooltip'
|
||||
|
||||
// Composite Components (复合组件)
|
||||
// 暂无复合组件
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// Original path: src/renderer/src/components/CollapsibleSearchBar.tsx
|
||||
import type { InputRef } from 'antd'
|
||||
import { Input, Tooltip } from 'antd'
|
||||
import { Input } from 'antd'
|
||||
import { Search } from 'lucide-react'
|
||||
import { motion } from 'motion/react'
|
||||
import React, { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { Tooltip } from '../../base/Tooltip'
|
||||
|
||||
interface CollapsibleSearchBarProps {
|
||||
onSearch: (text: string) => void
|
||||
placeholder?: string
|
||||
@@ -93,7 +95,7 @@ const CollapsibleSearchBar = ({
|
||||
}}
|
||||
style={{ cursor: 'pointer', display: 'flex' }}
|
||||
onClick={() => setSearchVisible(true)}>
|
||||
<Tooltip title={tooltip} mouseEnterDelay={0.5} mouseLeaveDelay={0}>
|
||||
<Tooltip content={tooltip} delay={500} closeDelay={0}>
|
||||
{icon}
|
||||
</Tooltip>
|
||||
</motion.div>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Scrollbar } from '@cherrystudio/ui'
|
||||
import type {
|
||||
DroppableProps,
|
||||
DropResult,
|
||||
@@ -10,6 +9,7 @@ import { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd'
|
||||
import { type ScrollToOptions, useVirtualizer, type VirtualItem } from '@tanstack/react-virtual'
|
||||
import { type Key, memo, useCallback, useImperativeHandle, useRef } from 'react'
|
||||
|
||||
import Scrollbar from '../../layout/Scrollbar'
|
||||
import { droppableReorder } from './sort'
|
||||
|
||||
export interface DraggableVirtualListRef {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Original path: src/renderer/src/components/TooltipIcons/HelpTooltip.tsx
|
||||
import type { TooltipProps } from 'antd'
|
||||
import { Tooltip } from 'antd'
|
||||
import { HelpCircle } from 'lucide-react'
|
||||
|
||||
type InheritedTooltipProps = Omit<TooltipProps, 'children'>
|
||||
|
||||
interface HelpTooltipProps extends InheritedTooltipProps {
|
||||
iconColor?: string
|
||||
iconSize?: string | number
|
||||
iconStyle?: React.CSSProperties
|
||||
}
|
||||
|
||||
const HelpTooltip = ({ iconColor = 'var(--color-text-2)', iconSize = 14, iconStyle, ...rest }: HelpTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<HelpCircle size={iconSize} color={iconColor} style={{ ...iconStyle }} role="img" aria-label="Help" />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export default HelpTooltip
|
||||
@@ -0,0 +1,19 @@
|
||||
// Original path: src/renderer/src/components/TooltipIcons/HelpTooltip.tsx
|
||||
import { HelpCircle } from 'lucide-react'
|
||||
|
||||
import { Tooltip } from '../../base/Tooltip'
|
||||
import type { IconTooltipProps } from './types'
|
||||
|
||||
export const HelpTooltip = ({ iconProps, ...rest }: IconTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<HelpCircle
|
||||
size={iconProps?.size ?? 14}
|
||||
color={iconProps?.color ?? 'var(--color-text-2)'}
|
||||
role="img"
|
||||
aria-label="Help"
|
||||
{...iconProps}
|
||||
/>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Original: src/renderer/src/components/TooltipIcons/InfoTooltip.tsx
|
||||
import { Info } from 'lucide-react'
|
||||
|
||||
import { Tooltip } from '../../base/Tooltip'
|
||||
import type { IconTooltipProps } from './types'
|
||||
|
||||
export const InfoTooltip = ({ iconProps, ...rest }: IconTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<Info
|
||||
size={iconProps?.size ?? 14}
|
||||
color={iconProps?.color ?? 'var(--color-text-2)'}
|
||||
role="img"
|
||||
aria-label="Information"
|
||||
{...iconProps}
|
||||
/>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Original path: src/renderer/src/components/TooltipIcons/WarnTooltip.tsx
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
|
||||
import { Tooltip } from '../../base/Tooltip'
|
||||
import type { IconTooltipProps } from './types'
|
||||
|
||||
export const WarnTooltip = ({ iconProps, ...rest }: IconTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<AlertTriangle
|
||||
size={iconProps?.size ?? 14}
|
||||
color={iconProps?.color ?? 'var(--color-status-warning)'}
|
||||
role="img"
|
||||
aria-label="Warning"
|
||||
{...iconProps}
|
||||
/>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export { HelpTooltip } from './HelpTooltip'
|
||||
export { InfoTooltip } from './InfoTooltip'
|
||||
export type { IconTooltipProps } from './types'
|
||||
export { WarnTooltip } from './WarnTooltip'
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { LucideProps } from 'lucide-react'
|
||||
|
||||
import type { TooltipProps } from '../../base/Tooltip'
|
||||
|
||||
export interface IconTooltipProps extends TooltipProps {
|
||||
iconProps?: LucideProps
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
// Original path: src/renderer/src/components/Preview/ImageToolButton.tsx
|
||||
import { Button } from '@cherrystudio/ui'
|
||||
import { Tooltip } from 'antd'
|
||||
import { memo } from 'react'
|
||||
|
||||
import Button from '../../base/Button'
|
||||
import { Tooltip } from '../../base/Tooltip'
|
||||
|
||||
interface ImageToolButtonProps {
|
||||
tooltip: string
|
||||
icon: React.ReactNode
|
||||
@@ -11,7 +12,7 @@ interface ImageToolButtonProps {
|
||||
|
||||
const ImageToolButton = ({ tooltip, icon, onPress }: ImageToolButtonProps) => {
|
||||
return (
|
||||
<Tooltip title={tooltip} mouseEnterDelay={0.5} mouseLeaveDelay={0}>
|
||||
<Tooltip content={tooltip} delay={500} closeDelay={0}>
|
||||
<Button radius="full" isIconOnly onPress={onPress} aria-label={tooltip}>
|
||||
{icon}
|
||||
</Button>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Original: src/renderer/src/components/TooltipIcons/InfoTooltip.tsx
|
||||
import type { TooltipProps } from 'antd'
|
||||
import { Tooltip } from 'antd'
|
||||
import { Info } from 'lucide-react'
|
||||
|
||||
type InheritedTooltipProps = Omit<TooltipProps, 'children'>
|
||||
|
||||
interface InfoTooltipProps extends InheritedTooltipProps {
|
||||
iconColor?: string
|
||||
iconSize?: string | number
|
||||
iconStyle?: React.CSSProperties
|
||||
}
|
||||
|
||||
const InfoTooltip = ({ iconColor = 'var(--color-text-2)', iconSize = 14, iconStyle, ...rest }: InfoTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<Info size={iconSize} color={iconColor} style={{ ...iconStyle }} role="img" aria-label="Information" />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export default InfoTooltip
|
||||
@@ -1,27 +0,0 @@
|
||||
// Original path: src/renderer/src/components/TooltipIcons/WarnTooltip.tsx
|
||||
import type { TooltipProps } from 'antd'
|
||||
import { Tooltip } from 'antd'
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
|
||||
type InheritedTooltipProps = Omit<TooltipProps, 'children'>
|
||||
|
||||
interface WarnTooltipProps extends InheritedTooltipProps {
|
||||
iconColor?: string
|
||||
iconSize?: string | number
|
||||
iconStyle?: React.CSSProperties
|
||||
}
|
||||
|
||||
const WarnTooltip = ({
|
||||
iconColor = 'var(--color-status-warning)',
|
||||
iconSize = 14,
|
||||
iconStyle,
|
||||
...rest
|
||||
}: WarnTooltipProps) => {
|
||||
return (
|
||||
<Tooltip {...rest}>
|
||||
<AlertTriangle size={iconSize} color={iconColor} style={{ ...iconStyle }} role="img" aria-label="Information" />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export default WarnTooltip
|
||||
Reference in New Issue
Block a user