Skip to content

Commit

Permalink
Update styles and mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dzole0311 authored and snmln committed Nov 22, 2024
1 parent 6012ce3 commit 5d8d783
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
39 changes: 28 additions & 11 deletions app/scripts/components/common/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,17 @@ const CardLabel = styled.span`

const CardFigure = styled(Figure)`
order: -1;
background: ${themeVal('color.primary-100')};
width: 100%;
${(props) => !props.isCoverOrFeatured && `aspect-ratio: 2/1;`}
background: ${(props) =>
props.src ? 'none' : props.theme.color['primary-100']};
img {
height: 100%;
width: 100%;
object-fit: cover;
mix-blend-mode: multiply;
display: ${(props) => (props.src ? 'inline-block' : 'none')};
display: ${(props) => (props.src ? 'block' : 'none')};
}
`;

Expand Down Expand Up @@ -287,7 +290,7 @@ function CardComponent(props: CardComponentPropsType) {
footerContent,
hideExternalLinkBadge,
onCardClickCapture,
onClick,
onClick
} = props;
// @TODO: This process is not necessary once all the instances adapt the linkProperties syntax
// Consolidate them to use LinkProperties only
Expand All @@ -299,18 +302,29 @@ function CardComponent(props: CardComponentPropsType) {
linkProperties = linkPropertiesProps;
} else {
const { linkTo } = props;
linkProperties = linkTo ? {
linkTo,
pathAttributeKeyName: 'to',
LinkElement: SmartLink
} : undefined;
linkProperties = linkTo
? {
linkTo,
pathAttributeKeyName: 'to',
LinkElement: SmartLink
}
: undefined;
}

const isExternalLink = linkProperties ? /^https?:\/\//.test(linkProperties.linkTo) : false;
const isExternalLink = linkProperties
? /^https?:\/\//.test(linkProperties.linkTo)
: false;

return (
<ElementInteractive
{...(linkProperties ? {linkProps: {as: linkProperties.LinkElement, [linkProperties.pathAttributeKeyName]: linkProperties.linkTo}} : {})}
{...(linkProperties
? {
linkProps: {
as: linkProperties.LinkElement,
[linkProperties.pathAttributeKeyName]: linkProperties.linkTo
}
}
: {})}
as={CardItem}
cardType={cardType}
className={className}
Expand Down Expand Up @@ -358,7 +372,10 @@ function CardComponent(props: CardComponentPropsType) {
</CardBody>
)}
{footerContent && <CardFooter>{footerContent}</CardFooter>}
<CardFigure src={imgSrc}>
<CardFigure
src={imgSrc}
isCoverOrFeatured={cardType === 'cover' || cardType === 'featured'}
>
<img src={imgSrc} alt={imgAlt} loading='lazy' />
</CardFigure>
</>
Expand Down
6 changes: 0 additions & 6 deletions mock/stories/external-link-example.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ featured: true
id: 'external-link-test'
name: External Link Test
description: Story to test external link
media:
src: ::file ./img-placeholder-6.jpg
alt: Generic placeholder by Unsplash
author:
name: Unsplash
url: https://unsplash.com/
pubDate: 2023-02-09
hideExternalLinkBadge: false
taxonomy:
Expand Down

0 comments on commit 5d8d783

Please sign in to comment.