| | |
| | | 'use client' |
| | | import React, { useState } from 'react' |
| | | import { useTranslation } from 'react-i18next' |
| | | import { |
| | | RiClipboardFill, |
| | | RiClipboardLine, |
| | | } from '@remixicon/react' |
| | | import { debounce } from 'lodash-es' |
| | | import copy from 'copy-to-clipboard' |
| | | import copyStyle from './style.module.css' |
| | | import Tooltip from '@/app/components/base/tooltip' |
| | | import ActionButton from '@/app/components/base/action-button' |
| | | |
| | | type Props = { |
| | | content: string |
| | |
| | | |
| | | const prefixEmbedded = 'appOverview.overview.appInfo.embedded' |
| | | |
| | | const CopyFeedback = ({ content }: Props) => { |
| | | const CopyFeedback = ({ content, className }: Props) => { |
| | | const { t } = useTranslation() |
| | | const [isCopied, setIsCopied] = useState<boolean>(false) |
| | | |
| | |
| | | : t(`${prefixEmbedded}.copy`)) || '' |
| | | } |
| | | > |
| | | <ActionButton> |
| | | <div |
| | | className={`w-8 h-8 cursor-pointer hover:bg-gray-100 rounded-lg ${ |
| | | className ?? '' |
| | | }`} |
| | | > |
| | | <div |
| | | onClick={onClickCopy} |
| | | onMouseLeave={onMouseLeave} |
| | | > |
| | | {isCopied && <RiClipboardFill className='h-4 w-4' />} |
| | | {!isCopied && <RiClipboardLine className='h-4 w-4' />} |
| | | </div> |
| | | </ActionButton> |
| | | className={`w-full h-full ${copyStyle.copyIcon} ${ |
| | | isCopied ? copyStyle.copied : '' |
| | | }`} |
| | | ></div> |
| | | </div> |
| | | </Tooltip> |
| | | ) |
| | | } |
| | |
| | | } |
| | | > |
| | | <div |
| | | className={`h-8 w-8 cursor-pointer rounded-lg hover:bg-components-button-ghost-bg-hover ${className ?? '' |
| | | className={`w-8 h-8 cursor-pointer hover:bg-gray-100 rounded-lg ${ |
| | | className ?? '' |
| | | }`} |
| | | > |
| | | <div |
| | | onClick={onClickCopy} |
| | | onMouseLeave={onMouseLeave} |
| | | className={`h-full w-full ${copyStyle.copyIcon} ${isCopied ? copyStyle.copied : '' |
| | | className={`w-full h-full ${copyStyle.copyIcon} ${ |
| | | isCopied ? copyStyle.copied : '' |
| | | }`} |
| | | ></div> |
| | | </div> |