Skip to content

Commit

Permalink
Merge pull request #66 from 001elijah/feachure-show-text
Browse files Browse the repository at this point in the history
add show more text button for card description
  • Loading branch information
001elijah committed Jun 30, 2023
2 parents 5868b69 + 5f38e9e commit 4f210ef
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 8 deletions.
55 changes: 55 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"react-responsive": "^9.0.2",
"react-router-dom": "^6.13.0",
"react-scripts": "5.0.1",
"react-show-more-text": "^1.6.2",
"redux-persist": "^6.0.0",
"sass": "^1.63.4",
"shortid": "^2.2.16",
Expand Down
14 changes: 13 additions & 1 deletion src/components/TaskCard/TaskCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector, useDispatch } from 'react-redux';
import clsx from 'clsx';
import shortid from 'shortid';
import PropTypes from 'prop-types';
import ShowMoreText from 'react-show-more-text';

import sprite from '../../assets/icons/sprite.svg';
import { removeCard, updateCard } from 'redux/Cards/cardsOperations';
Expand Down Expand Up @@ -74,7 +75,18 @@ export const TaskCard = ({
></div>
<div className={s.infoWrapper}>
<h4 className={clsx(s.title, s[theme])}>{title}</h4>
<p className={clsx(s.description, s[theme])}>{description}</p>

<ShowMoreText
lines={2}
more="more"
less="less"
anchorClass={clsx(s.showMoreAnchor, s[theme])}
expanded={false}
truncatedEndingComponent={'... '}
className={clsx(s.description, s[theme])}
>
{description}
</ShowMoreText>
</div>
<div className={clsx(s.controlPanel, s[theme])}>
<div className={s.statusInfo}>
Expand Down
26 changes: 19 additions & 7 deletions src/components/TaskCard/TaskCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
padding: 14px 21px;
width: 335px;
margin-right: 8px;
height: 154px;
height: max-content;
background-color: $white-text-color;
border-radius: 8px;
overflow: hidden;
Expand Down Expand Up @@ -62,17 +62,29 @@
line-height: 1.33;
color: $icon-main-color;

display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;

&.dark {
color: $icon-secondary-color;
}
}

.showMoreAnchor {
font-weight: 500;
color: $priority-high-color;
cursor: pointer;

transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);

&.colorful {
color: $accent-bright-color;
}

&:hover {
font-weight: 700;
transform: scale(1.04);
text-decoration: underline;
}
}

.controlPanel {
padding-top: 14px;

Expand Down

0 comments on commit 4f210ef

Please sign in to comment.