* dedicated search results page (redux) * Update SearchResults.tsx * adding pagination * fix pagination * say something on NoQuery * better Flash * tidying link * small fixes for results * debug info * l18n the meta info * inDebugMode * basic jest rendering of the skeleton page * basic jest rendering test * fix content tests * better document title * fix tests * quote query in page title * use home page sidebar * something when nothing is found * parseInt no longer needs the 10 * fix linting tests * fix test * prettier * Update pages/search.tsx Co-authored-by: Rachael Sewell <rachmari@github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Rachael Sewell <rachmari@github.com>
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { Spinner } from '@primer/react'
|
|
|
|
import { useTranslation } from 'components/hooks/useTranslation'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
export function Loading() {
|
|
const [showLoading, setShowLoading] = useState(false)
|
|
useEffect(() => {
|
|
let mounted = true
|
|
setTimeout(() => {
|
|
if (mounted) {
|
|
setShowLoading(true)
|
|
}
|
|
}, 1000)
|
|
|
|
return () => {
|
|
mounted = false
|
|
}
|
|
}, [])
|
|
return showLoading ? <ShowSpinner /> : <ShowNothing />
|
|
}
|
|
|
|
function ShowSpinner() {
|
|
const { t } = useTranslation(['search'])
|
|
return (
|
|
<div className="my-12">
|
|
<Spinner size="large" />
|
|
<h2>{t('loading')}</h2>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function ShowNothing() {
|
|
return (
|
|
// The min heigh is based on inspecting what the height became when it
|
|
// does render. Making this match makes the footer to not flicker
|
|
// up or down when it goes from showing nothing to something.
|
|
<div className="my-12" style={{ minHeight: 105 }}>
|
|
{/* Deliberately empty */}
|
|
</div>
|
|
)
|
|
}
|