hide ellipsis if non-expandable

This commit is contained in:
BFlat committed 2023-01-25 13:13:07 +07:00
1 parent 9a78323372
commit bedd8f1740
1 file changed
+2 -2
@@ -7,11 +7,11 @@ interface Props {
export const TextExpander: React.FC<Props> = ({ text }) => {
const [expanded, setExpanded] = useState(false);
const shortText = text.slice(0, 250) + "...";
const shortText = text.slice(0, 250);
return (
<>
{expanded ? text : shortText}
{expanded || text.length <= 250 ? text : shortText + "..."}
{text.length > 250 && (
<button
className="btn-link fw-medium p-0 ps-1"