Copy hooks/useHovering.ts to glitch-soc

main
Claire 2023-05-09 21:30:10 +02:00
parent 8e806b6e88
commit 42bdc2add9
3 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
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';
type Props = {

View File

@ -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 };
};

View File

@ -10,7 +10,9 @@
"skipLibCheck": true,
"baseUrl": "./",
"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/*"]
}