import React, { useState } from 'react'; import s from './JeepItem.module.scss'; export const JeepItem = ({ ...props }) => { const { img, title, description, readMore, link } = props; const [openDesc, setOpenDesc] = useState(false); function kitcut(text: string, limit: number) { text = text.trim(); if (text.length <= limit) return text; text = text.slice(0, limit); // тупо отрезать по лимиту let lastSpace = text.lastIndexOf(' '); if (lastSpace > 0) { // нашлась граница слов, ещё укорачиваем text = text.substr(0, lastSpace); } return text + '...'; } return (
{title}
{openDesc ? description : kitcut(description, 145)} setOpenDesc(!openDesc)}> {openDesc ? 'Read Less' : 'Read More'}
link()} className={s.button}> Customize appearance
); };