* Add dependencies for openapi-page component * Add openapi-page component * Use openapi-page component for /api-docs page * add /api link to nav (#570) * website: remove superflous netlify config file * website: misc clean up website/readme - remove netlify badge - run through prettier markdown fmt * website: add /api docs to nav - adds /api-docs => /api rewrite - updates open-api component base api path to be /api - adds .html rewrite for good measure * Fix currentPath highlight issue in subnav * Clean up inline styles in operation-object * Remove React imports * Remove api-docs rewrite Co-authored-by: Kyle MacDonald <kylemac@users.noreply.github.com>
23 lines
587 B
JavaScript
23 lines
587 B
JavaScript
import { useEffect } from 'react'
|
|
|
|
/**
|
|
* Hook that runs a callback on clicks outside the ref
|
|
*/
|
|
function useOnClickOutside(ref, callbackFn) {
|
|
useEffect(() => {
|
|
function handleClick(event) {
|
|
const isOutside = ref.current && !ref.current.contains(event.target)
|
|
if (isOutside) callbackFn(event)
|
|
}
|
|
|
|
// Bind the event listener
|
|
document.addEventListener('mousedown', handleClick)
|
|
return () => {
|
|
// Unbind the event listener on clean up
|
|
document.removeEventListener('mousedown', handleClick)
|
|
}
|
|
}, [ref])
|
|
}
|
|
|
|
export default useOnClickOutside
|