feat: add icon hover effect

pull/22091/head
Joel 11 months ago
parent 3e047a1c71
commit 26f32b6176

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

@ -1,8 +1,8 @@
'use client' 'use client'
import React, { useState } from 'react' import React, { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { getDomain } from 'tldts' 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 AppIconPicker from '@/app/components/base/app-icon-picker'
import type { AppIconSelection } 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' 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 Toast from '@/app/components/base/toast'
import { uploadRemoteFileInfo } from '@/service/common' import { uploadRemoteFileInfo } from '@/service/common'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useHover } from 'ahooks'
export type DuplicateAppModalProps = { export type DuplicateAppModalProps = {
data?: ToolWithProvider data?: ToolWithProvider
@ -62,6 +63,8 @@ const MCPModal = ({
const [showAppIconPicker, setShowAppIconPicker] = useState(false) const [showAppIconPicker, setShowAppIconPicker] = useState(false)
const [serverIdentifier, setServerIdentifier] = React.useState(data?.server_identifier || '') const [serverIdentifier, setServerIdentifier] = React.useState(data?.server_identifier || '')
const [isFetchingIcon, setIsFetchingIcon] = useState(false) const [isFetchingIcon, setIsFetchingIcon] = useState(false)
const appIconRef = useRef<HTMLDivElement>(null)
const isHovering = useHover(appIconRef)
const isValidUrl = (string: string) => { const isValidUrl = (string: string) => {
try { try {
@ -157,13 +160,20 @@ const MCPModal = ({
placeholder={t('tools.mcp.modal.namePlaceholder')} placeholder={t('tools.mcp.modal.namePlaceholder')}
/> />
</div> </div>
<div className='pt-2'> <div className='pt-2' ref={appIconRef}>
<AppIcon <AppIcon
iconType={appIcon.type} iconType={appIcon.type}
icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId} icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
background={appIcon.type === 'emoji' ? appIcon.background : undefined} background={appIcon.type === 'emoji' ? appIcon.background : undefined}
imageUrl={appIcon.type === 'image' ? appIcon.url : 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) }} onClick={() => { setShowAppIconPicker(true) }}
/> />
</div> </div>

Loading…
Cancel
Save