Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3949 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3630 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
5115 stevensc 3
import parse from 'html-react-parser'
3630 stevensc 4
 
5
const SharedContent = ({
5115 stevensc 6
  name,
7
  image,
8
  timeElapse,
9
  description,
10
  fileVideo,
11
  fileImagePreview,
12
  fileImage,
13
  fileDocument
3630 stevensc 14
}) => {
5115 stevensc 15
  const [isReadMoreActive, setIsReadMoreActive] = useState(false)
3630 stevensc 16
 
5115 stevensc 17
  const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)
3630 stevensc 18
 
5115 stevensc 19
  const htmlParsedText = (fullStringText) => {
20
    const fullText = parse(fullStringText)
21
    if (fullStringText.length > 500) {
22
      const shortenedString = fullStringText.substr(0, 500)
23
      const shortenedText = parse(`${shortenedString}... `)
24
      return (
3630 stevensc 25
                <p>
26
                    {isReadMoreActive ? fullText : shortenedText}
27
                    <span className='cursor-pointer' onClick={readMoreHandler}>
5115 stevensc 28
                        {isReadMoreActive ? ' Leer menos' : ' Leer más'}
3630 stevensc 29
                    </span>
30
                </p>
5115 stevensc 31
      )
32
    }
33
    return <p>{fullText}</p>
34
  }
3630 stevensc 35
 
5115 stevensc 36
  return (
3630 stevensc 37
        <div className="shared-post-bar">
38
            <div className="post-bar">
39
                <div className="post_topbar">
40
                    <div className="usy-dt">
41
                        <img
42
                            src={image}
43
                            alt=""
5115 stevensc 44
                            style={{ width: '50px', height: 'auto' }}
3630 stevensc 45
                        />
46
                        <div className="usy-name">
47
                            <h3>{name}</h3>
48
                            <span>
49
                                {timeElapse}
50
                            </span>
51
                        </div>
52
                    </div>
53
                </div>
54
                <div className="job_descp">
55
                    <div className="show-read-more">
56
                        {htmlParsedText(description)}
57
                    </div>
58
                    {fileImage &&
3949 stevensc 59
                        <img src={fileImage} className="Entradas" loading='lazy' />
3630 stevensc 60
                    }
61
                    {fileVideo &&
62
                        <video
63
                            src={fileVideo}
64
                            controls
65
                            poster={fileImagePreview}
66
                            preload="none"
67
                        />
68
                    }
69
                    {fileDocument &&
70
                        <a href={fileDocument} target="_blank" rel="noreferrer">
71
                            Descargar
72
                        </a>
73
                    }
74
                </div>
75
            </div>
76
        </div>
5115 stevensc 77
  )
3630 stevensc 78
}
79
 
5115 stevensc 80
export default SharedContent