Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6623 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6623 Rev 6830
Línea 1... Línea -...
1
/* eslint-disable react/display-name */
-
 
2
import React, { useEffect, useRef, useState } from 'react'
1
import React, { useEffect, useRef, useState } from 'react'
3
import RecommendIcon from './reactions/Recommned'
-
 
4
import FavoriteIcon from './reactions/LoveIt'
-
 
5
import VolunteerActivismIcon from './reactions/Support'
-
 
6
import EmojiEmotionsIcon from './reactions/Fun'
2
import { debounce } from '../../utils'
7
import TungstenIcon from './reactions/UserIdea'
3
import useOutsideClick from '../../hooks/useOutsideClick'
Línea -... Línea 4...
-
 
4
 
8
 
5
import RecommendIcon from '../UI/icons/Recommned'
-
 
6
import FavoriteIcon from '../UI/icons/LoveIt'
-
 
7
import VolunteerActivismIcon from '../UI/icons/Support'
9
import { debounce } from '../../../utils'
8
import EmojiEmotionsIcon from '../UI/icons/Fun'
Línea 10... Línea 9...
10
import useOutsideClick from '../../../hooks/useOutsideClick'
9
import TungstenIcon from '../UI/icons/Interest'
11
 
10
 
12
const withReactions = (
11
const withReactions = (
13
  Component,
12
  Component,
14
  { onSelect, onDelete, myReaction, withTitle = false }
13
  { onSelect, onDelete, myReaction, withTitle = false }
15
) => {
14
) => {
16
  return () => {
15
  return function HOC() {
17
    const [settedReaction, setSettedReaction] = useState(null)
16
    const [settedReaction, setSettedReaction] = useState(null)
18
    const [showReactions, setShowReactions] = useState(false)
17
    const [showReactions, setShowReactions] = useState(false)
Línea 19... Línea 18...
19
    const rectionBtn = useRef(null)
18
    const rectionBtn = useRef(null)
20
    const outsideClick = useOutsideClick(rectionBtn)
19
    useOutsideClick(rectionBtn, () => setShowReactions(false))
21
 
20
 
22
    const reactionsOptions = [
21
    const reactionsOptions = [
Línea 55... Línea 54...
55
    const onHover = debounce(() => setShowReactions(true), 500)
54
    const onHover = debounce(() => setShowReactions(true), 500)
Línea 56... Línea 55...
56
 
55
 
Línea 57... Línea 56...
57
    const onUnhover = debounce(() => setShowReactions(false), 500)
56
    const onUnhover = debounce(() => setShowReactions(false), 500)
58
 
-
 
59
    useEffect(() => {
-
 
60
      if (outsideClick) setShowReactions(false)
-
 
61
    }, [outsideClick])
-
 
62
 
57
 
63
    useEffect(() => {
58
    useEffect(() => {
64
      const currentReaction = reactionsOptions.find(
59
      const currentReaction = reactionsOptions.find(
65
        (reaction) => reaction.type === myReaction
60
        (reaction) => reaction.type === myReaction
66
      )
61
      )