Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2838 | Rev 2892 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React, { useState } from 'react'
import { Typography } from '@mui/material'
import parse from 'html-react-parser'

export default function FeedDescription({ description }) {
  const [showMore, setShowMore] = useState(false)
  const text = description.replace(/<\/?p>/g, '')

  const toggleShowMore = () => setShowMore(!showMore)

  if (description.length > 120) {
    return (
      <Typography onClickCapture={toggleShowMore}>
        {parse(showMore ? text : text.slice(0, 120))}

        <Typography variant='body2' sx={{ cursor: 'pointer' }}>
          {showMore ? ' ver menos' : '... ver más'}
        </Typography>
      </Typography>
    )
  }

  return <Typography>{parse(text)}</Typography>
}