Rev 2917 | 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 '@utils'export default function FeedDescription({ description = '' }) {const [showMore, setShowMore] = useState(false)const stripText = description.replace(/<p>|<\/p>/g, '')const maxLength = 140const truncatedText = stripText.slice(0, maxLength)const isTruncated = stripText.length > maxLengthconst toggleShowMore = () => setShowMore((prevState) => !prevState)return (<Typography>{parse(showMore ? stripText : truncatedText)}{isTruncated && (<TypographyonClick={toggleShowMore}variant='overline'color='primary'sx={{ cursor: 'pointer', display: 'inline-flex' }}aria-expanded={showMore}>{showMore ? ' Mostrar menos' : '... Mostrar más'}</Typography>)}</Typography>)}