mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-06 10:06:41 +07:00
added flow menus
This commit is contained in:
parent
65d13afab9
commit
c8204a41a2
13 changed files with 358 additions and 53 deletions
18
src/utils/hooks/useFocusEvent.ts
Normal file
18
src/utils/hooks/useFocusEvent.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
|
||||
export const useFocusEvent = (initialState = false) => {
|
||||
const [focused, setFocused] = useState(initialState);
|
||||
|
||||
const onFocus = useCallback(
|
||||
event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
setFocused(true);
|
||||
},
|
||||
[setFocused]
|
||||
);
|
||||
const onBlur = useCallback(() => setTimeout(() => setFocused(false), 300), [setFocused]);
|
||||
|
||||
return { focused, onBlur, onFocus };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue