Skip to content
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
6 changes: 4 additions & 2 deletions src/compounds/Item/CardBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, Card, Collapse } from 'react-bootstrap'
import NextLink from '../../components/NextLink/NextLink'
import LinkedButton from '../LinkedButton/LinkedButton'

const CardBody = ({ buttonLink, buttonProps, item, markdownDescriptionTruncated, markdownDescriptionExtended, orientation, titleLink, withButtonLink, withTitleLink }) => {
const CardBody = ({ buttonLink, buttonProps, item, markdownDescriptionTruncated, markdownDescriptionExtended, orientation, titleLink, truncateAt, withButtonLink, withTitleLink }) => {
const { id, description, name, snippet } = item
const [open, setOpen] = useState(false)

Expand Down Expand Up @@ -32,7 +32,7 @@ const CardBody = ({ buttonLink, buttonProps, item, markdownDescriptionTruncated,
<div className='fw-light'>{markdownDescriptionExtended}</div>
</Collapse>
</div>
{description?.length > 300 && (
{description?.length > truncateAt && (
<Button variant="link" onClick={() => setOpen(!open)} className="p-0 mt-3">
{open ? ' Show less' : ' Read more'}
</Button>
Expand Down Expand Up @@ -86,6 +86,7 @@ CardBody.propTypes = {
PropTypes.string,
PropTypes.elementType,
]),
truncateAt: PropTypes.number,
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
titleLink: PropTypes.string,
withButtonLink: PropTypes.bool,
Expand All @@ -100,6 +101,7 @@ CardBody.defaultProps = {
},
markdownDescriptionTruncated: '',
markdownDescriptionExtended: '',
truncateAt: 300,
orientation: 'vertical',
titleLink: '',
withButtonLink: false,
Expand Down
6 changes: 4 additions & 2 deletions src/compounds/Item/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import ItemLoading from './ItemLoading'
import NextLink from '../../components/NextLink/NextLink'
import './item.scss'

const Item = ({ buttonLink, buttonProps, markdownDescriptionTruncated, markdownDescriptionExtended, href, isLoading, item, orientation, titleLink, withButtonLink,
withTitleLink, width }) => {
const Item = ({ buttonLink, buttonProps, markdownDescriptionTruncated, markdownDescriptionExtended, href, isLoading, item, orientation, titleLink, truncateAt,
withButtonLink, withTitleLink, width }) => {
if (isLoading) {
return (
<>
Expand Down Expand Up @@ -49,6 +49,7 @@ const Item = ({ buttonLink, buttonProps, markdownDescriptionTruncated, markdownD
markdownDescriptionExtended={markdownDescriptionExtended}
orientation={orientation}
titleLink={link}
truncateAt={truncateAt}
withButtonLink={withButtonLink}
withTitleLink={withTitleLink}
/>
Expand All @@ -69,6 +70,7 @@ const Item = ({ buttonLink, buttonProps, markdownDescriptionTruncated, markdownD
item={item}
markdownDescriptionTruncated={markdownDescriptionTruncated}
markdownDescriptionExtended={markdownDescriptionExtended}
truncateAt={truncateAt}
orientation={orientation}
titleLink={link}
withButtonLink={withButtonLink}
Expand Down
30 changes: 29 additions & 1 deletion src/compounds/Item/Item.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,42 @@ Default.args = {
},
name: 'Microbiological Sterility Testing',
slug: 'microbiological-sterility-testing',
snippet: ''
},
titleLink: '/',
orientation: 'vertical',
style: {},
withButtonLink: false,
withTitleLink: false,
markdownDescriptionTruncated: null,
markdownDescriptionExtended: null
}

export const Horizontal = Template.bind({})
Horizontal.args = {
buttonLink: '/',
buttonProps: {
backgroundColor: '#A9A9A9',
label: 'Request this item',
},
item: {
description: 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
id: 1,
img: {
src: item,
alt: 'Several rows of test tubes with a liquid being put into one.',
},
name: 'Microbiological Sterility Testing',
slug: 'microbiological-sterility-testing',
},
titleLink: '/',
orientation: 'horizontal',
style: {},
withButtonLink: false,
withTitleLink: false,
markdownDescriptionTruncated: 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.',
markdownDescriptionExtended: ' Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.'
markdownDescriptionExtended: 'Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
truncateAt: 300
}

export const isLoading = Template.bind({})
Expand Down
Loading