Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-4997: add rerad more (#1227) #1228

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/team-member/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'reactstrap'

import styles from './team-member.module.scss'
import { ReadMore } from '../../design-v2/components/testimonial'

const TeamMember = ({
className = '',
Expand All @@ -28,7 +29,13 @@ const TeamMember = ({
{role && (
<CardSubtitle className={styles.teamMemberRole}>{role}</CardSubtitle>
)}
{description && <CardText>{description}</CardText>}
{description && description.length > 110 ? (
<ReadMore renderBreak textMaxLength={110}>
{description}
</ReadMore>
) : (
<CardText>{description}</CardText>
)}
{children}
</CardBody>
</Card>
Expand Down
7 changes: 5 additions & 2 deletions design-v2/components/testimonial/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from '@oacore/design/lib/utils/class-names'

import styles from './testimonial-card.module.scss'

const ReadMore = ({ children, textMaxLength }) => {
export const ReadMore = ({ children, textMaxLength, renderBreak }) => {
const text = children
const [isReadMore, setIsReadMore] = React.useState(true)
const toggleReadMore = () => {
Expand All @@ -12,10 +12,13 @@ const ReadMore = ({ children, textMaxLength }) => {
return (
<p className={styles.citation}>
“{isReadMore ? `${text.slice(0, textMaxLength)}...` : text}”
{renderBreak && <br />}
<span
onClick={toggleReadMore}
role="presentation"
className={styles.readMore}
className={classNames.use(styles.readMore, {
[styles.renderBreak]: renderBreak,
})}
>
{isReadMore ? ' Show more' : ' Show less'}
</span>
Expand Down
4 changes: 4 additions & 0 deletions design-v2/components/testimonial/testimonial-card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
color: var(--primary);
text-decoration: underline;
}

.render-break {
margin-left: 0;
}
Loading