wwf
3 天以前 a430284aa21e3ae1f0d5654e55b2ad2852519cc2
app/components/base/search-input/index.tsx
@@ -1,8 +1,9 @@
import type { FC } from 'react'
import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { RiCloseCircleFill, RiSearchLine } from '@remixicon/react'
import { RiSearchLine } from '@remixicon/react'
import cn from '@/utils/classnames'
import { XCircle } from '@/app/components/base/icons/src/vender/solid/general'
type SearchInputProps = {
  placeholder?: string
@@ -26,20 +27,23 @@
  return (
    <div className={cn(
      'group flex h-8 items-center overflow-hidden rounded-lg border-none bg-components-input-bg-normal px-2 hover:bg-components-input-bg-hover',
      focus && '!bg-components-input-bg-active',
      white && '!border-gray-300 !bg-white shadow-xs hover:!border-gray-300 hover:!bg-white',
      'group flex items-center px-2 h-8 rounded-lg bg-gray-200 hover:bg-gray-300 border border-transparent overflow-hidden',
      focus && '!bg-white hover:bg-white shadow-xs !border-gray-300',
      !focus && value && 'hover:!bg-gray-200 hover:!shadow-xs hover:!border-black/5',
      white && '!bg-white hover:!bg-white shadow-xs !border-gray-300 hover:!border-gray-300',
      className,
    )}>
      <div className="pointer-events-none mr-1.5 flex h-4 w-4 shrink-0 items-center justify-center">
        <RiSearchLine className="h-4 w-4 text-components-input-text-placeholder" aria-hidden="true" />
      <div className="pointer-events-none shrink-0 flex items-center mr-1.5 justify-center w-4 h-4">
        <RiSearchLine className="h-3.5 w-3.5 text-gray-500" aria-hidden="true" />
      </div>
      <input
        type="text"
        name="query"
        className={cn(
          'system-sm-regular caret-#295EFF block h-[18px] grow appearance-none border-0 bg-transparent text-components-input-text-filled outline-none placeholder:text-components-input-text-placeholder',
          white && '!bg-white placeholder:!text-gray-400 hover:!bg-white group-hover:!bg-white',
          'grow block h-[18px] bg-gray-200 border-0 text-gray-700 text-[13px] placeholder:text-gray-500 appearance-none outline-none group-hover:bg-gray-300 caret-blue-600',
          focus && '!bg-white hover:bg-white group-hover:bg-white placeholder:!text-gray-400',
          !focus && value && 'hover:!bg-gray-200 group-hover:!bg-gray-200',
          white && '!bg-white hover:!bg-white group-hover:!bg-white placeholder:!text-gray-400',
        )}
        placeholder={placeholder || t('common.operation.search')!}
        value={internalValue}
@@ -61,13 +65,13 @@
      />
      {value && (
        <div
          className='group/clear flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center'
          className='shrink-0 flex items-center justify-center w-4 h-4 cursor-pointer group/clear'
          onClick={() => {
            onChange('')
            setInternalValue('')
          }}
        >
          <RiCloseCircleFill className='h-4 w-4 text-text-quaternary group-hover/clear:text-text-tertiary' />
          <XCircle className='w-3.5 h-3.5 text-gray-400 group-hover/clear:text-gray-600' />
        </div>
      )}
    </div>