Files
old-kitabcitab-frontend/kitabcitab/pages/index.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-12-28 22:09:58 +01:00
import { AiOutlineSearch, AiOutlineClose } from 'react-icons/ai'
2023-01-03 13:31:47 +01:00
import Link from 'next/link'
import { useRef } from 'react'
import { useRouter } from 'next/router'
export default function Home({data}) {
const router = useRouter()
2023-03-08 12:08:29 +01:00
const searchInputRef = useRef("")
const search = () => {
const term = searchInputRef.current.value
if(!term) return
router.push(`/search?term=${term}`)
}
2022-12-27 02:53:10 +01:00
2023-03-08 12:08:29 +01:00
const enterHandler = (e) => {
const term = searchInputRef.current.value
if(e.key === "Enter" && term !== "") router.push(`/search?term=${term}`)
}
2022-12-27 02:53:10 +01:00
return (
2022-12-30 04:02:16 +01:00
<div className="flex flex-col justify-center items-center w-[100vw] h-[50vh]">
2022-12-28 22:09:58 +01:00
<div className="p-10 ">
<p className="text-6xl text-white font-serif">KitabCitab</p>
2022-12-27 02:53:10 +01:00
</div>
2022-12-28 22:09:58 +01:00
<div className="group
hover:bg-[#303134]
2022-12-30 04:02:16 +01:00
py-2 border-[1px] w-[90%]
2022-12-28 22:09:58 +01:00
border-[#bdc1c6] rounded-3xl flex flex-row justify-around
2022-12-27 02:53:10 +01:00
2022-12-28 22:09:58 +01:00
tablet:w-[70%]
2022-12-27 02:53:10 +01:00
2022-12-28 22:09:58 +01:00
laptop:w-[40%]
2022-12-27 02:53:10 +01:00
"
2022-12-28 22:09:58 +01:00
>
<i className='rounded-3xl hover:border-black text-[#9aa0a6] px-3' onClick={() => search()}><AiOutlineSearch size={25}/></i>
2023-03-08 12:08:29 +01:00
<input ref={searchInputRef} onKeyDown={(e) => enterHandler(e)} className="bg-[#202124] group-hover:bg-[#303134] w-[80%] px-2 active:border-none text-white outline-none text-xl"/>
<i className='rounded-3xl hover:border-black text-[#9aa0a6] px-3' onClick={() => (searchInputRef.current.value = "")}><AiOutlineClose size={25} /></i>
2022-12-27 02:53:10 +01:00
</div>
<button
2022-12-28 22:09:58 +01:00
className='py-1 px-10 mt-10 text-3xl rounded-md bg-[#303134] text-white font-serif border-[1px] border-[#303134] hover:border-[#fff] hover:border-[1px]'
onClick={() => search()}
2022-12-28 22:09:58 +01:00
>
Traži
</button>
2022-12-27 02:53:10 +01:00
</div>
)
}