Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2838 | Rev 2891 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2838 Rev 2850
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
-
 
2
import { Typography } from '@mui/material'
2
import parse from 'html-react-parser'
3
import parse from 'html-react-parser'
Línea 3... Línea 4...
3
 
4
 
4
export default function FeedDescription({ description }) {
5
export default function FeedDescription({ description }) {
-
 
6
  const [showMore, setShowMore] = useState(false)
Línea 5... Línea 7...
5
  const [showMore, setShowMore] = useState(false)
7
  const text = description.replace(/<\/?p>/g, '')
Línea 6... Línea 8...
6
 
8
 
7
  const toggleShowMore = () => setShowMore(!showMore)
-
 
8
 
-
 
9
  if (description.length > 120) {
-
 
10
    const result = description.replace(/<\/?p>/g, '')
9
  const toggleShowMore = () => setShowMore(!showMore)
11
    const parseDescription = parse(showMore ? result : result.slice(0, 120))
10
 
12
 
11
  if (description.length > 120) {
-
 
12
    return (
-
 
13
      <Typography onClickCapture={toggleShowMore}>
13
    return (
14
        {parse(showMore ? text : text.slice(0, 120))}
-
 
15
 
14
      <p onClickCapture={toggleShowMore}>
16
        <Typography variant='body2' sx={{ cursor: 'pointer' }}>
15
        {parseDescription}
17
          {showMore ? ' ver menos' : '... ver más'}
16
        <span>{showMore ? ' ver menos' : '... ver más'}</span>
18
        </Typography>
Línea 17... Línea 19...
17
      </p>
19
      </Typography>
18
    )
20
    )