You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

search-home.tsx 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { Input } from '@/components/originui/input';
  2. import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
  3. import { cn } from '@/lib/utils';
  4. import { Search } from 'lucide-react';
  5. import { Dispatch, SetStateAction } from 'react';
  6. import './index.less';
  7. import Spotlight from './spotlight';
  8. export default function SearchPage({
  9. isSearching,
  10. setIsSearching,
  11. searchText,
  12. setSearchText,
  13. }: {
  14. isSearching: boolean;
  15. setIsSearching: Dispatch<SetStateAction<boolean>>;
  16. searchText: string;
  17. setSearchText: Dispatch<SetStateAction<string>>;
  18. }) {
  19. const { data: userInfo } = useFetchUserInfo();
  20. return (
  21. <section className="relative w-full flex transition-all justify-center items-center mt-32">
  22. <div className="relative z-10 px-8 pt-8 flex text-transparent flex-col justify-center items-center w-[780px]">
  23. <h1
  24. className={cn(
  25. 'text-4xl font-bold bg-gradient-to-r from-sky-600 from-30% via-sky-500 via-60% to-emerald-500 bg-clip-text',
  26. )}
  27. >
  28. RAGFlow
  29. </h1>
  30. <div className="rounded-lg text-primary text-xl sticky flex justify-center w-full transform scale-100 mt-8 p-6 h-[230px] border">
  31. {!isSearching && <Spotlight className="z-0" />}
  32. <div className="flex flex-col justify-center items-center w-2/3">
  33. {!isSearching && (
  34. <>
  35. <p className="mb-4 transition-opacity">👋 Hi there</p>
  36. <p className="mb-10 transition-opacity">
  37. Welcome back, {userInfo?.nickname}
  38. </p>
  39. </>
  40. )}
  41. <div className="relative w-full ">
  42. <Input
  43. placeholder="How can I help you today?"
  44. className="w-full rounded-full py-6 px-4 pr-10 text-text-primary text-lg bg-bg-base delay-700"
  45. value={searchText}
  46. onKeyUp={(e) => {
  47. if (e.key === 'Enter') {
  48. setIsSearching(!isSearching);
  49. }
  50. }}
  51. onChange={(e) => {
  52. setSearchText(e.target.value || '');
  53. }}
  54. />
  55. <button
  56. type="button"
  57. className="absolute right-2 top-1/2 -translate-y-1/2 transform rounded-full bg-white p-2 text-gray-800 shadow w-12"
  58. onClick={() => {
  59. setIsSearching(!isSearching);
  60. }}
  61. >
  62. <Search size={22} className="m-auto" />
  63. </button>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </section>
  69. );
  70. }