Pythonidaer / reddie

React app for saving and retrieving Reddit comments.
0 stars 1 forks source link

Comment Cards can be really really long and need to be truncated #14

Closed Pythonidaer closed 1 year ago

Pythonidaer commented 1 year ago

Is there functionality in React-Bootstrap that can achieve this?

Pythonidaer commented 1 year ago

https://www.npmjs.com/package/react-read-more-read-less https://react-bootstrap.netlify.app/docs/utilities/transitions/#collapse

Pythonidaer commented 1 year ago

To test in develop branch::

import Card from 'react-bootstrap/Card';
import ShowMoreText from 'react-show-more-text';

function ExpandableCard({ title, text, lines }) {
  return (
    <Card>
      <Card.Header>{title}</Card.Header>
      <Card.Body>
        <ShowMoreText
          lines={lines}
          more="Read more"
          less="Read less"
          anchorClass="btn-link"
          expanded={false}
          width={280}
        >
          {text}
        </ShowMoreText>
      </Card.Body>
    </Card>
  );
}