Copy hooks/useHovering.ts to glitch-soc
parent
a0047223a5
commit
43b38dc9e6
|
@ -1,7 +1,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { autoPlayGif } from 'flavours/glitch/initial_state';
|
import { autoPlayGif } from 'flavours/glitch/initial_state';
|
||||||
import { useHovering } from 'hooks/useHovering';
|
import { useHovering } from 'flavours/glitch/hooks/useHovering';
|
||||||
import type { Account } from 'flavours/glitch/types/resources';
|
import type { Account } from 'flavours/glitch/types/resources';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
|
export const useHovering = (animate?: boolean) => {
|
||||||
|
const [hovering, setHovering] = useState<boolean>(animate ?? false);
|
||||||
|
|
||||||
|
const handleMouseEnter = useCallback(() => {
|
||||||
|
if (animate) return;
|
||||||
|
setHovering(true);
|
||||||
|
}, [animate]);
|
||||||
|
|
||||||
|
const handleMouseLeave = useCallback(() => {
|
||||||
|
if (animate) return;
|
||||||
|
setHovering(false);
|
||||||
|
}, [animate]);
|
||||||
|
|
||||||
|
return { hovering, handleMouseEnter, handleMouseLeave };
|
||||||
|
};
|
|
@ -10,7 +10,9 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
"*": ["app/javascript/*"],
|
"locales": ["app/javascript/locales"],
|
||||||
|
"flavours/glitch": ["app/javascript/flavours/glitch"],
|
||||||
|
"flavours/glitch/*": ["app/javascript/flavours/glitch/*"],
|
||||||
"mastodon": ["app/javascript/mastodon"],
|
"mastodon": ["app/javascript/mastodon"],
|
||||||
"mastodon/*": ["app/javascript/mastodon/*"]
|
"mastodon/*": ["app/javascript/mastodon/*"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue