feat: add icon hover effect

This commit is contained in:
Joel
2025-06-26 16:18:50 +08:00
parent 3e047a1c71
commit 26f32b6176
2 changed files with 17 additions and 4 deletions

View File

@ -18,6 +18,7 @@ export type AppIconProps = {
imageUrl?: string | null
className?: string
innerIcon?: React.ReactNode
coverElement?: React.ReactNode
onClick?: () => void
}
const appIconVariants = cva(
@ -51,6 +52,7 @@ const AppIcon: FC<AppIconProps> = ({
imageUrl,
className,
innerIcon,
coverElement,
onClick,
}) => {
const isValidImageIcon = iconType === 'image' && imageUrl
@ -65,6 +67,7 @@ const AppIcon: FC<AppIconProps> = ({
? <img src={imageUrl} className="h-full w-full" alt="app icon" />
: (innerIcon || ((icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id='🤖' />))
}
{coverElement}
</span>
}

View File

@ -1,8 +1,8 @@
'use client'
import React, { useState } from 'react'
import React, { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getDomain } from 'tldts'
import { RiCloseLine } from '@remixicon/react'
import { RiCloseLine, RiEditLine } from '@remixicon/react'
import AppIconPicker from '@/app/components/base/app-icon-picker'
import type { AppIconSelection } from '@/app/components/base/app-icon-picker'
import AppIcon from '@/app/components/base/app-icon'
@ -15,6 +15,7 @@ import { noop } from 'lodash-es'
import Toast from '@/app/components/base/toast'
import { uploadRemoteFileInfo } from '@/service/common'
import cn from '@/utils/classnames'
import { useHover } from 'ahooks'
export type DuplicateAppModalProps = {
data?: ToolWithProvider
@ -62,6 +63,8 @@ const MCPModal = ({
const [showAppIconPicker, setShowAppIconPicker] = useState(false)
const [serverIdentifier, setServerIdentifier] = React.useState(data?.server_identifier || '')
const [isFetchingIcon, setIsFetchingIcon] = useState(false)
const appIconRef = useRef<HTMLDivElement>(null)
const isHovering = useHover(appIconRef)
const isValidUrl = (string: string) => {
try {
@ -157,13 +160,20 @@ const MCPModal = ({
placeholder={t('tools.mcp.modal.namePlaceholder')}
/>
</div>
<div className='pt-2'>
<div className='pt-2' ref={appIconRef}>
<AppIcon
iconType={appIcon.type}
icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
background={appIcon.type === 'emoji' ? appIcon.background : undefined}
imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
size='xxl' className='cursor-pointer rounded-2xl'
size='xxl'
className='relative cursor-pointer rounded-2xl'
coverElement={
isHovering
? (<div className='absolute inset-0 flex items-center justify-center overflow-hidden rounded-2xl bg-background-overlay-alt'>
<RiEditLine className='size-6 text-text-primary-on-surface' />
</div>) : null
}
onClick={() => { setShowAppIconPicker(true) }}
/>
</div>