edited-beacon.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useRef } from 'react'
  4. import { useHover } from 'ahooks'
  5. import { RiResetLeftLine } from '@remixicon/react'
  6. import Tooltip from '@/app/components/base/tooltip'
  7. import { useTranslation } from 'react-i18next'
  8. type Props = {
  9. onReset: () => void
  10. }
  11. const EditedBeacon: FC<Props> = ({
  12. onReset,
  13. }) => {
  14. const { t } = useTranslation()
  15. const ref = useRef(null)
  16. const isHovering = useHover(ref)
  17. return (
  18. <div ref={ref} className='size-4 cursor-pointer'>
  19. {isHovering ? (
  20. <Tooltip popupContent={t('common.operation.reset')}>
  21. <div className='flex justify-center items-center size-4 bg-text-accent-secondary rounded-full' onClick={onReset}>
  22. <RiResetLeftLine className='size-[10px] text-text-primary-on-surface' />
  23. </div>
  24. </Tooltip>
  25. ) : (
  26. <div className='flex items-center justify-center size-4'>
  27. <div className='size-1 rounded-full bg-text-accent-secondary'></div>
  28. </div>
  29. )}
  30. </div>
  31. )
  32. }
  33. export default React.memo(EditedBeacon)