Skip to content

Commit

Permalink
feat: added image object for image handling in horizontal card component
Browse files Browse the repository at this point in the history
  • Loading branch information
Usmanfee committed Oct 18, 2024
1 parent 72cb531 commit 46c74b5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
9 changes: 7 additions & 2 deletions src/components/content/Cards/CardHorizontal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ CardHorizontal.args = {
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
borderRadius: 20,
imagePath: '',
imageAlt: 'App Card ',
image: {
src: 'https://raw.githubusercontent.com/eclipse-tractusx/portal-assets/main/public/assets/images/logos/cx-short.svg',
alt: 'alt text',
style: {
color: 'red',
},
},
status: StatusVariants.release,
statusText: 'In Release',
buttonText: 'Details',
Expand Down
40 changes: 20 additions & 20 deletions src/components/content/Cards/CardHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,36 @@

import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'
import { Box, useTheme } from '@mui/material'
import { useRef } from 'react'
import { LogoGrayData } from '../../basic/Image'
import { useRef, type CSSProperties } from 'react'
import { Image, LogoGrayData } from '../../basic/Image'
import { Typography } from '../../basic/Typography'
import { type CardChipProps } from './CardChip'

interface ICardImage {
src: string
alt?: string
style?: CSSProperties
}

interface CardHorizontalProps extends CardChipProps {
label: string
title: string
subTitle?: string
borderRadius: number
imagePath: string
imageAlt?: string
description?: string
backgroundColor?: string
buttonText?: string
onBtnClick?: React.MouseEventHandler
expandOnHover?: boolean
image: ICardImage
imageLoader?: (src: string) => Promise<ArrayBuffer>
}

export const CardHorizontal = ({
label,
title,
subTitle,
borderRadius = 0,
imagePath,
// @ts-expect-error keep for backward compatibility
imageAlt,
description,
// @ts-expect-error keep for backward compatibility
status,
Expand All @@ -55,6 +58,8 @@ export const CardHorizontal = ({
buttonText,
onBtnClick,
backgroundColor,
image,
imageLoader,
// @ts-expect-error keep for backward compatibility
expandOnHover = false,
}: CardHorizontalProps) => {
Expand All @@ -76,19 +81,14 @@ export const CardHorizontal = ({
},
}}
>
<Box
className="cx-card__horizontal--left"
sx={{
flex: '0 0 33.333333%',
maxWidth: '33.333333%',
minHeight: '200px',
backgroundImage: `url(${imagePath || LogoGrayData})`,
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundColor: theme.palette.accent.accent02,
}}
/>
{image && (
<Image
src={image?.src ?? LogoGrayData}
alt={image?.alt}
loader={imageLoader}
style={{ ...image?.style }}
/>
)}
<Box
className="cx-card__horizontal--right"
sx={{
Expand Down

0 comments on commit 46c74b5

Please sign in to comment.