from value
Should be called when size is changed
size value
Array of size options
to value
total value
import { useSizeOptions } from "@nosto/search-js/preact"
import { defaultConfig, sizes } from "../config"
export default () => {
const options = useSizeOptions(sizes, defaultConfig.serpSize)
const { from, to, total, size, sizeOptions, handleSizeChange } = options
return (
<div>
<div>
{from} - {total < to ? total : to} of {total} items
</div>
{sizeOptions.length > 0 && (
<div>
<select
value={size}
onChange={e => handleSizeChange(e.target.value)}
>
{sizeOptions.map(v => (
<option value={v}>{v} items per page</option>
))}
</select>
</div>
)}
</div>
)
}
Preact hook that provides size options to the component.