import { Button, Container } from 'react-bootstrap' import styles from './search.module.css' import SearchIcon from '../svgs/search-fill.svg' import CloseIcon from '../svgs/close-line.svg' import { useEffect, useState } from 'react' import { Form, Input, SubmitButton } from './form' import { useRouter } from 'next/router' export default function Search ({ sub }) { const router = useRouter() const [searching, setSearching] = useState(router.query.q) const [q, setQ] = useState(router.query.q) const [atBottom, setAtBottom] = useState() useEffect(() => { setAtBottom(Math.ceil(window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) window.onscroll = function (ev) { if (Math.ceil(window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) { setAtBottom(true) } else { setAtBottom(false) } } }, []) const showSearch = atBottom || searching || router.query.q return ( <>